@autobe/agent
Version:
AI backend server code generator
37 lines • 1.97 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAutoBeRealizeGenerated = void 0;
const getAutoBeRealizeGenerated = (props) => __awaiter(void 0, void 0, void 0, function* () {
return (Object.assign(Object.assign(Object.assign({}, Object.fromEntries(props.functions.map((f) => [
f.location,
f.template
? f.content + "\n\n" + embedTemplateComment(f.template)
: f.content,
]))), Object.fromEntries(props.authorizations
.map((auth) => [
[auth.decorator.location, auth.decorator.content],
[auth.provider.location, auth.provider.content],
[auth.payload.location, auth.payload.content],
])
.flat())), (yield props.compiler.realize.controller({
document: props.document,
functions: props.functions,
authorizations: props.authorizations,
}))));
});
exports.getAutoBeRealizeGenerated = getAutoBeRealizeGenerated;
function embedTemplateComment(template) {
const lines = template.split("\n").map((line) => `// ${line}`);
return [DIVIDER, "// TEMPLATE CODE", DIVIDER, ...lines, DIVIDER].join("\n");
}
const DIVIDER = "//--------------------------------------------------------------";
//# sourceMappingURL=getAutoBeRealizeGenerated.js.map