Lint-enforce two architecture rules that were only documented (ADR-0001), landing the rules with the fixes so the build stays green: - contracts/ imports nothing: dashboard-view.dto.ts is now pure wire shapes (inline string-union enums, no domain imports). The DashboardView FE-view type moves to the adapter, which maps wire → domain (compiler-enforced seam). - ApiClient lives only in infrastructure: change-request-form (UI) no longer injects ApiClient — a new ChangeRequestAdapter owns the client and the submit becomes a createSubmitChangeRequest() command factory (createDraftSync shape). draft-sync's wire-DTO import becomes type-only (allowed via allowTypeImports). - Role type moves to shared/domain/role.ts; the ?role= reader stays in shared/infrastructure/role.ts. - eslint: contracts import-ban + @typescript-eslint/no-restricted-imports on api-client (value-only; type imports permitted; infra + shared/upload exempt). Also fixes a PRE-EXISTING bug found while verifying the flow: change-request-form never imported FormsModule, so (ngSubmit) didn't bind and the submit button did a native form submit (page reload) instead of submitting. Verified end-to-end in the running app: submit → command → adapter → backend → reference, success alert shown. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
24 lines
833 B
TypeScript
24 lines
833 B
TypeScript
import { Injectable, inject } from '@angular/core';
|
|
import { ApiClient } from '@shared/infrastructure/api-client';
|
|
import { Valid } from '@registratie/domain/change-request.machine';
|
|
|
|
/**
|
|
* Infrastructure adapter for the adreswijziging POST (`/api/v1/change-requests`) —
|
|
* the single place the network client lives for change requests, so the command
|
|
* and the UI never touch `ApiClient`. Returns the server reference; the server
|
|
* re-validates and is the authority.
|
|
*/
|
|
@Injectable({ providedIn: 'root' })
|
|
export class ChangeRequestAdapter {
|
|
private client = inject(ApiClient);
|
|
|
|
async changeRequest(data: Valid): Promise<string> {
|
|
const res = await this.client.changeRequests({
|
|
straat: data.straat,
|
|
postcode: data.postcode,
|
|
woonplaats: data.woonplaats,
|
|
});
|
|
return res.referentie ?? '';
|
|
}
|
|
}
|