@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
29 lines (28 loc) • 1.16 kB
JavaScript
import { JsonMethodStore } from "../domain/JsonMethodStore.js";
import { JsonOperationPathsMap } from "../domain/JsonOperationPathsMap.js";
import { getInheritedStores } from "./getInheritedStores.js";
import { getJsonEntityStore } from "./getJsonEntityStore.js";
/**
* @ignore
*/
export function getOperationsStores(target) {
const store = target.isStore ? target : getJsonEntityStore(target);
if (!store.$operations) {
const operationPaths = new JsonOperationPathsMap();
store.$operations = new Map();
getInheritedStores(store).forEach((currentStore) => {
currentStore.children.forEach((propStore) => {
if (propStore instanceof JsonMethodStore && !store.$operations.has(propStore.propertyKey)) {
store.$operations.set(propStore.propertyKey, propStore);
}
});
});
store.$operations.forEach((store) => {
store.operation.operationPaths.forEach((operationPath) => {
operationPaths.setOperationPath(operationPath);
});
});
operationPaths.clear();
}
return store.$operations;
}