2026-06-18 12:49:47 -04:00
|
|
|
import apiClient from './client';
|
feat(contracts): adopt shared api-contracts in web, add zod schemas and ProblemDetails codes
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.
2026-07-13 17:19:42 -04:00
|
|
|
// Fix: WEB-M5 — types from the shared contracts package.
|
|
|
|
|
import type {
|
|
|
|
|
PricingLibraryItem,
|
|
|
|
|
PricingLibraryListParams,
|
|
|
|
|
CreatePricingLibraryItemRequest,
|
|
|
|
|
UpdatePricingLibraryItemRequest,
|
|
|
|
|
PagedResponse,
|
|
|
|
|
} from '@proposal-system/api-contracts';
|
2026-06-18 12:49:47 -04:00
|
|
|
|
feat(contracts): adopt shared api-contracts in web, add zod schemas and ProblemDetails codes
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.
2026-07-13 17:19:42 -04:00
|
|
|
export type {
|
|
|
|
|
PricingLibraryItem,
|
|
|
|
|
PricingLibraryListParams,
|
|
|
|
|
CreatePricingLibraryItemRequest,
|
|
|
|
|
UpdatePricingLibraryItemRequest,
|
|
|
|
|
} from '@proposal-system/api-contracts';
|
2026-06-18 12:49:47 -04:00
|
|
|
|
feat(contracts): adopt shared api-contracts in web, add zod schemas and ProblemDetails codes
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.
2026-07-13 17:19:42 -04:00
|
|
|
export type PagedPricingLibraryResponse = PagedResponse<PricingLibraryItem>;
|
2026-06-18 12:49:47 -04:00
|
|
|
|
|
|
|
|
export const pricingLibraryApi = {
|
|
|
|
|
/** GET /api/pricing-library/list?page=&pageSize= — paginated list (admin/sysadmin). */
|
|
|
|
|
list: async (params: PricingLibraryListParams = {}): Promise<PagedPricingLibraryResponse> => {
|
|
|
|
|
const qs = new URLSearchParams();
|
|
|
|
|
if (params.page) qs.append('page', String(params.page));
|
|
|
|
|
if (params.pageSize) qs.append('pageSize', String(params.pageSize));
|
|
|
|
|
const res = await apiClient.get(`/pricing-library/list?${qs.toString()}`);
|
|
|
|
|
return res.data;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/** POST /api/pricing-library — create a new pricing library item. */
|
|
|
|
|
create: async (data: CreatePricingLibraryItemRequest): Promise<PricingLibraryItem> => {
|
|
|
|
|
const res = await apiClient.post('/pricing-library', data);
|
|
|
|
|
return res.data;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/** PUT /api/pricing-library/{id} — update an existing pricing library item. */
|
|
|
|
|
update: async (id: string, data: UpdatePricingLibraryItemRequest): Promise<PricingLibraryItem> => {
|
|
|
|
|
const res = await apiClient.put(`/pricing-library/${id}`, data);
|
|
|
|
|
return res.data;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
/** DELETE /api/pricing-library/{id} — delete a pricing library item. */
|
|
|
|
|
remove: async (id: string): Promise<void> => {
|
|
|
|
|
await apiClient.delete(`/pricing-library/${id}`);
|
|
|
|
|
},
|
|
|
|
|
};
|