@autobe/agent
Version:
AI backend server code generator
137 lines • 5.66 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformInterfaceHistories = void 0;
const uuid_1 = require("uuid");
const transformInterfaceHistories = (state, systemMessage) => {
var _a, _b;
if (state.analyze === null)
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: [
"Requirement analysis is not yet completed.",
"Don't call the any tool function,",
"but say to process the requirement analysis.",
].join(" "),
},
];
else if (state.prisma === null)
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: [
"Prisma DB schema generation is not yet completed.",
"Don't call the any tool function,",
"but say to process the Prisma DB schema generation.",
].join(" "),
},
];
else if (state.analyze.step !== state.prisma.step)
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: [
"Prisma DB schema generation has not been updated",
"for the latest requirement analysis.",
"Don't call the any tool function,",
"but say to re-process the Prisma DB schema generation.",
].join(" "),
},
];
else if (state.prisma.compiled.type !== "success")
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: [
"Prisma DB schema generation has not been updated",
"for the latest requirement analysis.",
"Don't call the any tool function,",
"but say to re-process the Prisma DB schema generation.",
].join(" "),
},
];
return [
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "systemMessage",
text: systemMessage,
},
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "assistantMessage",
text: [
"Requirement analysis and Prisma DB schema generation are ready.",
"",
"Call the provided tool function to generate the OpenAPI document",
"referencing below requirement analysis and Prisma DB schema.",
"",
// User Request
`## User Request`,
"",
state.analyze.reason,
"",
"## Prefix",
"",
`* Prefix provided by the user: ${(_b = (_a = state.analyze) === null || _a === void 0 ? void 0 : _a.prefix) !== null && _b !== void 0 ? _b : null}`,
`* When defining TypeScript interfaces, the interface name must be in PascalCase. The property names, however, do not need to follow this convention.`,
"",
"The user wants all TypeScript identifiers (such as interfaces, types, and functions) to start with the prefix provided below. ",
"If the prefix is `null`, it should be ignored. ",
"If a prefix is provided, all identifier names **must begin with it**.",
"",
"However, if there is a special-purpose prefix like `mv` (e.g., for materialized view handlers or performance-related utilities), it **must precede** the given prefix.",
"",
"## Prefix Example",
"",
"If the prefix is `shopping`, then names should be like:",
"",
"* `shoppingSales`",
"* `shoppingSaleOptions`",
"* `shoppingCreateSale()`",
"",
"In cases where an identifier is created for performance-optimized logic or special processing (e.g., materialized view handling), the `mv` prefix must come first. ",
"For example:",
"",
"* `mvShoppingDailyStats`",
"* `mvShoppingAggregateView`",
"",
// Requirement Analysis Report
`## Requirement Analysis Report`,
"",
"```json",
JSON.stringify(state.analyze.files),
"```",
].join("\n"),
},
{
id: (0, uuid_1.v4)(),
created_at: new Date().toISOString(),
type: "assistantMessage",
text: [
"Database schema and entity relationship diagrams are ready.",
"",
"## Prisma DB Schema",
"```json",
JSON.stringify(state.prisma.schemas),
"```",
"",
"## Entity Relationship Diagrams",
"```json",
JSON.stringify(state.prisma.compiled.diagrams),
"```",
].join("\n"),
},
];
};
exports.transformInterfaceHistories = transformInterfaceHistories;
//# sourceMappingURL=transformInterfaceHistories.js.map