refactor(ts-migration): type src/api and the first of src/lib for noImplicitAny
Phase 12 step 1, in progress. The flag is not enabled yet — these are the
annotations it will require, landed first so the switch itself is a
one-line commit with a number that is already zero.
`noImplicitAny` projects 3496 errors across 242 files. This clears 179 of
them in 7 files: all of `src/api` (107 -> 0) and `workforce`,
`hiringRecords` in `src/lib`.
The leverage is real and worth recording, because it shapes the rest of
the step. Eight annotations on `aiEngine`'s prompt readers cleared 27
errors: where a value is `any`, every callback beneath it — `.map((c) =>
…)`, `.filter((r) => …)` — has no contextual type and errors on its own.
Typing the source fixes the callbacks for free, so this works bottom-up,
sources first.
Types are taken from what already exists wherever possible. The generated
entity types fit `workforce` and `hiringRecords` without a single
cascade: `JobPosting`, `JobApplication`, `Staff`, `AIInterview`,
`WorkerProfile`, `Assignment`, `Course`. `PreferencesUpdateResult` in
`src/types/user.ts` already described `updatePreferences`'s return.
`buildInsights` takes the other builders' outputs, so its parameters are
`ReturnType<typeof byDepartment>` and friends rather than a restatement
that could drift.
Two things are recorded rather than fixed:
`buildHires` probes four fields that are not `staff` columns —
`timeToHire`, `score`, `company` and `department` are absent from
`information_schema` and from the generated `Staff`. They are read as
fallbacks, so at run time they are always `undefined` and the other
branch always wins. `HireSourceRow` writes them down as optional so the
dead fallbacks are visible; removing the reads would be a behaviour
change. `Hire` likewise widens `profile_tier`, because the builder's
default `'skilled'` is lower-case where the column's check constraint
spells it `'Skilled'`.
`aiEngine`'s talent pool stays `any[]`. It is `JSON.parse` output from a
block embedded in a prompt, carrying computed fields like `match_score`
that no entity declares — typing it `WorkerProfile[]` would assert a
shape nothing validates.
One mistake worth keeping. I replaced an inline lookup with a hoisted
`const URGENCY = {…}`, and per-file esbuild said the output was
unchanged: with `--minify-syntax` it inlines a single-use const straight
back. The production bundle disagreed — `43e7f268` against `74d17e2d`.
Reverted to a type assertion, which erases. Hoisting reads as a tidy-up
and is a real change to the emitted code; the two checks disagreeing is
exactly why both are run.
typecheck 0 under the committed config; 3317 under the probe, from 3496
lint exit 0
npm test 1684/1691, the same 7 failures
build exit 0, bundle back to 74d17e2d…
emitted JS 7/7 identical
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBG1wnuRfJKCstGB8Fekr8
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* and results that actually respond to the data instead of being canned.
|
||||
*/
|
||||
|
||||
const clamp = (n, min = 0, max = 100) => Math.max(min, Math.min(max, Math.round(Number(n) || 0)));
|
||||
const clamp = (n: unknown, min = 0, max = 100) => Math.max(min, Math.min(max, Math.round(Number(n) || 0)));
|
||||
|
||||
/** Simulated model latency so streaming/pending UI behaves as designed. */
|
||||
const think = (ms = 900) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
@@ -21,39 +21,39 @@ const think = (ms = 900) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
/* ── Prompt field readers ──────────────────────────────────────────────── */
|
||||
|
||||
/** Reads a `Label: value` line out of a prompt. */
|
||||
function field(prompt, label) {
|
||||
function field(prompt: string, label: string): string {
|
||||
const match = prompt.match(new RegExp(`^${label}:[ \\t]*(.*)$`, 'mi'));
|
||||
return match ? match[1].trim() : '';
|
||||
}
|
||||
|
||||
function numField(prompt, label) {
|
||||
function numField(prompt: string, label: string): number {
|
||||
const raw = field(prompt, label);
|
||||
const match = raw.match(/-?\d+(\.\d+)?/);
|
||||
return match ? Number(match[0]) : 0;
|
||||
}
|
||||
|
||||
/** Reads a comma-separated line, treating the app's "None" sentinel as empty. */
|
||||
function listField(prompt, label) {
|
||||
function listField(prompt: string, label: string): string[] {
|
||||
const raw = field(prompt, label);
|
||||
if (!raw || /^(none|not specified|not provided)$/i.test(raw)) return [];
|
||||
return raw.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
/** Pulls the first triple-quoted block (transcripts, free-text resumes). */
|
||||
function quotedBlock(prompt) {
|
||||
function quotedBlock(prompt: string): string {
|
||||
const match = prompt.match(/"""\s*([\s\S]*?)\s*"""/);
|
||||
return match ? match[1].trim() : '';
|
||||
}
|
||||
|
||||
const ENGLISH_RANK = { basic: 1, conversational: 2, fluent: 3, native: 4 };
|
||||
const ENGLISH_RANK: Record<string, number> = { basic: 1, conversational: 2, fluent: 3, native: 4 };
|
||||
|
||||
const isSpanish = (prompt) => /Spanish \(español\)/.test(prompt) && !/default to English/.test(prompt);
|
||||
const isSpanish = (prompt: string) => /Spanish \(español\)/.test(prompt) && !/default to English/.test(prompt);
|
||||
|
||||
/* ── 1. Candidate screening ────────────────────────────────────────────── */
|
||||
|
||||
function screenCandidate(prompt) {
|
||||
function screenCandidate(prompt: string) {
|
||||
// Weights are stated inline: "experience 25%, english 20%, …"
|
||||
const weightOf = (name) => {
|
||||
const weightOf = (name: string) => {
|
||||
const match = prompt.match(new RegExp(`${name} (\\d+)%`));
|
||||
return match ? Number(match[1]) : 20;
|
||||
};
|
||||
@@ -184,7 +184,7 @@ function screenCandidate(prompt) {
|
||||
|
||||
/* ── 2. Job description generator ──────────────────────────────────────── */
|
||||
|
||||
const RESPONSIBILITY_LIBRARY = {
|
||||
const RESPONSIBILITY_LIBRARY: Record<string, string[]> = {
|
||||
Bartender: [
|
||||
'Set up and break down a full service bar',
|
||||
'Pour to spec at event pace without sacrificing presentation',
|
||||
@@ -236,7 +236,7 @@ const DEFAULT_RESPONSIBILITIES = [
|
||||
'Complete close-out duties before leaving',
|
||||
];
|
||||
|
||||
function generateJobDescription(prompt) {
|
||||
function generateJobDescription(prompt: string) {
|
||||
const title = field(prompt, 'Role Title');
|
||||
const category = field(prompt, 'Role Category');
|
||||
const minYears = numField(prompt, 'Min Experience');
|
||||
@@ -301,7 +301,7 @@ const CERT_KEYWORDS = [
|
||||
['food handler', 'Food Handler Card'], ['forklift', 'Forklift Operator'], ['osha', 'OSHA 10'],
|
||||
];
|
||||
|
||||
function buildResume(prompt) {
|
||||
function buildResume(prompt: string) {
|
||||
const text = quotedBlock(prompt);
|
||||
const lower = text.toLowerCase();
|
||||
|
||||
@@ -343,14 +343,14 @@ function buildResume(prompt) {
|
||||
|
||||
const INTERVIEW_QUESTIONS = {
|
||||
en: [
|
||||
(role) => `Thanks for joining. To start — what drew you to ${role} work, and how long have you been doing it?`,
|
||||
(role: string) => `Thanks for joining. To start — what drew you to ${role} work, and how long have you been doing it?`,
|
||||
() => `Walk me through your busiest shift. What actually happened, and what did you do about it?`,
|
||||
() => `Something goes wrong mid-service and your lead is unreachable. Talk me through your next three moves.`,
|
||||
() => `Tell me about feedback that changed how you work. What did you do differently afterward?`,
|
||||
() => `Last one — what does your schedule realistically look like, and what do you want to be doing a year from now?`,
|
||||
],
|
||||
es: [
|
||||
(role) => `Gracias por acompañarme. Para empezar — ¿qué te atrajo al trabajo de ${role}, y cuánto tiempo llevas haciéndolo?`,
|
||||
(role: string) => `Gracias por acompañarme. Para empezar — ¿qué te atrajo al trabajo de ${role}, y cuánto tiempo llevas haciéndolo?`,
|
||||
() => `Cuéntame de tu turno más ocupado. ¿Qué pasó realmente, y qué hiciste al respecto?`,
|
||||
() => `Algo sale mal a mitad del servicio y no puedes contactar a tu supervisor. Explícame tus siguientes tres pasos.`,
|
||||
() => `Háblame de algún comentario que cambió tu manera de trabajar. ¿Qué hiciste diferente después?`,
|
||||
@@ -358,7 +358,7 @@ const INTERVIEW_QUESTIONS = {
|
||||
],
|
||||
};
|
||||
|
||||
function interviewQuestion(prompt) {
|
||||
function interviewQuestion(prompt: string) {
|
||||
const lang = isSpanish(prompt) ? 'es' : 'en';
|
||||
const numberMatch = prompt.match(/Ask question (\d+) of 5/);
|
||||
const index = Math.min(4, Math.max(0, (numberMatch ? Number(numberMatch[1]) : 1) - 1));
|
||||
@@ -369,7 +369,7 @@ function interviewQuestion(prompt) {
|
||||
|
||||
const OWLIVER_QUESTIONS = {
|
||||
en: [
|
||||
(name) => `Hey ${name} — good to meet you. Tell me about yourself, in your own words.`,
|
||||
(name: string) => `Hey ${name} — good to meet you. Tell me about yourself, in your own words.`,
|
||||
() => `I like that. Tell me about something you got through that you're genuinely proud of.`,
|
||||
() => `Picture this: you're the only one on shift, 300 guests arrive early, and the kitchen is behind. What do you do?`,
|
||||
() => `What's a piece of feedback that stuck with you — and what changed after it?`,
|
||||
@@ -377,7 +377,7 @@ const OWLIVER_QUESTIONS = {
|
||||
() => `That's everything I needed. Anything you want to add before I put this together?`,
|
||||
],
|
||||
es: [
|
||||
(name) => `Hola ${name} — un gusto conocerte. Cuéntame de ti, con tus propias palabras.`,
|
||||
(name: string) => `Hola ${name} — un gusto conocerte. Cuéntame de ti, con tus propias palabras.`,
|
||||
() => `Me gusta eso. Cuéntame de algo que superaste y de lo que estés realmente orgulloso.`,
|
||||
() => `Imagina: estás solo en el turno, llegan 300 invitados antes de tiempo y la cocina va atrasada. ¿Qué haces?`,
|
||||
() => `¿Qué comentario se te quedó grabado — y qué cambió después?`,
|
||||
@@ -386,7 +386,7 @@ const OWLIVER_QUESTIONS = {
|
||||
],
|
||||
};
|
||||
|
||||
function owliverQuestion(prompt) {
|
||||
function owliverQuestion(prompt: string) {
|
||||
const lang = isSpanish(prompt) ? 'es' : 'en';
|
||||
const numberMatch = prompt.match(/you are on question (\d+)/);
|
||||
const index = Math.min(5, Math.max(0, (numberMatch ? Number(numberMatch[1]) : 1) - 1));
|
||||
@@ -398,7 +398,7 @@ function owliverQuestion(prompt) {
|
||||
/* ── 5. Interview evaluation ───────────────────────────────────────────── */
|
||||
|
||||
/** Scores a transcript on how substantive the candidate's own answers are. */
|
||||
function readTranscript(prompt) {
|
||||
function readTranscript(prompt: string) {
|
||||
const transcript = prompt.split('TRANSCRIPT:')[1] || '';
|
||||
const answers = transcript
|
||||
.split('\n')
|
||||
@@ -412,7 +412,7 @@ function readTranscript(prompt) {
|
||||
return { answers, words, avgWords, specifics };
|
||||
}
|
||||
|
||||
function evaluateInterview(prompt) {
|
||||
function evaluateInterview(prompt: string) {
|
||||
const { answers, avgWords, specifics } = readTranscript(prompt);
|
||||
const fastMatch = prompt.match(/(\d+) candidate response\(s\) were suspiciously fast/);
|
||||
const fast = fastMatch ? Number(fastMatch[1]) : 0;
|
||||
@@ -489,9 +489,14 @@ function evaluateInterview(prompt) {
|
||||
|
||||
/* ── 6. Talent matching ────────────────────────────────────────────────── */
|
||||
|
||||
function matchTalent(prompt) {
|
||||
function matchTalent(prompt: string) {
|
||||
const block = prompt.match(/AVAILABLE TALENT \(JSON\):\s*(\[[\s\S]*?\])\s*\n\nYou are NEVER/);
|
||||
let pool = [];
|
||||
/* Whatever the caller embedded in the prompt's talent-pool block, as
|
||||
`JSON.parse` hands it back. Not `WorkerProfile[]`: this is a simulated
|
||||
engine reading a blob out of free text, and the rows carry computed
|
||||
fields like `match_score` that no entity declares. Typing it as a
|
||||
record would assert a shape nothing validates. */
|
||||
let pool: any[] = [];
|
||||
try {
|
||||
pool = block ? JSON.parse(block[1]) : [];
|
||||
} catch {
|
||||
@@ -513,9 +518,9 @@ function matchTalent(prompt) {
|
||||
? Math.min(20, ((p.experience_years || 0) / minYears) * 20)
|
||||
: Math.min(20, (p.experience_years || 0) * 3);
|
||||
|
||||
const certs = (p.certifications || []).map((c) => c.toLowerCase());
|
||||
const certs = (p.certifications || []).map((c: string) => c.toLowerCase());
|
||||
const certFit = requiredCerts.length
|
||||
? (requiredCerts.filter((r) => certs.some((c) => c.includes(r) || r.includes(c))).length / requiredCerts.length) * 15
|
||||
? (requiredCerts.filter((r) => certs.some((c: string) => c.includes(r) || r.includes(c))).length / requiredCerts.length) * 15
|
||||
: (certs.length ? 12 : 5);
|
||||
|
||||
const scoreFit = ((p.krow_score || 0) / 100) * 20;
|
||||
@@ -577,7 +582,7 @@ const AVAILABILITY_TOKENS: [RegExp, string][] = [
|
||||
[/on.?call|flexible/i, 'On-Call'],
|
||||
];
|
||||
|
||||
function buildCareerDna(prompt) {
|
||||
function buildCareerDna(prompt: string) {
|
||||
const transcript = quotedBlock(prompt);
|
||||
const lower = transcript.toLowerCase();
|
||||
const { answers, avgWords, specifics } = (() => {
|
||||
@@ -701,7 +706,7 @@ function buildCareerDna(prompt) {
|
||||
|
||||
/* ── 8. Proving Ground evaluator ───────────────────────────────────────── */
|
||||
|
||||
function evaluateChallenge(prompt) {
|
||||
function evaluateChallenge(prompt: string) {
|
||||
const criteriaMatch = prompt.match(/rubric" object: (.+?)\.\n/);
|
||||
const criteria = criteriaMatch
|
||||
? criteriaMatch[1].split(',').map((c) => c.trim()).filter(Boolean)
|
||||
@@ -748,7 +753,7 @@ function evaluateChallenge(prompt) {
|
||||
const verdict = base >= 70 ? 'verified' : base >= 50 ? 'needs_work' : 'failed';
|
||||
|
||||
// Spread the overall score across the rubric so criteria are not identical.
|
||||
const rubric = {};
|
||||
const rubric: Record<string, number> = {};
|
||||
criteria.forEach((criterion, i) => {
|
||||
rubric[criterion] = clamp(base + (i % 3 === 0 ? 4 : i % 3 === 1 ? -3 : 1));
|
||||
});
|
||||
|
||||
@@ -39,15 +39,15 @@ const WINDOW_DAYS = 56;
|
||||
* Local rather than UTC because a shift belongs to the day it was worked in the
|
||||
* place it was worked, and `periodRange` windows on local day boundaries too.
|
||||
*/
|
||||
function daysAgo(n, hour = 9, minute = 0, anchor = new Date()) {
|
||||
function daysAgo(n: number, hour = 9, minute = 0, anchor = new Date()) {
|
||||
const d = new Date(anchor.getTime());
|
||||
d.setDate(d.getDate() - n);
|
||||
d.setHours(hour, minute, 0, 0);
|
||||
return d;
|
||||
}
|
||||
|
||||
const round1 = (n) => Math.round(n * 10) / 10;
|
||||
const round2 = (n) => Math.round(n * 100) / 100;
|
||||
const round1 = (n: number) => Math.round(n * 10) / 10;
|
||||
const round2 = (n: number) => Math.round(n * 100) / 100;
|
||||
const HOUR = 60 * 60 * 1000;
|
||||
|
||||
/**
|
||||
@@ -105,10 +105,21 @@ const ROSTER = [
|
||||
* Returning a plain record keeps every rule visible in one place instead of
|
||||
* spread across the generator.
|
||||
*/
|
||||
const BEHAVIOUR = {
|
||||
/**
|
||||
* One worker's shift outcome, as the rules below return it.
|
||||
*
|
||||
* `i` is the index of the shift counting back from the anchor, `weekday` the
|
||||
* day it falls on. Rules that ignore the weekday take one argument, which is
|
||||
* why the second is optional here.
|
||||
*/
|
||||
type ShiftBehaviour = (i: number, weekday?: number) => {
|
||||
status: string; minutesLate: number; overtime: number; notes: string;
|
||||
};
|
||||
|
||||
const BEHAVIOUR: Record<string, ShiftBehaviour> = {
|
||||
/* Reliable. One late arrival every couple of months, and overtime only on
|
||||
the nights events actually overrun. */
|
||||
staff_marco: (i, weekday) => ({
|
||||
staff_marco: (i: number, weekday?: number) => ({
|
||||
status: i === 14 ? 'late' : 'present',
|
||||
minutesLate: i === 14 ? 9 : 0,
|
||||
/* Friday and Saturday events overrun; midweek ones do not. */
|
||||
@@ -124,7 +135,7 @@ const BEHAVIOUR = {
|
||||
* the six weeks before it — a change big enough to be worth surfacing and
|
||||
* specific enough to act on.
|
||||
*/
|
||||
staff_marcus: (i) => {
|
||||
staff_marcus: (i: number) => {
|
||||
if (i === 2 || i === 7) {
|
||||
return { status: 'absent', minutesLate: 0, overtime: 0, notes: 'Called in sick' };
|
||||
}
|
||||
@@ -145,7 +156,7 @@ const BEHAVIOUR = {
|
||||
* covers, on the three busiest shifts of each week. A steady climb rather
|
||||
* than a spike, which is exactly the shape that hides in a table of totals.
|
||||
*/
|
||||
staff_antoine: (i, weekday) => {
|
||||
staff_antoine: (i: number, weekday?: number) => {
|
||||
const weekIndex = Math.floor(i / 5);
|
||||
const busy = weekday === 4 || weekday === 5 || weekday === 6;
|
||||
const overtime = busy ? Math.max(0.5, round1(3.5 - weekIndex * 0.45)) : 0;
|
||||
@@ -154,8 +165,8 @@ const BEHAVIOUR = {
|
||||
};
|
||||
|
||||
/** Every shift date for one worker, most recent first. */
|
||||
function shiftOffsets(weekdays, anchor) {
|
||||
const offsets = [];
|
||||
function shiftOffsets(weekdays: number[], anchor: Date) {
|
||||
const offsets: number[] = [];
|
||||
for (let offset = 0; offset <= WINDOW_DAYS; offset += 1) {
|
||||
const day = daysAgo(offset, 9, 0, anchor).getDay();
|
||||
if (weekdays.includes(day)) offsets.push(offset);
|
||||
@@ -163,16 +174,16 @@ function shiftOffsets(weekdays, anchor) {
|
||||
return offsets;
|
||||
}
|
||||
|
||||
const pad = (n) => String(n).padStart(2, '0');
|
||||
const localDate = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
||||
const pad = (n: number) => String(n).padStart(2, '0');
|
||||
const localDate = (d: Date) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
||||
|
||||
/**
|
||||
* @param {Date} [anchor] the day to count back from. Defaults to now, which is
|
||||
* the point of this collection; a caller passes one only to hold the window
|
||||
* still — see buildShiftsAt.
|
||||
*/
|
||||
function buildShifts(anchor = new Date()) {
|
||||
const records = [];
|
||||
function buildShifts(anchor: Date = new Date()) {
|
||||
const records: any[] = [];
|
||||
|
||||
for (const worker of ROSTER) {
|
||||
const offsets = shiftOffsets(worker.weekdays, anchor);
|
||||
@@ -251,6 +262,6 @@ export const SHIFT_RECORDS = buildShifts();
|
||||
* shifts built around one day and bucketed around another describe two
|
||||
* different windows.
|
||||
*/
|
||||
export function buildShiftsAt(anchor) {
|
||||
export function buildShiftsAt(anchor: Date) {
|
||||
return buildShifts(anchor);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
import { createEntity, request, isUnauthenticated, API_BASE_URL } from './httpClient';
|
||||
import type { PreferencesUpdateResult } from '@/types/user';
|
||||
import { invokeLLM, uploadFile } from './aiEngine';
|
||||
import { DEMO_USER } from './demoUser';
|
||||
|
||||
@@ -154,7 +155,7 @@ let hydration: Promise<any> | null = request('GET', '/me')
|
||||
cacheUser();
|
||||
return user;
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((): null => {
|
||||
authenticated = false;
|
||||
return null;
|
||||
});
|
||||
@@ -255,7 +256,7 @@ const auth = {
|
||||
* question the shape exists to answer is now answered by whether this
|
||||
* function resolved at all.
|
||||
*/
|
||||
async updatePreferences(patch: any) {
|
||||
async updatePreferences(patch: any): Promise<PreferencesUpdateResult> {
|
||||
const preferences = await request('PATCH', '/me/preferences', { body: patch });
|
||||
currentUser = { ...currentUser, preferences };
|
||||
cacheUser();
|
||||
|
||||
@@ -319,19 +319,19 @@ export function createEntity(name: string) {
|
||||
return request('GET', base, { query: { ...query, sort, limit } });
|
||||
},
|
||||
|
||||
async get(id) {
|
||||
async get(id: string) {
|
||||
return request('GET', `${base}/${encodeURIComponent(id)}`);
|
||||
},
|
||||
|
||||
async create(data) {
|
||||
async create(data: any) {
|
||||
return request('POST', base, { body: data });
|
||||
},
|
||||
|
||||
async update(id, data) {
|
||||
async update(id: string, data: any) {
|
||||
return request('PATCH', `${base}/${encodeURIComponent(id)}`, { body: data });
|
||||
},
|
||||
|
||||
async delete(id) {
|
||||
async delete(id: string) {
|
||||
return request('DELETE', `${base}/${encodeURIComponent(id)}`);
|
||||
},
|
||||
|
||||
@@ -343,8 +343,8 @@ export function createEntity(name: string) {
|
||||
* identical — the first rejection stops the run and the records before it
|
||||
* are already written.
|
||||
*/
|
||||
async bulkCreate(records = []) {
|
||||
const created = [];
|
||||
async bulkCreate(records: any[] = []) {
|
||||
const created: any[] = [];
|
||||
for (const record of records) created.push(await this.create(record));
|
||||
return created;
|
||||
},
|
||||
|
||||
138
src/api/seed.ts
138
src/api/seed.ts
@@ -11,7 +11,7 @@
|
||||
import { SHIFT_RECORDS } from './attendanceSeed';
|
||||
import { DEMO_USER } from './demoUser';
|
||||
|
||||
const iso = (date) => new Date(`${date}T09:00:00.000Z`).toISOString();
|
||||
const iso = (date: string) => new Date(`${date}T09:00:00.000Z`).toISOString();
|
||||
|
||||
/* ── Reference data ────────────────────────────────────────────────────── */
|
||||
|
||||
@@ -347,7 +347,7 @@ const JOB_POSTINGS = [
|
||||
|
||||
/* ── Applications ──────────────────────────────────────────────────────── */
|
||||
|
||||
const breakdown = (over) => ({
|
||||
const breakdown = (over?: Record<string, number>) => ({
|
||||
experience: 0, english: 0, reliability: 0, certifications: 0, availability: 0,
|
||||
personality: 0, culture_fit: 0, communication_style: 0, attendance_expectations: 0,
|
||||
physical_requirements: 0, leadership_expectations: 0, job_related_answers: 0,
|
||||
@@ -356,13 +356,13 @@ const breakdown = (over) => ({
|
||||
});
|
||||
|
||||
/** An applicant who has not been screened yet — every AI field stays empty. */
|
||||
const unscreened = (over) => ({
|
||||
const unscreened = (over?: Record<string, any>) => ({
|
||||
status: 'applied',
|
||||
ai_score: 0,
|
||||
certifications: [],
|
||||
availability: [],
|
||||
skills: [],
|
||||
companies_worked: [],
|
||||
certifications: [] as string[],
|
||||
availability: [] as string[],
|
||||
skills: [] as string[],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
created_date: iso('2026-08-04'),
|
||||
updated_date: iso('2026-08-04'),
|
||||
@@ -428,7 +428,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['ServSafe', 'CPR / First Aid'],
|
||||
availability: ['Weekdays', 'Weekends', 'Evenings'],
|
||||
skills: ['Menu design', 'Brigade leadership', 'Food costing', 'Plated dinners', 'Offsite catering'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.9,
|
||||
professional_summary:
|
||||
'Executive chef with 12 years across hotel banquets and high-end offsite catering. Has run brigades of 20+ and holds plate standards at 400 covers.',
|
||||
@@ -480,7 +480,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Guard Card', 'CPR / First Aid'],
|
||||
availability: ['Weekends', 'Evenings', 'Overnight'],
|
||||
skills: ['Crowd management', 'De-escalation', 'Incident reporting', 'Access control'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.8,
|
||||
professional_summary:
|
||||
'Licensed event security officer with five years across concerts and corporate activations. Known for defusing situations before they escalate.',
|
||||
@@ -514,7 +514,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Guard Card'],
|
||||
availability: ['Weekends', 'Evenings'],
|
||||
skills: ['Access control', 'Incident reporting'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
professional_summary: 'Venue security officer transitioning into private event work.',
|
||||
job_posting_id: 'job_security',
|
||||
@@ -562,7 +562,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['RBS Alcohol Server', 'TIPS Certified'],
|
||||
availability: ['Weekdays', 'Evenings'],
|
||||
skills: ['Batch cocktails', 'Craft cocktails', 'Bar setup', 'Inventory control'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.7,
|
||||
professional_summary:
|
||||
'Corporate event bartender with six years on Bay Area tech campuses. Builds batched programs that hold quality at volume.',
|
||||
@@ -605,7 +605,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Food Handler Card'],
|
||||
availability: ['Weekends', 'Evenings'],
|
||||
skills: ['Synchronized service', 'Tray service', 'Wine service', 'Guest relations'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.6,
|
||||
professional_summary:
|
||||
'Fine dining event server with four years of coursed banquet service and wine knowledge.',
|
||||
@@ -639,7 +639,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Food Handler Card'],
|
||||
availability: ['Weekends'],
|
||||
skills: ['Banquet service', 'Tray service', 'Table resets'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.4,
|
||||
professional_summary: 'Banquet server with three years of seated dinner service.',
|
||||
selfie_url: 'https://i.pravatar.cc/240?img=44',
|
||||
@@ -673,7 +673,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: [],
|
||||
availability: ['Weekends', 'Evenings'],
|
||||
skills: ['Table service'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
professional_summary: 'Restaurant server moving into event work.',
|
||||
job_posting_id: 'job_server_fine',
|
||||
@@ -695,7 +695,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['TIPS Certified'],
|
||||
availability: ['Weekends', 'Evenings'],
|
||||
skills: ['Classic cocktails', 'Bar setup', 'Speed pouring'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.2,
|
||||
professional_summary: 'Event bartender with three years of high-volume weekend service.',
|
||||
job_posting_id: 'job_bartender',
|
||||
@@ -728,7 +728,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['TIPS Certified'],
|
||||
availability: ['Evenings'],
|
||||
skills: ['Bar setup', 'Wine service'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 4.0,
|
||||
professional_summary: 'Barback stepping up to bartending at private events.',
|
||||
job_posting_id: 'job_bartender',
|
||||
@@ -761,7 +761,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: [],
|
||||
availability: ['Weekends'],
|
||||
skills: [],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
professional_summary: 'Looking for a first hospitality role.',
|
||||
job_posting_id: 'job_bartender',
|
||||
@@ -795,7 +795,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Forklift Operator'],
|
||||
availability: ['Weekdays', 'Early mornings'],
|
||||
skills: ['Order picking', 'Scanner operation', 'Pallet staging'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 3.9,
|
||||
professional_summary: 'Warehouse picker with forklift certification.',
|
||||
job_posting_id: 'job_picker',
|
||||
@@ -827,7 +827,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: [],
|
||||
availability: ['Weekdays'],
|
||||
skills: ['Order picking'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
professional_summary: 'Fulfillment associate seeking steady warehouse shifts.',
|
||||
job_posting_id: 'job_picker',
|
||||
@@ -854,7 +854,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Food Handler Card'],
|
||||
availability: ['Weekdays', 'Weekends'],
|
||||
skills: ['Banquet leadership', 'BEO reading', 'Floor coordination'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
professional_summary: 'Banquet server with lead-shift experience in hotel events.',
|
||||
job_posting_id: 'job_banquet',
|
||||
@@ -874,7 +874,7 @@ const JOB_APPLICATIONS = [
|
||||
certifications: ['Food Handler Card'],
|
||||
availability: ['Weekdays', 'Weekends', 'Evenings'],
|
||||
skills: ['Floor leadership', 'Client relations', 'Event reporting'],
|
||||
companies_worked: [],
|
||||
companies_worked: [] as string[],
|
||||
client_rating: 0,
|
||||
professional_summary: 'Hotel banquet captain with six years directing event floors.',
|
||||
job_posting_id: 'job_banquet',
|
||||
@@ -900,7 +900,7 @@ const JOB_APPLICATIONS = [
|
||||
|
||||
/* ── AI interviews ─────────────────────────────────────────────────────── */
|
||||
|
||||
const transcript = (candidate, role) => [
|
||||
const transcript = (candidate: string, role: string) => [
|
||||
{ role: 'assistant', content: `Hi ${candidate.split(' ')[0]} — thanks for making time. Tell me about the busiest ${role} shift you've worked and how you handled it.`, timestamp: iso('2026-08-04') },
|
||||
{ role: 'user', content: 'We were short two people on a 300-guest event. I re-sectioned the floor, moved the strongest server to the head tables, and pulled the rest into a runner rotation so nothing sat under the lamps.', timestamp: iso('2026-08-04'), response_time_seconds: 11 },
|
||||
{ role: 'assistant', content: 'What broke first, and what did you do the moment you noticed?', timestamp: iso('2026-08-04') },
|
||||
@@ -919,7 +919,7 @@ const AI_INTERVIEWS = [
|
||||
verdict: 'maybe',
|
||||
hire_recommendation: 'Worth a trial shift on a coursed dinner before committing to the season.',
|
||||
integrity_score: 100,
|
||||
ai_flags: [],
|
||||
ai_flags: [] as string[],
|
||||
category_scores: {
|
||||
communication: 78, confidence: 71, experience_relevance: 74, culture_fit: 76,
|
||||
problem_solving: 69, personality: 77, communication_style: 76,
|
||||
@@ -947,11 +947,11 @@ const AI_INTERVIEWS = [
|
||||
verdict: 'maybe',
|
||||
hire_recommendation: '',
|
||||
integrity_score: 100,
|
||||
ai_flags: [],
|
||||
ai_flags: [] as string[],
|
||||
category_scores: {},
|
||||
strengths: [],
|
||||
concerns: [],
|
||||
best_fit_roles: [],
|
||||
strengths: [] as string[],
|
||||
concerns: [] as string[],
|
||||
best_fit_roles: [] as string[],
|
||||
summary: '',
|
||||
reasoning: '',
|
||||
created_date: iso('2026-08-05'),
|
||||
@@ -967,11 +967,11 @@ const AI_INTERVIEWS = [
|
||||
verdict: 'maybe',
|
||||
hire_recommendation: '',
|
||||
integrity_score: 100,
|
||||
ai_flags: [],
|
||||
ai_flags: [] as string[],
|
||||
category_scores: {},
|
||||
strengths: [],
|
||||
concerns: [],
|
||||
best_fit_roles: [],
|
||||
strengths: [] as string[],
|
||||
concerns: [] as string[],
|
||||
best_fit_roles: [] as string[],
|
||||
summary: '',
|
||||
reasoning: '',
|
||||
created_date: iso('2026-08-05'),
|
||||
@@ -987,11 +987,11 @@ const AI_INTERVIEWS = [
|
||||
verdict: 'maybe',
|
||||
hire_recommendation: '',
|
||||
integrity_score: 100,
|
||||
ai_flags: [],
|
||||
ai_flags: [] as string[],
|
||||
category_scores: {},
|
||||
strengths: [],
|
||||
concerns: [],
|
||||
best_fit_roles: [],
|
||||
strengths: [] as string[],
|
||||
concerns: [] as string[],
|
||||
best_fit_roles: [] as string[],
|
||||
summary: '',
|
||||
reasoning: '',
|
||||
created_date: iso('2026-08-03'),
|
||||
@@ -1015,7 +1015,7 @@ const STAFF = [
|
||||
ai_score: 92,
|
||||
status: 'onboarding',
|
||||
client_rating: 0,
|
||||
endorsed_skills: [],
|
||||
endorsed_skills: [] as string[],
|
||||
created_date: iso('2026-07-25'),
|
||||
},
|
||||
{
|
||||
@@ -1031,7 +1031,7 @@ const STAFF = [
|
||||
ai_score: 94,
|
||||
status: 'onboarding',
|
||||
client_rating: 0,
|
||||
endorsed_skills: [],
|
||||
endorsed_skills: [] as string[],
|
||||
created_date: iso('2026-07-25'),
|
||||
},
|
||||
{
|
||||
@@ -1047,7 +1047,7 @@ const STAFF = [
|
||||
ai_score: 97,
|
||||
status: 'onboarding',
|
||||
client_rating: 0,
|
||||
endorsed_skills: [],
|
||||
endorsed_skills: [] as string[],
|
||||
created_date: iso('2026-07-25'),
|
||||
},
|
||||
];
|
||||
@@ -1085,7 +1085,7 @@ const COURSES = [
|
||||
{ criterion: 'Protects the table experience', weight: 30 },
|
||||
],
|
||||
},
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] },
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] as string[] },
|
||||
quiz: [
|
||||
{
|
||||
question: 'A guest flags an allergy mid-service. What happens first?',
|
||||
@@ -1127,7 +1127,7 @@ const COURSES = [
|
||||
{ criterion: 'Escalates appropriately', weight: 30 },
|
||||
],
|
||||
},
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] },
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] as string[] },
|
||||
quiz: [
|
||||
{
|
||||
question: 'A guest shows clear signs of intoxication. What do you do?',
|
||||
@@ -1151,7 +1151,7 @@ const COURSES = [
|
||||
proof_skill: 'Hazard Identification',
|
||||
skill_id: 'food_safety',
|
||||
target_level: 'beginner',
|
||||
required_level: null,
|
||||
required_level: null as string | null,
|
||||
completion_criteria: ['Work through the training material', 'Submit evidence for the challenge'],
|
||||
verification_criteria: ['Identifies temperature violations', 'Spots cross-contamination risk', 'Notes obstruction hazards'],
|
||||
challenge: {
|
||||
@@ -1164,7 +1164,7 @@ const COURSES = [
|
||||
{ criterion: 'Notes obstruction hazards', weight: 20 },
|
||||
],
|
||||
},
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] },
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] as string[] },
|
||||
quiz: [
|
||||
{
|
||||
question: 'What is the danger zone for cold-held food?',
|
||||
@@ -1201,7 +1201,7 @@ const COURSES = [
|
||||
],
|
||||
},
|
||||
unlock_requirements: { min_shifts: 5, min_reliability: 70, required_badges: ['Service Fundamentals'] },
|
||||
quiz: [],
|
||||
quiz: [] as unknown[],
|
||||
pass_score: 80,
|
||||
status: 'active',
|
||||
created_date: iso('2026-06-16'),
|
||||
@@ -1293,7 +1293,7 @@ const MODULE_TABLE: [string, string, string, number, string, string, string[]][]
|
||||
['food_safety', 'advanced', 'Incident Response & Reporting', 18, 'roleplay', 'A suspected foodborne incident, in the hour it matters.', ['Isolates the product', 'Documents accurately', 'Notifies the right people']],
|
||||
];
|
||||
|
||||
const SKILL_CATEGORY = {
|
||||
const SKILL_CATEGORY: Record<string, string> = {
|
||||
server: 'Service',
|
||||
bartending: 'Bar',
|
||||
leadership: 'Leadership',
|
||||
@@ -1304,20 +1304,20 @@ const SKILL_CATEGORY = {
|
||||
const LEVEL_ORDER = ['beginner', 'intermediate', 'advanced', 'expert'];
|
||||
|
||||
/** Level → the rung below it, which is what a module requires before it opens. */
|
||||
const requiredLevelFor = (level) => LEVEL_ORDER[LEVEL_ORDER.indexOf(level) - 1] || null;
|
||||
const requiredLevelFor = (level: string) => LEVEL_ORDER[LEVEL_ORDER.indexOf(level) - 1] || null;
|
||||
|
||||
/** Difficulty is the existing field; level drives it so the two never disagree. */
|
||||
const DIFFICULTY_FOR = { beginner: 'beginner', intermediate: 'intermediate', advanced: 'advanced', expert: 'advanced' };
|
||||
const DIFFICULTY_FOR: Record<string, string> = { beginner: 'beginner', intermediate: 'intermediate', advanced: 'advanced', expert: 'advanced' };
|
||||
|
||||
const XP_FOR = { beginner: 100, intermediate: 150, advanced: 220, expert: 300 };
|
||||
const XP_FOR: Record<string, number> = { beginner: 100, intermediate: 150, advanced: 220, expert: 300 };
|
||||
|
||||
const PROMPT_FOR = {
|
||||
const PROMPT_FOR: Record<string, (title: string) => string> = {
|
||||
roleplay: (title) => `Work through a ${title.toLowerCase()} scenario with Owliver, start to finish.`,
|
||||
video: (title) => `Record yourself demonstrating ${title.toLowerCase()} as you would on a live shift.`,
|
||||
photo_identify: (title) => `Mark everything a ${title.toLowerCase()} check should catch in this photo.`,
|
||||
};
|
||||
|
||||
const slug = (title) => title.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_|_$/g, '');
|
||||
const slug = (title: string) => title.toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_|_$/g, '');
|
||||
|
||||
const TRAINING_MODULES = MODULE_TABLE.map(
|
||||
([skill_id, target_level, title, minutes, type, description, criteria], i) => ({
|
||||
@@ -1341,8 +1341,8 @@ const TRAINING_MODULES = MODULE_TABLE.map(
|
||||
ai_persona: type === 'roleplay' ? 'A guest or teammate in a live service situation.' : undefined,
|
||||
rubric: (Array.isArray(criteria) ? criteria : []).map((criterion, n) => ({ criterion, weight: n === 0 ? 40 : 30 })),
|
||||
},
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] },
|
||||
quiz: [],
|
||||
unlock_requirements: { min_shifts: 0, min_reliability: 0, required_badges: [] as string[] },
|
||||
quiz: [] as unknown[],
|
||||
pass_score: 70,
|
||||
status: 'active',
|
||||
created_date: iso('2026-06-20'),
|
||||
@@ -1354,7 +1354,7 @@ const TRAINING_MODULES = MODULE_TABLE.map(
|
||||
const COURSE_LIBRARY = [...COURSES, ...TRAINING_MODULES];
|
||||
|
||||
/** A module id from its skill and title, so profiles read like the ladder does. */
|
||||
const mod = (skill, title) => `mod_${skill}_${slug(title)}`;
|
||||
const mod = (skill: string, title: string) => `mod_${skill}_${slug(title)}`;
|
||||
|
||||
/**
|
||||
* Completed training on a worker profile.
|
||||
@@ -1362,7 +1362,7 @@ const mod = (skill, title) => `mod_${skill}_${slug(title)}`;
|
||||
* Titles are looked up rather than repeated, so a renamed module cannot leave a
|
||||
* profile claiming a course that no longer goes by that name.
|
||||
*/
|
||||
const completions = (ids, date, score = 88) =>
|
||||
const completions = (ids: string[], date: string, score = 88) =>
|
||||
ids.map((id) => ({
|
||||
course_id: id,
|
||||
title: COURSE_LIBRARY.find((c) => c.id === id)?.title || id,
|
||||
@@ -1535,7 +1535,7 @@ const WORKER_PROFILES = [
|
||||
earned_badges: [
|
||||
{ name: 'Service Fundamentals', level: 'bronze', course_id: 'course_service_basics', earned_date: iso('2026-07-28') },
|
||||
],
|
||||
capabilities: [],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 6,
|
||||
attendance_score: 92,
|
||||
performance_score: 0,
|
||||
@@ -1605,8 +1605,8 @@ const WORKER_PROFILES = [
|
||||
'2026-08-02',
|
||||
89
|
||||
),
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 38,
|
||||
attendance_score: 96,
|
||||
performance_score: 88,
|
||||
@@ -1653,8 +1653,8 @@ const WORKER_PROFILES = [
|
||||
'2026-07-30',
|
||||
85
|
||||
),
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 21,
|
||||
attendance_score: 93,
|
||||
performance_score: 81,
|
||||
@@ -1701,8 +1701,8 @@ const WORKER_PROFILES = [
|
||||
'2026-08-05',
|
||||
76
|
||||
),
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 4,
|
||||
attendance_score: 100,
|
||||
performance_score: 0,
|
||||
@@ -1745,8 +1745,8 @@ const WORKER_PROFILES = [
|
||||
},
|
||||
xp: 0,
|
||||
completed_courses: [],
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 0,
|
||||
attendance_score: 100,
|
||||
performance_score: 0,
|
||||
@@ -1789,8 +1789,8 @@ const WORKER_PROFILES = [
|
||||
},
|
||||
xp: 0,
|
||||
completed_courses: [],
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 0,
|
||||
attendance_score: 100,
|
||||
performance_score: 0,
|
||||
@@ -1833,8 +1833,8 @@ const WORKER_PROFILES = [
|
||||
},
|
||||
xp: 0,
|
||||
completed_courses: [],
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 0,
|
||||
attendance_score: 100,
|
||||
performance_score: 0,
|
||||
@@ -1877,8 +1877,8 @@ const WORKER_PROFILES = [
|
||||
},
|
||||
xp: 0,
|
||||
completed_courses: [],
|
||||
earned_badges: [],
|
||||
capabilities: [],
|
||||
earned_badges: [] as unknown[],
|
||||
capabilities: [] as unknown[],
|
||||
shifts_completed: 0,
|
||||
attendance_score: 100,
|
||||
performance_score: 0,
|
||||
@@ -2024,7 +2024,7 @@ const ASSIGNMENTS = [
|
||||
worker_email: 'marco.rivera@email.com',
|
||||
worker_name: 'Marco Rivera',
|
||||
starts_at: iso('2026-07-01'),
|
||||
ends_at: null,
|
||||
ends_at: null as string | null,
|
||||
status: 'active',
|
||||
source: 'seed',
|
||||
match_score: 92,
|
||||
|
||||
Reference in New Issue
Block a user