@autobe/agent
Version:
AI backend server code generator
47 lines (43 loc) • 1.8 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformInterfaceOperationParameterHistory = void 0;
const utils_1 = require("@autobe/utils");
const transformInterfaceOperationParameterHistory = (props) => {
const operations = props.operations.filter((op) => { var _a; return ((_a = op.requestBody) === null || _a === void 0 ? void 0 : _a.typeName) === props.typeName; });
if (operations.length === 0)
return "";
const actors = new Set(operations.map((op) => op.authorizationActor).filter((s) => s !== null));
return [writeActor(Array.from(actors)), writeOperations(operations)]
.filter((s) => s !== null)
.join("\n\n");
};
exports.transformInterfaceOperationParameterHistory = transformInterfaceOperationParameterHistory;
function writeActor(actors) {
if (actors.length === 0)
return null;
return utils_1.StringUtil.trim `
### Authorization Actors
These following actors and their sessions are coming from
the JWT authorization token, so you don't need to define them
in the request body schema.
${actors.map((a) => `- ${a}`).join("\n")}
`;
}
function writeOperations(operations) {
operations = operations.filter((op) => op.parameters.length !== 0);
if (operations.length === 0)
return null;
return utils_1.StringUtil.trim `
### Path Parameters
These following path parameters are defined for the operations,
so you don't need to define them in the request body schema.
${operations
.map((op) => [
`- ${op.method.toUpperCase()} ${op.path}`,
...op.parameters.map((p) => ` - \`${p.name}\``),
])
.flat()
.join("\n")}
`;
}
//# sourceMappingURL=transformInterfaceOperationParameterHistory.js.map