Files
clean-architecture-frontend…/src/contracts/api-operations.js
T

28 lines
773 B
JavaScript

/**
* @typedef {{
* method: string,
* path: string,
* operationId: string,
* auth: "none" | "external-session",
* timeoutMs: number | null,
* idempotency: "safe" | "keyed" | "none",
* retry: "runtime" | "never",
* requestSource: "search" | "body" | "none",
* requestSchema: string,
* responseSchema: string,
* owner: string
* }} ApiOperation
*/
export const API_OPERATIONS = Object.freeze({});
/** @param {string} operationId */
export function getApiOperation(operationId, operations = API_OPERATIONS) {
const registry = /** @type {Record<string, ApiOperation>} */ (operations);
const selected = registry[operationId];
if (!selected) {
throw new Error(`Unregistered API operation: ${operationId}`);
}
return selected;
}