Phase 2: core domain, policy engine, packet API, Clerical screen
Migration 0003: projects, aliases, renumbers, units, packets and every child table, change orders, assets, documents, ITPs, station limits, department weld flag. Policy package: Principal, PacketState, Action rules, custody, preconditions, CO hold, order of checks, can/blocked/holder on reads. docs/POLICY.md with the tightenings table for Seth. Write pipeline: FOR UPDATE, CAS on status and dept, If-Match row versions, server-assigned numbers, field CAS, version bump, packet log, audit, NOTIFY, signatures, IT reasons, filed lock and HMAC seal. API: /api/packets (header, transitions, work orders, pages, docs, move, remove, BOM, shorts, welds, heat tags, heat table, stage, checklist, clock, warehouse stage, Q.C., change orders, log, seal), /api/projects, /api/units, /api/assets, /_blob. Frontend: Clerical home, projects and units, packet page with pdf.js and QR codes, hand draft, heat map, send to warehouse, department or Q.C. Tests: policy matrix, API, concurrency, schema, projects; Playwright Clerical draft scenario. Verified on docker-1 with the CI stack and the Samba DC. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// 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;
|
||||
}
|
||||
|
||||
export interface UnitFields {
|
||||
name: string | null;
|
||||
due: string | null;
|
||||
status: Unit["status"];
|
||||
notes: 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),
|
||||
};
|
||||
Reference in New Issue
Block a user