@autobe/agent
Version:
AI backend server code generator
666 lines • 110 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.orchestrateRealizeAuthorizationCorrect = orchestrateRealizeAuthorizationCorrect;
const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport.js"));
const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize.js"));
const typia_1 = __importDefault(require("typia"));
const uuid_1 = require("uuid");
const assertSchemaModel_1 = require("../../context/assertSchemaModel");
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const transformRealizeAuthorizationCorrectHistory_1 = require("./histories/transformRealizeAuthorizationCorrectHistory");
const AuthorizationFileSystem_1 = require("./utils/AuthorizationFileSystem");
const AutoBeRealizeAuthorizationReplaceImport_1 = require("./utils/AutoBeRealizeAuthorizationReplaceImport");
function orchestrateRealizeAuthorizationCorrect(ctx_1, props_1) {
return __awaiter(this, arguments, void 0, function* (ctx, props, life = ctx.retry) {
var _a, _b;
const compiler = yield ctx.compiler();
const providerContent = yield compiler.typescript.beautify(AutoBeRealizeAuthorizationReplaceImport_1.AutoBeRealizeAuthorizationReplaceImport.replaceProviderImport(props.authorization.actor.name, props.authorization.provider.content));
const decoratorContent = yield compiler.typescript.beautify(AutoBeRealizeAuthorizationReplaceImport_1.AutoBeRealizeAuthorizationReplaceImport.replaceDecoratorImport(props.authorization.actor.name, props.authorization.decorator.content));
// Check Compile
const files = Object.assign(Object.assign(Object.assign({}, props.template), props.prismaClient), { [AuthorizationFileSystem_1.AuthorizationFileSystem.decoratorPath(props.authorization.decorator.name)]: decoratorContent, [AuthorizationFileSystem_1.AuthorizationFileSystem.providerPath(props.authorization.provider.name)]: providerContent, [AuthorizationFileSystem_1.AuthorizationFileSystem.payloadPath(props.authorization.payload.name)]: props.authorization.payload.content });
const compiled = yield compiler.typescript.compile({
files,
});
ctx.dispatch({
type: "realizeAuthorizationValidate",
id: (0, uuid_1.v7)(),
created_at: new Date().toISOString(),
authorization: props.authorization,
result: compiled,
step: (_b = (_a = ctx.state().test) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0,
});
if (compiled.type === "success") {
return props.authorization;
}
else if (compiled.type === "exception" || life < 0) {
return props.authorization;
}
const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({
source: SOURCE,
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeRealizeAuthorizationCorrectApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on your\ncurrent state and explain your reasoning:\n\nFor preliminary requests (getAnalysisFiles, getPrismaSchemas, etc.):\n- What critical information is missing that you don't already have?\n- Why do you need it specifically right now?\n- Be brief - state the gap, don't list everything you have.\n\nFor completion (complete):\n- What key assets did you acquire?\n- What did you accomplish?\n- Why is it sufficient to complete?\n- Summarize - don't enumerate every single item.\n\nThis reflection helps you avoid duplicate requests and premature completion."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPrismaSchemas"
},
{
$ref: "#/components/schemas/IAutoBeRealizeAuthorizationCorrectApplication.IComplete"
}
],
discriminator: {
propertyName: "type",
mapping: {
getPrismaSchemas: "#/components/schemas/IAutoBePreliminaryGetPrismaSchemas",
complete: "#/components/schemas/IAutoBeRealizeAuthorizationCorrectApplication.IComplete"
}
},
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval\n(getPrismaSchemas) or final error correction (complete). When preliminary\nreturns empty array, that type is removed from the union, physically\npreventing repeated calls."
}
},
required: [
"thinking",
"request"
]
},
IAutoBePreliminaryGetPrismaSchemas: {
type: "object",
properties: {
type: {
"const": "getPrismaSchemas",
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"getPrismaSchemas\" indicates this is a preliminary\ndata request for Prisma schemas."
},
schemaNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "List of Prisma table names to retrieve.\n\nTable names from the Prisma schema file representing database entities\n(e.g., \"user\", \"post\", \"comment\").\n\nCRITICAL: DO NOT request the same schema names that you have already\nrequested in previous calls."
}
},
required: [
"type",
"schemaNames"
],
description: "Request to retrieve Prisma database schema definitions for context.\n\nThis type is used in the preliminary phase to request specific Prisma table\nschemas needed for generating type-safe API operations."
},
"IAutoBeRealizeAuthorizationCorrectApplication.IComplete": {
type: "object",
properties: {
type: {
"const": "complete",
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"complete\" indicates this is the final task\nexecution request."
},
error_analysis: {
type: "string",
description: "Step 1: TypeScript compilation error analysis and diagnosis.\n\nAI identifies and categorizes all compilation errors (type mismatches,\nimport issues, syntax errors) by component (providers/decorator/payload).\nLists specific error messages with their locations and types for\nsystematic troubleshooting."
},
solution_guidance: {
type: "string",
description: "Step 2: Solution guidance and fix recommendations.\n\nAI provides clear, actionable instructions on how to resolve each\nidentified error. Includes specific steps like \"add property X to\ninterface Y\", \"update import path from A to B\", or \"change type from C to\nD\". Focus on guidance rather than generating complete code\nimplementations."
},
provider: {
$ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IProvider",
description: "Authentication Provider function configuration containing the function\nname and implementation code. The Provider handles JWT token\nverification, role validation, and database queries to authenticate\nusers."
},
decorator: {
$ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IDecorator",
description: "Authentication Decorator configuration containing the decorator name and\nimplementation code. The Decorator integrates with NestJS parameter\ndecorators to automatically inject authenticated user data into\nController methods."
},
payload: {
$ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IPayloadType",
description: "Authentication Payload Type configuration containing the payload type\nname and implementation code. The Payload Type is used to define the\nstructure of the authenticated user data that will be injected into\nController methods when using the decorator. It serves as the TypeScript\ntype for the parameter in Controller method signatures."
}
},
required: [
"type",
"error_analysis",
"solution_guidance",
"provider",
"decorator",
"payload"
],
description: "Request to fix authentication component errors.\n\nExecutes targeted error correction to resolve TypeScript compilation issues\nin provider, decorator, and payload type. Applies systematic fixes while\npreserving all authentication logic and business requirements."
},
"IAutoBeRealizeAuthorizationWriteApplication.IProvider": {
type: "object",
properties: {
name: {
type: "string",
pattern: "^[a-z][a-zA-Z0-9]*$",
description: "The name of the authentication Provider function in {role}Authorize\nformat (e.g., adminAuthorize, userAuthorize). This function will be\ncalled by the decorator to verify JWT tokens and return authenticated\nuser information for the specified role.\n\nDO: Use camelCase naming convention."
},
content: {
type: "string",
description: "Complete TypeScript code for the authentication Provider function. Must\ninclude: JWT token verification using jwtAuthorize function, role type\nchecking against payload.type, database query using\nMyGlobal.prisma.{tableName} pattern to verify user existence, and proper\nerror handling with ForbiddenException and UnauthorizedException. The\nfunction should return the authenticated user payload data."
}
},
required: [
"name",
"content"
]
},
"IAutoBeRealizeAuthorizationWriteApplication.IDecorator": {
type: "object",
properties: {
name: {
type: "string",
pattern: "^[A-Z][a-zA-Z0-9]*$",
description: "The name of the Decorator to be generated in {Actor}Auth format (e.g.,\nAdminAuth, UserAuth). This decorator will be used as a parameter\ndecorator in Controller methods to automatically authenticate and\nauthorize users for the specific role, injecting the authenticated user\npayload as a method parameter.\n\nDO: Use PascalCase naming convention."
},
content: {
type: "string",
description: "Complete TypeScript code for the authentication Decorator implementation.\nMust include: SwaggerCustomizer integration to add bearer token security\nschema to API documentation, createParamDecorator implementation that\ncalls the corresponding Provider function for authentication, Singleton\npattern using tstl library for efficient decorator instance management,\nand proper TypeScript typing for the ParameterDecorator interface."
}
},
required: [
"name",
"content"
]
},
"IAutoBeRealizeAuthorizationWriteApplication.IPayloadType": {
type: "object",
properties: {
name: {
type: "string",
pattern: "^[A-Z][a-zA-Z0-9]*$",
description: "The name of the Payload type to be generated in {Actor}Payload format\n(e.g., AdminPayload, UserPayload). This type defines the structure of the\nauthenticated user data that will be injected into Controller methods\nwhen using the decorator.\n\nDO: Use PascalCase naming convention."
},
content: {
type: "string",
description: "Complete TypeScript code for the Payload type interface in {Actor}Payload\nformat (e.g., AdminPayload, UserPayload). Must include: id field with\nUUID format validation, type field as role discriminator, and proper\ntypia tags for validation. This interface defines the structure of the\nauthenticated user data that will be injected into Controller methods\nwhen using the decorator and serves as the TypeScript type for the\nparameter in Controller method signatures."
}
},
required: [
"name",
"content"
]
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "next",
description: " Request containing either preliminary data request or complete\ntask",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeRealizeAuthorizationCorrectApplication.IProps"
}
}
],
description: "Process authentication component correction task or preliminary data\nrequests.\n\nFixes TypeScript compilation errors in authentication components through\nsystematic error diagnosis. Provides error analysis, solution guidance, and\ncorrected versions while preserving authentication logic."
}
]
},
kinds: ["prismaSchemas"],
state: ctx.state(),
});
return yield preliminary.orchestrate(ctx, (out) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
const pointer = {
value: null,
};
const result = yield ctx.conversate(Object.assign({ source: "realizeAuthorizationCorrect", controller: createController({
model: ctx.model,
build: (next) => {
pointer.value = next;
},
preliminary,
}), enforceFunctionCall: true }, (0, transformRealizeAuthorizationCorrectHistory_1.transformRealizeAuthorizationCorrectHistory)({
authorization: props.authorization,
template: props.template,
diagnostics: compiled.diagnostics,
preliminary,
})));
if (pointer.value === null)
return out(result)(null);
const correct = Object.assign(Object.assign({}, pointer.value), { decorator: Object.assign(Object.assign({}, pointer.value.decorator), { location: AuthorizationFileSystem_1.AuthorizationFileSystem.decoratorPath(pointer.value.decorator.name) }), provider: Object.assign(Object.assign({}, pointer.value.provider), { location: AuthorizationFileSystem_1.AuthorizationFileSystem.providerPath(pointer.value.provider.name) }), payload: {
name: pointer.value.payload.name,
location: AuthorizationFileSystem_1.AuthorizationFileSystem.payloadPath(pointer.value.payload.name),
content: yield compiler.typescript.beautify(pointer.value.payload.content),
}, actor: props.authorization.actor });
ctx.dispatch(Object.assign(Object.assign({}, pointer.value), { type: "realizeAuthorizationCorrect", id: (0, uuid_1.v7)(), created_at: new Date().toISOString(), authorization: correct, result: compiled, metric: result.metric, tokenUsage: result.tokenUsage, step: (_b = (_a = ctx.state().test) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0 }));
return out(result)(yield orchestrateRealizeAuthorizationCorrect(ctx, {
authorization: correct,
prismaClient: props.prismaClient,
template: props.template,
}, life - 1));
}));
});
}
function createController(props) {
(0, assertSchemaModel_1.assertSchemaModel)(props.model);
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 => "getPrismaSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "complete" === input.type && "string" === typeof input.error_analysis && "string" === typeof input.solution_guidance && ("object" === typeof input.provider && null !== input.provider && _io3(input.provider)) && ("object" === typeof input.decorator && null !== input.decorator && _io4(input.decorator)) && ("object" === typeof input.payload && null !== input.payload && _io5(input.payload)); const _io3 = input => "string" === typeof input.name && RegExp("^[a-z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _io4 = input => "string" === typeof input.name && RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _io5 = input => "string" === typeof input.name && RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _iu0 = input => (() => {
if ("getPrismaSchemas" === input.type)
return _io1(input);
else if ("complete" === 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: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeAuthorizationCorrectApplication.IComplete)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeAuthorizationCorrectApplication.IComplete)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["getPrismaSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPrismaSchemas\"",
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, _index2) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index2 + "]",
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) => ["complete" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"complete\"",
value: input.type
}), "string" === typeof input.error_analysis || _report(_exceptionable, {
path: _path + ".error_analysis",
expected: "string",
value: input.error_analysis
}), "string" === typeof input.solution_guidance || _report(_exceptionable, {
path: _path + ".solution_guidance",
expected: "string",
value: input.solution_guidance
}), ("object" === typeof input.provider && null !== input.provider || _report(_exceptionable, {
path: _path + ".provider",
expected: "IAutoBeRealizeAuthorizationWriteApplication.IProvider",
value: input.provider
})) && _vo3(input.provider, _path + ".provider", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".provider",
expected: "IAutoBeRealizeAuthorizationWriteApplication.IProvider",
value: input.provider
}), ("object" === typeof input.decorator && null !== input.decorator || _report(_exceptionable, {
path: _path + ".decorator",
expected: "IAutoBeRealizeAuthorizationWriteApplication.IDecorator",
value: input.decorator
})) && _vo4(input.decorator, _path + ".decorator", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".decorator",
expected: "IAutoBeRealizeAuthorizationWriteApplication.IDecorator",
value: input.decorator
}), ("object" === typeof input.payload && null !== input.payload || _report(_exceptionable, {
path: _path + ".payload",
expected: "IAutoBeRealizeAuthorizationWriteApplication.IPayloadType",
value: input.payload
})) && _vo5(input.payload, _path + ".payload", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".payload",
expected: "IAutoBeRealizeAuthorizationWriteApplication.IPayloadType",
value: input.payload
})].every(flag => flag); const _vo3 = (input, _path, _exceptionable = true) => ["string" === typeof input.name && (RegExp("^[a-z][a-zA-Z0-9]*$").test(input.name) || _report(_exceptionable, {
path: _path + ".name",
expected: "string & CamelCasePattern",
value: input.name
})) || _report(_exceptionable, {
path: _path + ".name",
expected: "(string & CamelCasePattern)",
value: input.name
}), "string" === typeof input.content || _report(_exceptionable, {
path: _path + ".content",
expected: "string",
value: input.content
})].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["string" === typeof input.name && (RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) || _report(_exceptionable, {
path: _path + ".name",
expected: "string & PascalCasePattern",
value: input.name
})) || _report(_exceptionable, {
path: _path + ".name",
expected: "(string & PascalCasePattern)",
value: input.name
}), "string" === typeof input.content || _report(_exceptionable, {
path: _path + ".content",
expected: "string",
value: input.content
})].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => ["string" === typeof input.name && (RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) || _report(_exceptionable, {
path: _path + ".name",
expected: "string & PascalCasePattern",
value: input.name
})) || _report(_exceptionable, {
path: _path + ".name",
expected: "(string & PascalCasePattern)",
value: input.name
}), "string" === typeof input.content || _report(_exceptionable, {
path: _path + ".content",
expected: "string",
value: input.content
})].every(flag => flag); const _vu0 = (input, _path, _exceptionable = true) => (() => {
if ("getPrismaSchemas" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("complete" === input.type)
return _vo2(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeAuthorizationCorrectApplication.IComplete)",
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: "IAutoBeRealizeAuthorizationCorrectApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeRealizeAuthorizationCorrectApplication.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 || result.data.request.type === "complete")
return result;
return props.preliminary.validate({
thinking: result.data.thinking,
request: result.data.request,
});
};
const application = collection[props.model === "chatgpt"
? "chatgpt"
: props.model === "gemini"
? "gemini"
: "claude"](validate);
return {
protocol: "class",
name: SOURCE,
application,
execute: {
process: (next) => {
if (next.request.type === "complete")
props.build(next.request);
},
},
};
}
const collection = {
chatgpt: (validate) => (() => {
const application = {
model: "chatgpt",
options: {
reference: true,
strict: false,
separate: null
},
functions: [
{
name: "process",
parameters: {
description: " Request containing either preliminary data request or complete\ntask\n\n------------------------------\n\nCurrent Type: {@link IAutoBeRealizeAuthorizationCorrectApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Think before you act.\n\nBefore requesting preliminary data or completing your task, reflect on your\ncurrent state and explain your reasoning:\n\nFor preliminary requests (getAnalysisFiles, getPrismaSchemas, etc.):\n- What critical information is missing that you don't already have?\n- Why do you need it specifically right now?\n- Be brief - state the gap, don't list everything you have.\n\nFor completion (complete):\n- What key assets did you acquire?\n- What did you accomplish?\n- Why is it sufficient to complete?\n- Summarize - don't enumerate every single item.\n\nThis reflection helps you avoid duplicate requests and premature completion.",
type: "string"
},
request: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval\n(getPrismaSchemas) or final error correction (complete). When preliminary\nreturns empty array, that type is removed from the union, physically\npreventing repeated calls.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryGetPrismaSchemas"
},
{
$ref: "#/$defs/IAutoBeRealizeAuthorizationCorrectApplication.IComplete"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
getPrismaSchemas: "#/$defs/IAutoBePreliminaryGetPrismaSchemas",
complete: "#/$defs/IAutoBeRealizeAuthorizationCorrectApplication.IComplete"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
IAutoBePreliminaryGetPrismaSchemas: {
description: "Request to retrieve Prisma database schema definitions for context.\n\nThis type is used in the preliminary phase to request specific Prisma table\nschemas needed for generating type-safe API operations.",
type: "object",
properties: {
type: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"getPrismaSchemas\" indicates this is a preliminary\ndata request for Prisma schemas.",
type: "string",
"enum": [
"getPrismaSchemas"
]
},
schemaNames: {
description: "List of Prisma table names to retrieve.\n\nTable names from the Prisma schema file representing database entities\n(e.g., \"user\", \"post\", \"comment\").\n\nCRITICAL: DO NOT request the same schema names that you have already\nrequested in previous calls.\n\n\n@minItems 1",
type: "array",
items: {
type: "string"
}
}
},
required: [
"type",
"schemaNames"
]
},
"IAutoBeRealizeAuthorizationCorrectApplication.IComplete": {
description: "Request to fix authentication component errors.\n\nExecutes targeted error correction to resolve TypeScript compilation issues\nin provider, decorator, and payload type. Applies systematic fixes while\npreserving all authentication logic and business requirements.",
type: "object",
properties: {
type: {
description: "Type discriminator for the request.\n\nDetermines which action to perform: preliminary data retrieval or actual\ntask execution. Value \"complete\" indicates this is the final task\nexecution request.",
type: "string",
"enum": [
"complete"
]
},
error_analysis: {
description: "Step 1: TypeScript compilation error analysis and diagnosis.\n\nAI identifies and categorizes all compilation errors (type mismatches,\nimport issues, syntax errors) by component (providers/decorator/payload).\nLists specific error messages with their locations and types for\nsystematic troubleshooting.",
type: "string"
},
solution_guidance: {
description: "Step 2: Solution guidance and fix recommendations.\n\nAI provides clear, actionable instructions on how to resolve each\nidentified error. Includes specific steps like \"add property X to\ninterface Y\", \"update import path from A to B\", or \"change type from C to\nD\". Focus on guidance rather than generating complete code\nimplementations.",
type: "string"
},
provider: {
description: "Authentication Provider function configuration containing the function\nname and implementation code. The Provider handles JWT token\nverification, role validation, and database queries to authenticate\nusers.",
$ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IProvider"
},
decorator: {
description: "Authentication Decorator configuration containing the decorator name and\nimplementation code. The Decorator integrates with NestJS parameter\ndecorators to automatically inject authenticated user data into\nController methods.",
$ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IDecorator"
},
payload: {
description: "Authentication Payload Type configuration containing the payload type\nname and implementation code. The Payload Type is used to define the\nstructure of the authenticated user data that will be injected into\nController methods when using the decorator. It serves as the TypeScript\ntype for the parameter in Controller method signatures.",
$ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IPayloadType"
}
},
required: [
"type",
"error_analysis",
"solution_guidance",
"provider",
"decorator",
"payload"
]
},
"IAutoBeRealizeAuthorizationWriteApplication.IProvider": {
type: "object",
properties: {
name: {
description: "The name of the authentication Provider function in {role}Authorize\nformat (e.g., adminAuthorize, userAuthorize). This function will be\ncalled by the decorator to verify JWT tokens and return authenticated\nuser information for the specified role.\n\nDO: Use camelCase naming convention.\n\n\n@pattern ^[a-z][a-zA-Z0-9]*$",
type: "string"
},
content: {
description: "Complete TypeScript code for the authentication Provider function. Must\ninclude: JWT token verification using jwtAuthorize function, role type\nchecking against payload.type, database query using\nMyGlobal.prisma.{tableName} pattern to verify user existence, and proper\nerror handling with ForbiddenException and UnauthorizedException. The\nfunction should return the authenticated user payload data.",
type: "string"
}
},
required: [
"name",
"content"
]
},
"IAutoBeRealizeAuthorizationWriteApplication.IDecorator": {
type: "object",
properties: {
name: {
description: "The name of the Decorator to be generated in {Actor}Auth format (e.g.,\nAdminAuth, UserAuth). This decorator will be used as a parameter\ndecorator in Controller methods to automatically authenticate and\nauthorize users for the specific role, injecting the authenticated user\npayload as a method parameter.\n\nDO: Use PascalCase naming convention.\n\n\n@pattern ^[A-Z][a-zA-Z0-9]*$",
type: "string"
},
content: {
description: "Complete TypeScript code for the authentication Decorator implementation.\nMust include: SwaggerCustomizer integration to add bearer token security\nschema to API documentation, createParamDecorator implementation that\ncalls the corresponding Provider function for authentication, Singleton\npattern using tstl library for efficient decorator instance management,\nand proper TypeScript typing for the ParameterDecorator interface.",
type: "string"
}
},
required: [
"name",
"content"
]
},
"IAutoBeRealizeAuthorizationWriteApplication.IPayloadType": {
type: "object",
properties: {
name: {
description: "The name of the Payload type to be generated in {Actor}Payload format\n(e.g., AdminPayload, UserPayload). This type defines the structure of the\nauthenticated user data that will be injected into Controller methods\nwhen using the decorator.\n\nDO: Use PascalCase naming convention.\n\n\n@pattern ^[A-Z][a-zA-Z0-9]*$",
type: "string"
},
content: {
description: "Complete TypeScript code for the Payload type interface in {Actor}Payload\nformat (e.g., AdminPayload, UserPayload). Must include: id field with\nUUID format validation, type field as role discriminator, and proper\ntypia tags for validation. This interface defines the structure of the\nauthenticated user data that will be injected into Controller methods\nwhen using the decorator and serves as the TypeScript type for the\nparameter in Controller method signatures.",
type: "string"
}
},
required: [
"name",
"content"
]
}
}
},
description: "Process authentication component correction task or preliminary data\nrequests.\n\nFixes TypeScript compilation errors in authentication components through\nsystematic error diagnosis. Provides error analysis, solution guidance, and\ncorrected versions while preserving authentication logic.",
validate: (() => { const _io0 = input => "string" === typeof input.thinking && ("object" === typeof input.request && null !== input.request && _iu0(input.request)); const _io1 = input => "getPrismaSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io2 = input => "complete" === input.type && "string" === typeof input.error_analysis && "string" === typeof input.solution_guidance && ("object" === typeof input.provider && null !== input.provider && _io3(input.provider)) && ("object" === typeof input.decorator && null !== input.decorator && _io4(input.decorator)) && ("object" === typeof input.payload && null !== input.payload && _io5(input.payload)); const _io3 = input => "string" === typeof input.name && RegExp("^[a-z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _io4 = input => "string" === typeof input.name && RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _io5 = input => "string" === typeof input.name && RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _iu0 = input => (() => {
if ("getPrismaSchemas" === input.type)
return _io1(input);
else if ("complete" === 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: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeAuthorizationCorrectApplication.IComplete)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBePreliminaryGetPrismaSchemas | IAutoBeRealizeAuthorizationCorrectApplication.IComplete)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["getPrismaSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPrismaSchemas\"",
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, _index2) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index2 + "]",
expected: "string",
value: elem
}))