/** * @typedef {{ * method: string, * path: string, * operationId: string, * auth: "none" | "external-session", * timeoutMs: number, * idempotency: "safe" | "keyed" | "none", * requestSchema: string, * responseSchema: string, * owner: string * }} ApiOperation */ /** @param {ApiOperation} definition */ const operation = (definition) => Object.freeze(definition); export const API_OPERATIONS = Object.freeze({ LIST_SAMPLE_RESOURCES: operation({ method: "GET", path: "/api/sample/resources", operationId: "LIST_SAMPLE_RESOURCES", auth: "external-session", timeoutMs: 10_000, idempotency: "safe", requestSchema: "SampleResourceListQuery", responseSchema: "SampleResourceListPayload", owner: "feature-sample-feature-slice-contract-fixture", }), CREATE_SAMPLE_RESOURCE: operation({ method: "POST", path: "/api/sample/resources", operationId: "CREATE_SAMPLE_RESOURCE", auth: "external-session", timeoutMs: 10_000, idempotency: "keyed", requestSchema: "CreateSampleResourceCommand", responseSchema: "SampleResourcePayload", owner: "feature-sample-feature-slice-contract-fixture", }), }); /** @param {string} operationId */ export function getApiOperation(operationId) { const registry = /** @type {Record} */ (API_OPERATIONS); const selected = registry[operationId]; if (!selected) { throw new Error(`Unregistered API operation: ${operationId}`); } return selected; }