Files
PacketStation/frontend/src/api/projects.ts
T
spencermandClaude Fable 5.1 591fe90076
ci / frontend (push) Successful in 30s
ci / server (push) Successful in 4m12s
ci / image (push) Successful in 46s
ci / e2e (push) Successful in 1m24s
Phase 3: VISUAL feed and M-Files drawings in the worker
Migration 0004 (VISUAL and drawing caches, go-live ignored list, resource
map, job tables, order-derived columns with provenance; work order key
includes the operation sequence). The real worker on APScheduler with
settings re-read each fire, pause, run now, advisory locks, job_runs and a
heartbeat. The visual-feed job (five VisualKit reads, COPY and MERGE cache,
suspect-batch guard, the apply in one transaction: drafts, change orders,
retire-moved, work order gone, closed and cancelled observed, projects and
units from order links, auto-release) and the fingerprint. The drawing-lookup
job (queue, budget, download on version change, sha256 into assets, decision
table, staging for rev approval, drawing-origin change orders). Clerical From
VISUAL panel, flags, rev approval, hand uploads, change-order review; Admin
Feed settings and resource map. Synthetic fixture generator and a
fixture-driven worker in CI with a Playwright scenario. Docs updated.

Verified: 3249 server tests and 13 Playwright scenarios on the docker-1 CI
stack, 76 frontend tests, doctor at 0004; one feed and one drawing run
against VISUAL DEV and the vault from the developer machine (counts in the
changelog).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-16 14:45:38 -06:00

49 lines
2.4 KiB
TypeScript

// Project and unit endpoints from the phase 2 contract.
import { api } from "./client";
import { asList, qs } from "./query";
import type { FieldCas, Guarded, NumberLookup, Project, ProjectCreate, Unit, UnitsCreate } from "./types";
export type ProjectShow = "active" | "open" | "hold" | "closed" | "all";
export interface ProjectFields {
name: string | null;
customer: string | null;
po: string | null;
due: string | null;
status: Project["status"];
notes: string | null;
order_pin?: string | null;
order_pin_reason?: string | null;
}
export interface UnitFields {
name: string | null;
due: string | null;
status: Unit["status"];
notes: string | null;
order_pin?: string | null;
order_pin_reason?: string | null;
}
const pid = (id: number) => `/api/projects/${encodeURIComponent(String(id))}`;
const uid = (id: number) => `/api/units/${encodeURIComponent(String(id))}`;
export const projectsApi = {
list: async (q: string, status: ProjectShow = "active", signal?: AbortSignal): Promise<Project[]> =>
asList<Project>(await api.get<unknown>(`/api/projects${qs({ q, status })}`, signal), "projects"),
get: (id: number, signal?: AbortSignal) => api.get<Project>(pid(id), signal),
create: (body: ProjectCreate & Guarded) => api.post<Project>("/api/projects", body),
patch: (id: number, body: FieldCas<ProjectFields>) => api.patch<Project>(pid(id), body),
renumber: (id: number, body: { number: string; reason: string } & Guarded) => api.post<Project>(`${pid(id)}/renumber`, body),
remove: (id: number, body: { reason: string } & Guarded) => api.delWithBody<null>(pid(id), body),
addUnits: async (id: number, body: UnitsCreate & Guarded): Promise<Unit[]> =>
asList<Unit>(await api.post<unknown>(`${pid(id)}/units`, body), "units"),
units: async (projectId: number, q = "", signal?: AbortSignal): Promise<Unit[]> =>
asList<Unit>(await api.get<unknown>(`/api/units${qs({ project_id: projectId, q })}`, signal), "units"),
unit: (id: number, signal?: AbortSignal) => api.get<Unit>(uid(id), signal),
patchUnit: (id: number, body: FieldCas<UnitFields>) => api.patch<Unit>(uid(id), body),
renumberUnit: (id: number, body: { lot: string; reason: string } & Guarded) => api.post<Unit>(`${uid(id)}/renumber`, body),
removeUnit: (id: number, body: { reason: string } & Guarded) => api.delWithBody<null>(uid(id), body),
lookup: (n: string, signal?: AbortSignal) => api.get<NumberLookup>(`/api/lookup/number${qs({ n })}`, signal),
};