import type { HttpMethod, InstalledContractContribution, InstalledHttpContract, ResponseEnvelope, RetrySemantics, } from "./external-contract-runtime.ts"; /** * FE-REG-API. The governed row of one installed HTTP operation, projected * from its V3 descriptor (`InstalledHttpContract`). A feature writes the * operation once, in its contract contribution; `check:registries` compares * these rows with the approved baseline. */ export type ApiOperationRow = Readonly<{ operationId: string; featureId: string; method: HttpMethod; path: string; authProfileId: string; retrySemantics: RetrySemantics; requestBody: InstalledHttpContract["contract"]["requestBody"]; responseBody: InstalledHttpContract["contract"]["responseBody"]; responseEnvelope: ResponseEnvelope; requestSchema: string; responseSchema: string; problemSchema: string; }>; /** * Pass composed contributions (`composeContractContributions`): composition * already refused duplicate operation ids and snapshotted every row. */ export function projectApiOperationRows( contributions: readonly InstalledContractContribution[], ): Readonly> { const rows: Record = {}; for (const contribution of contributions) { for (const { contract, frontend } of contribution.http) { rows[contract.operationId] = Object.freeze({ operationId: contract.operationId, featureId: contribution.featureId, method: contract.method, path: contract.pathTemplate, authProfileId: frontend.authProfileId, retrySemantics: contract.retrySemantics, requestBody: contract.requestBody, responseBody: contract.responseBody, responseEnvelope: contract.responseEnvelope ?? "NONE", requestSchema: contract.inputValidator.schemaId, responseSchema: contract.outputValidator.schemaId, problemSchema: contract.problemValidator.schemaId, }); } } return Object.freeze(rows); }