mirror of
https://github.com/Sea-Haven-Industries/proposal-system.git
synced 2026-10-07 12:48:57 +00:00
Closes WEB-M5 (web hand-duplicated wire types, standing drift risk): - shared/api-contracts: rewritten as the authoritative superset of the .NET DTOs (ProposalListItem/ProposalDetail with poNumber and submittedByName, line item requests, customers, pricing library, dashboard, audit, sites, auth, presigned upload, ApiProblem); stale Proposal/UpdateLineItemsRequest shapes removed - shared/api-contracts/src/schemas.ts: zod runtime schemas coupled to every wire type via `satisfies z.ZodType<T>` (schema/type drift is now a compile error); separate entrypoint so type-only consumers (mobile) never pull zod - web: imports @proposal-system/api-contracts (file: dep + tsconfig paths + vite preserveSymlinks); all 7 lib/api modules re-export shared types so page imports stay stable; enum unions tightened (PricingLibraryPage form state now ServiceCategory-typed) - fix(web): customer create/update sent a singular `address` field the API silently dropped (contract is addresses: string[], CustomerDtos.cs) - addresses now round-trip, extra addresses preserved on edit - api: ProblemDetails responses carry a machine-readable top-level `code` (SHOC error-code vocabulary): ValidationFailed, InvalidStateTransition, NotFound, Unauthorized, InternalError; new BusinessRuleException(code, message) maps to 422 with its code; GlobalExceptionHandlerTests cover the full mapping (wire contract) Cross-checked .NET DTOs vs TS types vs zod schemas with the orchestrator scanner (Gemini): core domains consistent; internal-only DTOs (FileDtos vendor/lambda surface, SimilarProposalDtos, UserDtos admin surface) intentionally uncovered. Verify: dotnet 166/166, web tsc + vitest 26/26 + build, mobile tsc, shared tsc all green.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import apiClient from './client';
|
|
// Fix: WEB-M5 — types from the shared contracts package.
|
|
import type { LineItem, CreateLineItemRequest, UpdateLineItemEntry } from '@proposal-system/api-contracts';
|
|
|
|
export type {
|
|
PricingMode,
|
|
LineItemSource,
|
|
LineItem,
|
|
CreateLineItemRequest,
|
|
UpdateLineItemEntry,
|
|
} from '@proposal-system/api-contracts';
|
|
|
|
export const lineItemsApi = {
|
|
getAll: async (proposalId: string): Promise<LineItem[]> => {
|
|
const res = await apiClient.get(`/proposals/${proposalId}/line-items`);
|
|
return res.data;
|
|
},
|
|
|
|
create: async (proposalId: string, data: CreateLineItemRequest): Promise<LineItem> => {
|
|
const res = await apiClient.post(`/proposals/${proposalId}/line-items`, data);
|
|
return res.data;
|
|
},
|
|
|
|
bulkUpdate: async (proposalId: string, lineItems: UpdateLineItemEntry[]): Promise<LineItem[]> => {
|
|
const res = await apiClient.put(`/proposals/${proposalId}/line-items`, { lineItems });
|
|
return res.data;
|
|
},
|
|
|
|
delete: async (proposalId: string, itemId: string): Promise<void> => {
|
|
await apiClient.delete(`/proposals/${proposalId}/line-items/${itemId}`);
|
|
},
|
|
};
|