@autobe/agent
Version:
AI backend server code generator
643 lines • 73.3 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.orchestrateRealizeTransformerCorrectOverall = void 0;
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport"));
const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize"));
const utils_1 = require("@autobe/utils");
const typia_1 = __importDefault(require("typia"));
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const orchestrateRealizeCorrectOverall_1 = require("./correct/orchestrateRealizeCorrectOverall");
const transformRealizeTransformerCorrectHistory_1 = require("./histories/transformRealizeTransformerCorrectHistory");
const AutoBeRealizeTransformerProgrammer_1 = require("./programmers/AutoBeRealizeTransformerProgrammer");
const orchestrateRealizeTransformerCorrectOverall = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () {
const prismaApplication = ctx.state().database.result.data;
const document = ctx.state().interface.document;
const getNeighbors = (func) => {
const visited = new Set();
utils_1.AutoBeOpenApiTypeChecker.visit({
components: document.components,
schema: { $ref: `#/components/schemas/${func.plan.dtoTypeName}` },
closure: (next) => {
if (utils_1.AutoBeOpenApiTypeChecker.isReference(next)) {
const key = next.$ref.split("/").pop();
visited.add(key);
}
},
});
return props.functions.filter((y) => y.plan.dtoTypeName !== func.plan.dtoTypeName &&
visited.has(y.plan.dtoTypeName));
};
return yield (0, orchestrateRealizeCorrectOverall_1.orchestrateRealizeCorrectOverall)(ctx, {
programmer: {
location: "src/transformers",
// Recalculate template for corrected transformer function
template: (func) => {
const model = prismaApplication.files
.map((f) => f.models)
.flat()
.find((m) => m.name === func.plan.databaseSchemaName);
return AutoBeRealizeTransformerProgrammer_1.AutoBeRealizeTransformerProgrammer.writeTemplate({
plan: func.plan,
schema: document.components.schemas[func.plan.dtoTypeName],
schemas: document.components.schemas,
neighbors: getNeighbors(func).map((n) => n.plan),
relations: AutoBeRealizeTransformerProgrammer_1.AutoBeRealizeTransformerProgrammer.getRelationMappingTable({
application: prismaApplication,
model,
}),
model,
});
},
// Replace import statements using Transformer-specific programmer
replaceImportStatements: (next) => __awaiter(void 0, void 0, void 0, function* () {
return yield AutoBeRealizeTransformerProgrammer_1.AutoBeRealizeTransformerProgrammer.replaceImportStatements(ctx, {
dtoTypeName: next.function.plan.dtoTypeName,
schemas: document.components.schemas,
code: next.code,
});
}),
// No additional files needed for transformers (unlike operations)
additional: (_functions) => ({}),
// Create preliminary controller with only databaseSchemas support
preliminary: (next) => new AutoBePreliminaryController_1.AutoBePreliminaryController({
source: next.source,
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeRealizeTransformerCorrectApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Think before you act.\n\nFor preliminary requests: what critical information is missing?\n\nFor write: what errors you're fixing and the correction strategy."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBeRealizeTransformerCorrectApplication.IWrite"
}
],
discriminator: {
propertyName: "type",
mapping: {
getDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas",
write: "#/components/schemas/IAutoBeRealizeTransformerCorrectApplication.IWrite"
}
},
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls."
}
},
required: [
"thinking",
"request"
]
},
IAutoBePreliminaryGetDatabaseSchemas: {
type: "object",
properties: {
type: {
"const": "getDatabaseSchemas",
description: "Type discriminator."
},
schemaNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "Database table names to retrieve. DO NOT request same names already\nrequested in previous calls."
}
},
required: [
"type",
"schemaNames"
],
description: "Request to retrieve database schema definitions for context."
},
"IAutoBeRealizeTransformerCorrectApplication.IWrite": {
type: "object",
properties: {
type: {
"const": "write",
description: "Type discriminator for write submission."
},
think: {
type: "string",
description: "Systematic error analysis. MUST contain four sections:\n\n1. Error Inventory \u2014 categorize ALL compilation errors by root cause\n2. Root Cause Analysis \u2014 identify WHY each error occurs (wrong field, wrong\n transform, etc.)\n3. Schema Verification \u2014 cross-check error-related fields against actual\n database schema\n4. Correction Strategy \u2014 specific fix for each error in BOTH select() and\n transform()\n\nThis forces you to understand the REAL problem (not guess) and plan\nsurgical fixes that address root causes, not symptoms."
},
selectMappings: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeRealizeTransformerSelectMapping"
},
description: "Selection mapping verification for select(). For each database field\nneeded by transform(), document:\n\n- `member`: Exact Prisma field/relation name (snake_case) \u2014 verify against\n the Relation Mapping Table and member list\n- `kind`: scalar, belongsTo, hasOne, or hasMany\n- `nullable`: true/false for scalar/belongsTo, null for hasMany/hasOne\n- `how`: Current state + correction plan (\"No change needed\", \"Fix: wrong\n field name\", etc.)\n\n**Common selection errors to identify**:\n\n- Wrong field name (typo or doesn't exist in schema)\n- Missing required field (transform() uses it but select() doesn't)\n- Wrong syntax (true for relation, or nested select for scalar)\n\nMissing even a single required field will cause validation failure."
},
transformMappings: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeRealizeTransformerTransformMapping"
},
description: "Transform mapping verification. MUST include EVERY DTO property.\n\n- `property`: Exact DTO property name (camelCase)\n- `how`: Current state + correction plan (\"No change needed\", \"Fix:\n [problem] \u2192 [solution]\")\n\nEven correct properties must be included with \"No change needed\" to\nensure complete review.\n\nMissing even a single property will cause validation failure."
},
draft: {
type: "string",
description: "Complete corrected code. EVERY error from think Section 1 MUST be\naddressed. Implement:\n\n- Field name corrections in select() (exact database field names)\n- Type casts in transform() (Decimal\u2192Number, DateTime\u2192ISO)\n- Neighbor transformer reuse (replace inline logic if transformer exists)\n\nApply fixes surgically \u2014 change ONLY what's broken, preserve working\nlogic."
},
revise: {
$ref: "#/components/schemas/IAutoBeRealizeTransformerCorrectApplication.IReviseProps",
description: "Reviews draft corrections and produces final error-free code."
}
},
required: [
"type",
"think",
"selectMappings",
"transformMappings",
"draft",
"revise"
],
description: "Correct transformer compilation errors via think/draft/revise."
},
AutoBeRealizeTransformerSelectMapping: {
type: "object",
properties: {
member: {
type: "string",
description: "Exact Prisma field or relation name from the Prisma schema.\n\nMUST match the Prisma schema exactly (case-sensitive, snake_case).\n\n**Field Types**:\n\n- **Scalar fields**: Database columns (id, email, created_at, unit_price)\n- **BelongsTo relations**: FK relations (customer, article, category)\n- **HasMany relations**: 1:N arrays (tags, comments, reviews)\n- **Aggregations**: Prisma computed fields (_count, _sum, _avg)\n\n**Examples**:\n\n```typescript\n// Scalar fields\n{ member: \"id\", kind: \"scalar\", nullable: false, how: \"For DTO.id\" }\n{ member: \"created_at\", kind: \"scalar\", nullable: false, how: \"For DTO.createdAt (needs .toISOString())\" }\n{ member: \"unit_price\", kind: \"scalar\", nullable: false, how: \"For DTO.price (Decimal \u2192 Number)\" }\n{ member: \"deleted_at\", kind: \"scalar\", nullable: true, how: \"For DTO.deletedAt (nullable DateTime)\" }\n\n// BelongsTo relations \u2014 member is ALWAYS the Prisma relation name,\n// which may differ from the DTO property name\n{ member: \"customer\", kind: \"belongsTo\", nullable: false, how: \"For DTO.buyer (nested transformer)\" }\n{ member: \"user\", kind: \"belongsTo\", nullable: true, how: \"For DTO.voter (optional nested)\" }\n\n// HasMany relations\n{ member: \"tags\", kind: \"hasMany\", nullable: null, how: \"For DTO.tags (array transformer)\" }\n```\n\nDO NOT use DTO property names \u2014 this is about Prisma schema members. Read\nthe Relation Mapping Table and member list to find correct names."
},
kind: {
oneOf: [
{
"const": "scalar"
},
{
"const": "belongsTo"
},
{
"const": "hasOne"
},
{
"const": "hasMany"
}
],
description: "Kind of Prisma schema member.\n\n- `\"scalar\"`: Regular column \u2192 `{ field: true }`\n- `\"belongsTo\"`: FK relation \u2192 `{ relation: { select: ... } }`\n- `\"hasOne\"`: 1:1 relation \u2192 nested select\n- `\"hasMany\"`: 1:N relation \u2192 `{ relation: { select: ... } }`\n\nThe kind forces explicit classification of each member BEFORE deciding\nselect syntax, preventing confusion between scalars and relations."
},
nullable: {
oneOf: [
{
type: "null"
},
{
type: "boolean"
}
],
description: "Whether nullable in Prisma schema.\n\n- `false`: Always present \u2014 transform() can safely access\n- `true`: May be null \u2014 transform() must handle null case\n- `null`: Not applicable (hasMany/hasOne)"
},
how: {
type: "string",
description: "Brief reason for selecting this field (NOT code).\n\nWrite phase: \"For DTO.id\", \"For DTO.createdAt (needs .toISOString())\", \"For\nDTO.customer (nested transformer)\".\n\nCorrect phase: \"No change needed\", \"Fix: Missing field \u2014 add for\nDTO.totalPrice\".\n\nEven if correct, you MUST include it in the mapping. This ensures complete\ncoverage and alignment with transform()."
}
},
required: [
"member",
"kind",
"nullable",
"how"
],
description: "Prisma field selection mapping for the select() function.\n\nDocuments which Prisma fields/relations must be selected to enable\ntransform() to build the DTO. EVERY required field must be listed \u2014 the\nvalidator rejects incomplete selections."
},
AutoBeRealizeTransformerTransformMapping: {
type: "object",
properties: {
property: {
type: "string",
description: "Exact DTO property name (case-sensitive, camelCase).\n\nInclude ALL properties: direct mappings, type conversions, computed values,\nand nested transformations.\n\n**Examples**:\n\n```typescript\n// Direct scalar mappings\n{ property: \"id\", how: \"From prisma.id\" }\n{ property: \"createdAt\", how: \"From prisma.created_at.toISOString()\" }\n\n// Type conversions\n{ property: \"price\", how: \"From prisma.unit_price (Decimal \u2192 Number)\" }\n{ property: \"deletedAt\", how: \"From prisma.deleted_at?.toISOString() ?? null\" }\n\n// Computed properties\n{ property: \"totalPrice\", how: \"Compute: prisma.unit_price * prisma.quantity\" }\n{ property: \"reviewCount\", how: \"From prisma._count.reviews\" }\n\n// Nested transformations (reuse neighbor transformers)\n{ property: \"customer\", how: \"Transform with CustomerTransformer\" }\n{ property: \"tags\", how: \"Array map with TagTransformer\" }\n```"
},
how: {
type: "string",
description: "Brief strategy for obtaining this property's value (NOT code).\n\nWrite phase: \"From prisma.email\", \"From prisma.created_at.toISOString()\",\n\"From prisma.deleted_at?.toISOString() ?? null\", \"From prisma.unit_price\n(Decimal \u2192 Number)\", \"Transform with CustomerTransformer\", \"Array map with\nTagTransformer\", \"Compute: prisma.unit_price * prisma.quantity\".\n\nCorrect phase: \"No change needed\", \"Fix: Missing Decimal conversion\", \"Fix:\nShould use TagTransformer instead of inline\".\n\nEven if correct, you MUST include it. This ensures complete DTO coverage."
}
},
required: [
"property",
"how"
],
description: "DTO property transformation mapping for the transform() function.\n\nDocuments how to transform Prisma payload data into each DTO property. EVERY\nDTO property must be listed \u2014 the validator rejects incomplete mappings."
},
"IAutoBeRealizeTransformerCorrectApplication.IReviseProps": {
type: "object",
properties: {
review: {
type: "string",
description: "MUST systematically verify four checklists:\n\n1. Error Resolution \u2014 confirm EVERY error from think Section 1 is fixed\n2. Root Cause Fix \u2014 verify fixes address root causes (not workarounds/hacks)\n3. System Rules \u2014 neighbor reuse, select (not include), proper types\n4. No Regression \u2014 confirm no NEW errors, Payload type matches select()\n\nCatch Band-Aid fixes (any casts, type assertions) that hide real\nproblems."
},
final: {
oneOf: [
{
type: "null"
},
{
type: "string"
}
],
description: "Final error-free code with all corrections applied, or null if draft\nneeds no changes."
}
},
required: [
"review",
"final"
]
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
description: " Preliminary data request or write submission",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeRealizeTransformerCorrectApplication.IProps"
}
}
],
description: "Process transformer correction task or preliminary data requests."
}
]
},
kinds: ["databaseSchemas"],
dispatch: (e) => ctx.dispatch(e),
state: ctx.state(),
local: {
databaseSchemas: ctx
.state()
.database.result.data.files.map((f) => f.models)
.flat()
.filter((m) => m.name === next.function.plan.databaseSchemaName),
},
}),
// Transform history using Transformer-specific transformer
histories: (next) => (0, transformRealizeTransformerCorrectHistory_1.transformRealizeTransformerCorrectHistory)(ctx, {
function: next.function,
neighbors: getNeighbors(next.function),
failures: next.failures,
preliminary: next.preliminary,
}),
// Create controller with Transformer-specific validation
controller: (next) => {
const validate = (input) => {
const result = (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "write" === input.type && "string" === typeof input.think && (Array.isArray(input.selectMappings) && input.selectMappings.every(elem => "object" === typeof elem && null !== elem && _io3(elem))) && (Array.isArray(input.transformMappings) && input.transformMappings.every(elem => "object" === typeof elem && null !== elem && _io4(elem))) && "string" === typeof input.draft && ("object" === typeof input.revise && null !== input.revise && _io5(input.revise)); const _io3 = input => "string" === typeof input.member && ("scalar" === input.kind || "belongsTo" === input.kind || "hasOne" === input.kind || "hasMany" === input.kind) && (null === input.nullable || "boolean" === typeof input.nullable) && "string" === typeof input.how; const _io4 = input => "string" === typeof input.property && "string" === typeof input.how; const _io5 = input => "string" === typeof input.review && (null === input.final || "string" === typeof input.final); const _iu0 = input => (() => {
if ("getDatabaseSchemas" === input.type)
return _io1(input);
else if ("write" === input.type)
return _io2(input);
else
return false;
})(); const _vo0 = (input, _path, _exceptionable = true) => ["string" === typeof input.thinking || _report(_exceptionable, {
path: _path + ".thinking",
expected: "string",
value: input.thinking
}), ("object" === typeof input.request && null !== input.request || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeTransformerCorrectApplication.IWrite)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeTransformerCorrectApplication.IWrite)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["getDatabaseSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getDatabaseSchemas\"",
value: input.type
}), (Array.isArray(input.schemaNames) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})) && ((1 <= input.schemaNames.length || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "Array<> & MinItems<1>",
value: input.schemaNames
})) && input.schemaNames.map((elem, _index4) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index4 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})].every(flag => flag); const _vo2 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"write\"",
value: input.type
}), "string" === typeof input.think || _report(_exceptionable, {
path: _path + ".think",
expected: "string",
value: input.think
}), (Array.isArray(input.selectMappings) || _report(_exceptionable, {
path: _path + ".selectMappings",
expected: "Array<AutoBeRealizeTransformerSelectMapping>",
value: input.selectMappings
})) && input.selectMappings.map((elem, _index5) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".selectMappings[" + _index5 + "]",
expected: "AutoBeRealizeTransformerSelectMapping",
value: elem
})) && _vo3(elem, _path + ".selectMappings[" + _index5 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".selectMappings[" + _index5 + "]",
expected: "AutoBeRealizeTransformerSelectMapping",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".selectMappings",
expected: "Array<AutoBeRealizeTransformerSelectMapping>",
value: input.selectMappings
}), (Array.isArray(input.transformMappings) || _report(_exceptionable, {
path: _path + ".transformMappings",
expected: "Array<AutoBeRealizeTransformerTransformMapping>",
value: input.transformMappings
})) && input.transformMappings.map((elem, _index6) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".transformMappings[" + _index6 + "]",
expected: "AutoBeRealizeTransformerTransformMapping",
value: elem
})) && _vo4(elem, _path + ".transformMappings[" + _index6 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".transformMappings[" + _index6 + "]",
expected: "AutoBeRealizeTransformerTransformMapping",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".transformMappings",
expected: "Array<AutoBeRealizeTransformerTransformMapping>",
value: input.transformMappings
}), "string" === typeof input.draft || _report(_exceptionable, {
path: _path + ".draft",
expected: "string",
value: input.draft
}), ("object" === typeof input.revise && null !== input.revise || _report(_exceptionable, {
path: _path + ".revise",
expected: "IAutoBeRealizeTransformerCorrectApplication.IReviseProps",
value: input.revise
})) && _vo5(input.revise, _path + ".revise", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".revise",
expected: "IAutoBeRealizeTransformerCorrectApplication.IReviseProps",
value: input.revise
})].every(flag => flag); const _vo3 = (input, _path, _exceptionable = true) => ["string" === typeof input.member || _report(_exceptionable, {
path: _path + ".member",
expected: "string",
value: input.member
}), "scalar" === input.kind || "belongsTo" === input.kind || "hasOne" === input.kind || "hasMany" === input.kind || _report(_exceptionable, {
path: _path + ".kind",
expected: "(\"belongsTo\" | \"hasMany\" | \"hasOne\" | \"scalar\")",
value: input.kind
}), null === input.nullable || "boolean" === typeof input.nullable || _report(_exceptionable, {
path: _path + ".nullable",
expected: "(boolean | null)",
value: input.nullable
}), "string" === typeof input.how || _report(_exceptionable, {
path: _path + ".how",
expected: "string",
value: input.how
})].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["string" === typeof input.property || _report(_exceptionable, {
path: _path + ".property",
expected: "string",
value: input.property
}), "string" === typeof input.how || _report(_exceptionable, {
path: _path + ".how",
expected: "string",
value: input.how
})].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => ["string" === typeof input.review || _report(_exceptionable, {
path: _path + ".review",
expected: "string",
value: input.review
}), null === input.final || "string" === typeof input.final || _report(_exceptionable, {
path: _path + ".final",
expected: "(null | string)",
value: input.final
})].every(flag => flag); const _vu0 = (input, _path, _exceptionable = true) => (() => {
if ("getDatabaseSchemas" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("write" === input.type)
return _vo2(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeTransformerCorrectApplication.IWrite)",
value: input
});
})(); const __is = input => "object" === typeof input && null !== input && _io0(input); let errors; let _report; return input => {
if (false === __is(input)) {
errors = [];
_report = __typia_transform__validateReport._validateReport(errors);
((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeTransformerCorrectApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeTransformerCorrectApplication.IProps",
value: input
}))(input, "$input", true);
const success = 0 === errors.length;
return success ? {
success,
data: input
} : {
success,
errors,
data: input
};
}
return {
success: true,
data: input
};
}; })()(input);
if (result.success === false)
return result;
else if (result.data.request.type !== "write")
return next.preliminary.validate({
thinking: result.data.thinking,
request: result.data.request,
});
// Validate transformer-specific constraints
const errors = AutoBeRealizeTransformerProgrammer_1.AutoBeRealizeTransformerProgrammer.validate({
application: prismaApplication,
document,
plan: next.function.plan,
neighbors: props.functions.map((f) => f.plan),
transformMappings: result.data.request.transformMappings,
selectMappings: result.data.request.selectMappings,
draft: result.data.request.draft,
revise: result.data.request.revise,
});
return errors.length
? {
success: false,
errors,
data: result.data,
}
: result;
};
const application = next.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({
functions: [
{
name: "process",
parameters: {
description: "Current Type: {@link IAutoBeRealizeTransformerCorrectApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Think before you act.\n\nFor preliminary requests: what critical information is missing?\n\nFor write: what errors you're fixing and the correction strategy.",
type: "string"
},
request: {
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBeRealizeTransformerCorrectApplication.IWrite"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
getDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas",
write: "#/$defs/IAutoBeRealizeTransformerCorrectApplication.IWrite"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
IAutoBePreliminaryGetDatabaseSchemas: {
description: "Request to retrieve database schema definitions for context.",
type: "object",
properties: {
type: {
description: "Type discriminator.",
type: "string",
"enum": [
"getDatabaseSchemas"
]
},
schemaNames: {
description: "Database table names to retrieve. DO NOT request same names already\nrequested in previous calls.",
type: "array",
items: {
type: "string"
},
minItems: 1
}
},
required: [
"type",
"schemaNames"
]
},
"IAutoBeRealizeTransformerCorrectApplication.IWrite": {
description: "Correct transformer compilation errors via think/draft/revise.",
type: "object",
properties: {
type: {
description: "Type discriminator for write submission.",
type: "string",
"enum": [
"write"
]
},
think: {
description: "Systematic error analysis. MUST contain four sections:\n\n1. Error Inventory \u2014 categorize ALL compilation errors by root cause\n2. Root Cause Analysis \u2014 identify WHY each error occurs (wrong field, wrong\n transform, etc.)\n3. Schema Verification \u2014 cross-check error-related fields against actual\n database schema\n4. Correction Strategy \u2014 specific fix for each error in BOTH select() and\n transform()\n\nThis forces you to understand the REAL problem (not guess) and plan\nsurgical fixes that address root causes, not symptoms.",
type: "string"
},
selectMappings: {
description: "Selection mapping verification for select(). For each database field\nneeded by transform(), document:\n\n- `member`: Exact Prisma field/relation name (snake_case) \u2014 verify against\n the Relation Mapping Table and member list\n- `kind`: scalar, belongsTo, hasOne, or hasMany\n- `nullable`: true/false for scalar/belongsTo, null for hasMany/hasOne\n- `how`: Current state + correction plan (\"No change needed\", \"Fix: wrong\n field name\", etc.)\n\n**Common selection errors to identify**:\n\n- Wrong field name (typo or doesn't exist in schema)\n- Missing required field (transform() uses it but select() doesn't)\n- Wrong syntax (true for relation, or nested select for scalar)\n\nMissing even a single required field will cause validation failure.",
type: "array",
items: {
$ref: "#/$defs/AutoBeRealizeTransformerSelectMapping"
}
},
transformMappings: {
description: "Transform mapping verification. MUST include EVERY DTO property.\n\n- `property`: Exact DTO property name (camelCase)\n- `how`: Current state + correction plan (\"No change needed\", \"Fix:\n [problem] \u2192 [solution]\")\n\nEven correct properties must be included with \"No change needed\" to\nensure complete review.\n\nMissing even a single property will cause validation failure.",
type: "array",
items: {
$ref: "#/$defs/AutoBeRealizeTransformerTransformMapping"
}
},
draft: {
description: "Complete corrected code. EVERY error from think Section 1 MUST be\naddressed. Implement:\n\n- Field name corrections in select() (exact database field names)\n- Type casts in transform() (Decimal\u2192Number, DateTime\u2192ISO)\n- Neighbor transformer reuse (replace inline logic if transformer exists)\n\nApply fixes surgically \u2014 change ONLY what's broken, preserve working\nlogic.",
type: "string"
},
revise: {
description: "Reviews draft corrections and produces final error-free code.",
$ref: "#/$defs/IAutoBeRealizeTransformerCorrectApplication.IReviseProps"
}
},
required: [
"type",
"think",
"selectMappings",
"transformMappings",
"draft",
"revise"
]
},
AutoBeRealizeTransformerSelectMapping: {
description: "Prisma field selection mapping for the select() function.\n\nDocuments which Prisma fields/relations must be selected to enable\ntransform() to build the DTO. EVERY required field must be listed \u2014 the\nvalidator rejects incomplete selections.",
type: "object",
properties: {
member: {
description: "Exact Prisma field or relation name from the Prisma schema.\n\nMUST match the Prisma schema exactly (case-sensitive, snake_case).\n\n**Field Types**:\n\n- **Scalar fields**: Database columns (id, email, created_at, unit_price)\n- **BelongsTo relations**: FK relations (customer, article, category)\n- **HasMany relations**: 1:N arrays (tags, comments, reviews)\n- **Aggregations**: Prisma computed fields (_count, _sum, _avg)\n\n**Examples**:\n\n```typescript\n// Scalar fields\n{ member: \"id\", kind: \"scalar\", nullable: false, how: \"For DTO.id\" }\n{ member: \"created_at\", kind: \"scalar\", nullable: false, how: \"For DTO.createdAt (needs .toISOString())\" }\n{ member: \"unit_price\", kind: \"scalar\", nullable: false, how: \"For DTO.price (Decimal \u2192 Number)\" }\n{ member: \"deleted_at\", kind: \"scalar\", nullable: true, how: \"For DTO.deletedAt (nullable DateTime)\" }\n\n// BelongsTo relations \u2014 member is ALWAYS the Prisma relation name,\n// which may differ from the DTO property name\n{ member: \"customer\", kind: \"belongsTo\", nullable: false, how: \"For DTO.buyer (n