@hadoku/jobplatform-worker 2.32.41 → 2.32.43

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/dist/index.js CHANGED
@@ -1663,6 +1663,16 @@ function parseAtsSlug(url) {
1663
1663
  }
1664
1664
  return { ats: null, slug: null };
1665
1665
  }
1666
+ const TEST_BOARDS = /* @__PURE__ */ new Set(["greenhouse:linkedin", "lever:linkedin"]);
1667
+ function isTestBoardPosting(url, scraped) {
1668
+ const onTestBoard = (ats, slug2) => !!ats && !!slug2 && TEST_BOARDS.has(`${ats.toLowerCase()}:${slug2.toLowerCase()}`);
1669
+ const parsed = parseAtsSlug(url);
1670
+ return onTestBoard(parsed.ats, parsed.slug) || onTestBoard(scraped?.ats, scraped?.slug);
1671
+ }
1672
+ [...TEST_BOARDS].map((k) => {
1673
+ const [ats, slug2] = k.split(":");
1674
+ return { ats, slug: slug2 };
1675
+ });
1666
1676
  const US = [
1667
1677
  ["arlington", "va", 38.8799, -77.1068],
1668
1678
  ["austin", "tx", 30.2672, -97.7431],
@@ -2581,6 +2591,7 @@ function scheduleRankBuild(c, db, profileId, profile) {
2581
2591
  rebuildRank(db, profileId, profile).finally(() => building.delete(profileId))
2582
2592
  );
2583
2593
  }
2594
+ const MANUAL_SOURCE = "manual";
2584
2595
  function normalizeWorkplaceType(wt) {
2585
2596
  if (wt === "on_site") return "onsite";
2586
2597
  return wt;
@@ -2711,7 +2722,10 @@ const ingestRoute = createRoute({
2711
2722
  });
2712
2723
  const INGEST_BATCH_CHUNK = 100;
2713
2724
  app$4.openapi(ingestRoute, async (c) => {
2714
- const { jobs, batch_number, is_final, source, board_slug } = c.req.valid("json");
2725
+ const { jobs: received, batch_number, is_final, source, board_slug } = c.req.valid("json");
2726
+ const jobs = received.filter(
2727
+ (job) => !isTestBoardPosting(job.url, board_slug ? { ats: source, slug: board_slug } : void 0)
2728
+ );
2715
2729
  const db = c.env.JOB_PLATFORM_DB;
2716
2730
  const now = (/* @__PURE__ */ new Date()).toISOString();
2717
2731
  const stmts = jobs.map((job) => insertJobStatement(db, job, { source, board_slug, now }));
@@ -2723,7 +2737,7 @@ app$4.openapi(ingestRoute, async (c) => {
2723
2737
  }
2724
2738
  endTime(c, "insert");
2725
2739
  const accepted = inserted.filter(Boolean).length;
2726
- const skipped = jobs.length - accepted;
2740
+ const skipped = received.length - accepted;
2727
2741
  const seen = jobs.filter((_, i) => !inserted[i]);
2728
2742
  const SEEN_CHUNK = 45;
2729
2743
  const storedReads = [];
@@ -3890,6 +3904,7 @@ function deserializeProfile(r) {
3890
3904
  };
3891
3905
  }
3892
3906
  const profileRoutes = app$3;
3907
+ const MAX_SEARCH_WORDS = 6;
3893
3908
  const MAX_NEARBY = 80;
3894
3909
  const LIGHT_CANDIDATE_CAP = 5e4;
3895
3910
  const FULL_SCORE_CAP = 800;
@@ -3988,6 +4003,15 @@ function registerFeedRoute(app2) {
3988
4003
  }),
3989
4004
  min_salary: z.coerce.number().min(0).optional().openapi({
3990
4005
  description: "View filter: drop jobs whose salary_max is below this. Jobs with no listed salary are kept — most postings omit it, and hiding them would hide the corpus."
4006
+ }),
4007
+ q: z.string().trim().max(100).optional().openapi({
4008
+ description: "Keyword search over title, company and location, case-insensitive. Words are AND-ed (each must appear in one of the three); at most 6 are used."
4009
+ }),
4010
+ source: z.string().trim().toLowerCase().regex(/^[a-z0-9.-]{1,40}$/).optional().openapi({
4011
+ description: "Only postings from one source: an ATS ('greenhouse', 'ashby', 'lever') or a site ('remoteok'), matched against the posting's ats and source_site."
4012
+ }),
4013
+ track: z.enum(["ic", "manager"]).optional().openapi({
4014
+ description: "Hard filter on the classified role track, for a caller without a profile (a profile's own track applies too)."
3991
4015
  })
3992
4016
  })
3993
4017
  },
@@ -4037,7 +4061,10 @@ function registerFeedRoute(app2) {
4037
4061
  min_salary,
4038
4062
  near,
4039
4063
  radius_miles,
4040
- include_remote
4064
+ include_remote,
4065
+ q,
4066
+ source,
4067
+ track
4041
4068
  } = c.req.valid("query");
4042
4069
  const hideDismissed = hideDismissedRaw === "true";
4043
4070
  const hideQueued = hideQueuedRaw === "true";
@@ -4105,6 +4132,24 @@ function registerFeedRoute(app2) {
4105
4132
  wheres.push(`(${terms.join(" OR ")})`);
4106
4133
  whereBinds.push(...nearby.map((p) => `%|${p.key}|%`));
4107
4134
  }
4135
+ if (q) {
4136
+ const words = q.split(/\s+/).filter(Boolean).slice(0, MAX_SEARCH_WORDS);
4137
+ for (const word of words) {
4138
+ const pattern = `%${word.replace(/[\\%_]/g, (ch) => `\\${ch}`)}%`;
4139
+ wheres.push(
4140
+ "(j.title LIKE ? ESCAPE '\\' OR j.company LIKE ? ESCAPE '\\' OR j.location LIKE ? ESCAPE '\\')"
4141
+ );
4142
+ whereBinds.push(pattern, pattern, pattern);
4143
+ }
4144
+ }
4145
+ if (source) {
4146
+ wheres.push("(j.ats = ? OR j.source_site LIKE ?)");
4147
+ whereBinds.push(source, `${source}%`);
4148
+ }
4149
+ if (track) {
4150
+ wheres.push("j.role_track = ?");
4151
+ whereBinds.push(track);
4152
+ }
4108
4153
  if (userId) {
4109
4154
  if (stateFilter === "new") {
4110
4155
  wheres.push("js.state IS NULL");
@@ -4123,6 +4168,11 @@ function registerFeedRoute(app2) {
4123
4168
  whereBinds.push(userId);
4124
4169
  }
4125
4170
  }
4171
+ if (userId) {
4172
+ wheres.push(`(j.source_site IS NOT '${MANUAL_SOURCE}' OR js.state IS NOT NULL)`);
4173
+ } else {
4174
+ wheres.push(`j.source_site IS NOT '${MANUAL_SOURCE}'`);
4175
+ }
4126
4176
  const whereClause = wheres.length > 0 ? `WHERE ${wheres.join(" AND ")}` : "";
4127
4177
  const andWheres = wheres.length > 0 ? ` AND ${wheres.join(" AND ")}` : "";
4128
4178
  if (profile_id && profile) {
@@ -7157,7 +7207,14 @@ function registerLocationsRoute(app2) {
7157
7207
  const ImportJobSchema = z.object({
7158
7208
  url: z.string().trim().url().max(2e3),
7159
7209
  /** Where it lands in the pipeline when it is new to the caller. */
7160
- state: JobStateSchema.exclude(["dismissed"]).default("saved")
7210
+ state: JobStateSchema.exclude(["dismissed"]).default("saved"),
7211
+ /** Typed by the person: store this instead of reading the page. */
7212
+ manual: z.object({
7213
+ title: z.string().trim().min(1).max(300),
7214
+ company: z.string().trim().min(1).max(200),
7215
+ location: z.string().trim().max(200).default(""),
7216
+ description: z.string().trim().max(2e4).default("")
7217
+ }).optional()
7161
7218
  }).openapi("ImportJob");
7162
7219
  const ImportedSchema = z.object({
7163
7220
  success: z.literal(true),
@@ -7185,6 +7242,16 @@ function failure(status, message) {
7185
7242
  };
7186
7243
  }
7187
7244
  const JOB_COLS = "id, title, company, location, url";
7245
+ const escapeHtml = (text) => text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
7246
+ function manualDescriptionHtml(text) {
7247
+ if (!text) return "";
7248
+ return text.split(/\n\s*\n/).map((para) => `<p>${escapeHtml(para.trim()).replace(/\n/g, "<br>")}</p>`).join("");
7249
+ }
7250
+ async function manualId(url) {
7251
+ const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(url));
7252
+ const hex = [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
7253
+ return `manual_${hex.slice(0, 16)}`;
7254
+ }
7188
7255
  async function greenhouseSlugFor(db, url) {
7189
7256
  const parsed = new URL(url);
7190
7257
  if (!parsed.searchParams.has("gh_jid")) return void 0;
@@ -7241,13 +7308,44 @@ function registerImportRoute(app2) {
7241
7308
  }
7242
7309
  }),
7243
7310
  async (c) => {
7244
- const { url, state } = c.req.valid("json");
7311
+ const { url, state, manual } = c.req.valid("json");
7245
7312
  const { ownerName } = c.req.valid("query");
7246
7313
  const who = await effectiveUserId(c, ownerName);
7247
7314
  if (isEffectiveUserError(who)) return c.json(who.error.body, who.error.status);
7248
7315
  const db = c.env.JOB_PLATFORM_DB;
7249
7316
  let row = await db.prepare(`SELECT ${JOB_COLS} FROM jobs WHERE url = ?`).bind(url).first();
7250
7317
  let created = false;
7318
+ if (!row && manual) {
7319
+ const now2 = (/* @__PURE__ */ new Date()).toISOString();
7320
+ const id = await manualId(url);
7321
+ const [res] = await db.batch([
7322
+ insertJobStatement(
7323
+ db,
7324
+ {
7325
+ id,
7326
+ url,
7327
+ source_site: MANUAL_SOURCE,
7328
+ title: manual.title,
7329
+ company: manual.company,
7330
+ location: manual.location,
7331
+ job_type: "unknown",
7332
+ workplace_type: "unknown",
7333
+ salary: null,
7334
+ description: manualDescriptionHtml(manual.description),
7335
+ posted_date: null,
7336
+ application_url: url,
7337
+ department: null,
7338
+ scraper_used: null,
7339
+ raw: {}
7340
+ },
7341
+ { source: MANUAL_SOURCE, now: now2 }
7342
+ )
7343
+ ]);
7344
+ created = (res.meta?.changes ?? 0) > 0;
7345
+ row = await db.prepare(`SELECT ${JOB_COLS} FROM jobs WHERE id = ?`).bind(id).first();
7346
+ if (!row) throw new Error(`import: manual ${id} neither inserted nor found`);
7347
+ if (created) await rankNewJobs(db);
7348
+ }
7251
7349
  if (!row) {
7252
7350
  let extracted;
7253
7351
  try {
@@ -7275,6 +7373,12 @@ function registerImportRoute(app2) {
7275
7373
  502
7276
7374
  );
7277
7375
  }
7376
+ if (isTestBoardPosting(job.data.url, { ats: extracted.ats, slug: extracted.board_slug })) {
7377
+ return c.json(
7378
+ failure(422, "That board holds LinkedIn's ATS test postings, not real jobs."),
7379
+ 422
7380
+ );
7381
+ }
7278
7382
  const now2 = (/* @__PURE__ */ new Date()).toISOString();
7279
7383
  const [res] = await db.batch([
7280
7384
  insertJobStatement(db, job.data, {
@@ -8,6 +8,11 @@ import type { z } from '@hono/zod-openapi';
8
8
  import type { AppEnv } from './types.js';
9
9
  import type { IngestJobSchema } from './schemas.js';
10
10
  type DB = AppEnv['JOB_PLATFORM_DB'];
11
+ /**
12
+ * The `source_site` of a posting a person typed in by hand (POST /jobs/import's
13
+ * `manual`). Nothing verified it, so the feed shows it only to people tracking it.
14
+ */
15
+ export declare const MANUAL_SOURCE = "manual";
11
16
  export type IngestJob = z.infer<typeof IngestJobSchema>;
12
17
  /**
13
18
  * The INSERT OR IGNORE for one posting. Ignored when its url (UNIQUE) or id
@@ -1 +1 @@
1
- {"version":3,"file":"ingestWrite.d.ts","sourceRoot":"","sources":["../src/ingestWrite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAQpD,KAAK,EAAE,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACpC,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAQxD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,EAAE,EAAE,EAAE,EACN,GAAG,EAAE,SAAS,EACd,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,2DA6DjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB9E"}
1
+ {"version":3,"file":"ingestWrite.d.ts","sourceRoot":"","sources":["../src/ingestWrite.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAQpD,KAAK,EAAE,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,aAAa,WAAW,CAAC;AACtC,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAQxD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,EAAE,EAAE,EAAE,EACN,GAAG,EAAE,SAAS,EACd,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,2DA6DjF;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAyB9E"}
@@ -1 +1 @@
1
- {"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../src/routes/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiB9E,UAAU,YAAY;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE;QAAE,WAAW,EAAE,iBAAiB,CAAA;KAAE,CAAC;CAC9C;AAq9BD,eAAO,MAAM,YAAY,oCAAM,CAAC"}
1
+ {"version":3,"file":"ingest.d.ts","sourceRoot":"","sources":["../../src/routes/ingest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAkB9E,UAAU,YAAY;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE;QAAE,WAAW,EAAE,iBAAiB,CAAA;KAAE,CAAC;CAC9C;AA09BD,eAAO,MAAM,YAAY,oCAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../../../src/routes/jobs/feed.ts"],"names":[],"mappings":"AAYA,OAAO,EASN,KAAK,OAAO,EACZ,MAAM,aAAa,CAAC;AAkLrB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAuqBpD"}
1
+ {"version":3,"file":"feed.d.ts","sourceRoot":"","sources":["../../../src/routes/jobs/feed.ts"],"names":[],"mappings":"AAYA,OAAO,EASN,KAAK,OAAO,EACZ,MAAM,aAAa,CAAC;AAsLrB,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAyuBpD"}
@@ -1,3 +1,9 @@
1
1
  import { type JobsApp } from './shared.js';
2
+ /**
3
+ * Typed notes as the drawer's HTML: escaped, a paragraph per blank-line block,
4
+ * <br> for a single newline. Always wrapped in <p>, so the drawer reads it as
5
+ * HTML rather than collapsing an entity-escaped plain string.
6
+ */
7
+ export declare function manualDescriptionHtml(text: string): string;
2
8
  export declare function registerImportRoute(app: JobsApp): void;
3
9
  //# sourceMappingURL=importUrl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"importUrl.d.ts","sourceRoot":"","sources":["../../../src/routes/jobs/importUrl.ts"],"names":[],"mappings":"AA2BA,OAAO,EAKN,KAAK,OAAO,EACZ,MAAM,aAAa,CAAC;AA2ErB,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAuJtD"}
1
+ {"version":3,"file":"importUrl.d.ts","sourceRoot":"","sources":["../../../src/routes/jobs/importUrl.ts"],"names":[],"mappings":"AAoCA,OAAO,EAKN,KAAK,OAAO,EACZ,MAAM,aAAa,CAAC;AAgErB;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1D;AAgCD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAkMtD"}
@@ -0,0 +1,11 @@
1
+ /** The posting is on a known test board (by its URL, or the board the scraper says it fetched). */
2
+ export declare function isTestBoardPosting(url: string, scraped?: {
3
+ ats?: string | null;
4
+ slug?: string | null;
5
+ }): boolean;
6
+ /** For the migration and tests: the boards as (ats, slug) pairs. */
7
+ export declare const TEST_BOARD_PAIRS: {
8
+ ats: string;
9
+ slug: string;
10
+ }[];
11
+ //# sourceMappingURL=testBoards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testBoards.d.ts","sourceRoot":"","sources":["../src/testBoards.ts"],"names":[],"mappings":"AAkBA,mGAAmG;AACnG,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACrD,OAAO,CAKT;AAED,oEAAoE;AACpE,eAAO,MAAM,gBAAgB;;;GAG3B,CAAC"}
@@ -0,0 +1,23 @@
1
+ -- Drop the postings of known ATS test boards (worker/src/testBoards.ts):
2
+ -- LinkedIn's own Greenhouse and Lever tenants, which hold only LinkedIn's
3
+ -- integration tests ("Bug Bash Job …", "EA Test - Most Questions",
4
+ -- "SJ_TEST_LEVER_ATTACHMENT", 76 rows on 2026-11-09). Ingest and
5
+ -- POST /jobs/import refuse them from now on; this removes what is already
6
+ -- stored.
7
+ --
8
+ -- Only rows nobody has touched: a posting someone tracks, voted on, queued or
9
+ -- logged a timeline row for stays, as the daily cull spares it. job_profile_rank,
10
+ -- job_profile_matches, job_states and job_events cascade on delete; applications
11
+ -- and job_feedback have no foreign key, so they are checked explicitly.
12
+ DELETE FROM jobs
13
+ WHERE (
14
+ (ats = 'greenhouse' AND LOWER(slug) = 'linkedin')
15
+ OR (ats = 'lever' AND LOWER(slug) = 'linkedin')
16
+ OR url LIKE 'https://job-boards.greenhouse.io/linkedin/%'
17
+ OR url LIKE 'https://boards.greenhouse.io/linkedin/%'
18
+ OR url LIKE 'https://jobs.lever.co/linkedin/%'
19
+ )
20
+ AND NOT EXISTS (SELECT 1 FROM job_states s WHERE s.job_id = jobs.id)
21
+ AND NOT EXISTS (SELECT 1 FROM job_feedback f WHERE f.job_id = jobs.id)
22
+ AND NOT EXISTS (SELECT 1 FROM applications a WHERE a.job_id = jobs.id)
23
+ AND NOT EXISTS (SELECT 1 FROM job_events e WHERE e.job_id = jobs.id);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/jobplatform-worker",
3
- "version": "2.32.41",
4
- "gitHead": "c4c6f527fc7f72dbbf7088cf0dc07a6ecbdb1b44",
3
+ "version": "2.32.43",
4
+ "gitHead": "1894003df9c23d34d2488f9104836c8e9384e267",
5
5
  "description": "Job listings aggregation and tracking dashboard - Worker package",
6
6
  "license": "MIT",
7
7
  "type": "module",