@autobe/agent
Version:
AI backend server code generator
832 lines • 87 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.orchestrateInterfaceEndpointWrite = void 0;
const __typia_transform__isTypeUint32 = __importStar(require("typia/lib/internal/_isTypeUint32"));
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 tstl_1 = require("tstl");
const typia_1 = __importDefault(require("typia"));
const uuid_1 = require("uuid");
const RAGRetrieval_1 = require("../../utils/RAGRetrieval");
const getEmbedder_1 = require("../../utils/getEmbedder");
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const convertToSectionEntries_1 = require("../common/internal/convertToSectionEntries");
const AutoBeInterfaceEndpointProgrammer_1 = require("./programmers/AutoBeInterfaceEndpointProgrammer");
const orchestrateInterfaceEndpointWrite = (ctx, props) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
const start = new Date();
const allSections = (0, convertToSectionEntries_1.convertToSectionEntries)((_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.files) !== null && _b !== void 0 ? _b : []);
const queryText = [
"interface",
"endpoint",
props.group.name,
...props.group.databaseSchemas,
].join(" ");
const ragSections = yield (0, RAGRetrieval_1.buildAnalysisContextSections)((0, getEmbedder_1.getEmbedder)(), allSections, queryText, "TOPK", { log: false, logPrefix: "interfaceEndpointWrite" });
const databaseSchemas = new Map(ctx
.state()
.database.result.data.files.flatMap((f) => f.models)
.map((m) => [m.name, m]));
const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({
dispatch: (e) => ctx.dispatch(e),
state: ctx.state(),
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeInterfaceEndpointWriteApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Reasoning: what's missing (preliminary), what you're submitting (write),\nor why you're finalizing (complete)."
},
request: {
oneOf: [
{
$ref: "#/components/schemas/IAutoBePreliminaryComplete"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPreviousAnalysisSections"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPreviousDatabaseSchemas"
},
{
$ref: "#/components/schemas/IAutoBePreliminaryGetPreviousInterfaceOperations"
},
{
$ref: "#/components/schemas/IAutoBeInterfaceEndpointWriteApplication.IWrite"
}
],
discriminator: {
propertyName: "type",
mapping: {
complete: "#/components/schemas/IAutoBePreliminaryComplete",
getAnalysisSections: "#/components/schemas/IAutoBePreliminaryGetAnalysisSections",
getDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas",
getPreviousAnalysisSections: "#/components/schemas/IAutoBePreliminaryGetPreviousAnalysisSections",
getPreviousDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetPreviousDatabaseSchemas",
getPreviousInterfaceOperations: "#/components/schemas/IAutoBePreliminaryGetPreviousInterfaceOperations",
write: "#/components/schemas/IAutoBeInterfaceEndpointWriteApplication.IWrite"
}
},
description: "Action to perform. Exhausted preliminary types are removed from the\nunion."
}
},
required: [
"thinking",
"request"
]
},
IAutoBePreliminaryComplete: {
type: "object",
properties: {
type: {
"const": "complete",
description: "Type discriminator for completion request."
}
},
required: [
"type"
],
description: "Finalize the write loop by accepting your most recent `write` as-is.\n\nAfter submitting a `write`, review it yourself thoroughly against the review\nchecklist in your instructions. If you find issues worth fixing, submit\nanother `write` with corrections. When you are satisfied with the quality,\ncall `complete` to finalize.\n\nYou have a maximum of 3 write attempts, but this is a safety cap \u2014 not a\ntarget to fill.\n\nOnly valid after at least one `write` submission \u2014 rejected otherwise."
},
IAutoBePreliminaryGetAnalysisSections: {
type: "object",
properties: {
type: {
"const": "getAnalysisSections",
description: "Type discriminator."
},
sectionIds: {
type: "array",
items: {
type: "integer",
minimum: 0
},
minItems: 1,
maxItems: 100,
description: "Section IDs to retrieve. DO NOT request same IDs already requested in\nprevious calls."
}
},
required: [
"type",
"sectionIds"
],
description: "Request to retrieve individual analysis sections by numeric ID."
},
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."
},
IAutoBePreliminaryGetPreviousAnalysisSections: {
type: "object",
properties: {
type: {
"const": "getPreviousAnalysisSections",
description: "Type discriminator."
},
sectionIds: {
type: "array",
items: {
type: "integer",
minimum: 0
},
minItems: 1,
description: "Section IDs to retrieve from previous iteration. DO NOT request same IDs\nalready requested in previous calls."
}
},
required: [
"type",
"sectionIds"
],
description: "Request to retrieve analysis sections from the previous iteration by numeric\nID."
},
IAutoBePreliminaryGetPreviousDatabaseSchemas: {
type: "object",
properties: {
type: {
"const": "getPreviousDatabaseSchemas",
description: "Type discriminator."
},
schemaNames: {
type: "array",
items: {
type: "string"
},
minItems: 1,
description: "Table names to retrieve from previous iteration. DO NOT request same names\nalready requested in previous calls."
}
},
required: [
"type",
"schemaNames"
],
description: "Request to retrieve database schemas from the previous iteration.\n\nLoads database table definitions from the last successfully generated\nversion, used as reference context during regeneration or modification\ncycles."
},
IAutoBePreliminaryGetPreviousInterfaceOperations: {
type: "object",
properties: {
type: {
"const": "getPreviousInterfaceOperations",
description: "Type discriminator."
},
endpoints: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeOpenApi.IEndpoint"
},
minItems: 1,
description: "Endpoints to retrieve from previous iteration. DO NOT request same\nendpoints already requested in previous calls."
}
},
required: [
"type",
"endpoints"
],
description: "Request to retrieve interface operations from the previous iteration.\n\nLoads API operation definitions from the last successfully generated version,\nused as reference context during regeneration or modification cycles."
},
"AutoBeOpenApi.IEndpoint": {
type: "object",
properties: {
path: {
type: "string",
pattern: "^\\/[a-zA-Z0-9\\/_{}.-]*$",
description: "HTTP path of the API operation.\n\nMust start with `/`. Parameters use curly braces: `{paramName}`. Resource\nnames in camelCase. No quotes, spaces, role prefixes (`/admin/`), or API\nversion prefixes (`/api/v1/`).\n\nAllowed characters: letters, digits, `/`, `{`, `}`, `-`, `_`, `.`"
},
method: {
oneOf: [
{
"const": "get"
},
{
"const": "post"
},
{
"const": "put"
},
{
"const": "delete"
},
{
"const": "patch"
}
],
description: "HTTP method (lowercase only).\n\nUse `patch` (not `get`) when a read operation needs a complex\n{@link requestBody}. `get` cannot have a request body."
}
},
required: [
"path",
"method"
],
description: "API endpoint information."
},
"IAutoBeInterfaceEndpointWriteApplication.IWrite": {
type: "object",
properties: {
type: {
"const": "write",
description: "Type discriminator for write submission."
},
analysis: {
type: "string",
description: "Analysis of requirements and database schema for endpoint design."
},
rationale: {
type: "string",
description: "Rationale for the endpoint design decisions."
},
designs: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeInterfaceEndpointDesign"
},
description: "Array of endpoint designs to generate.\n\nPath rules: hierarchical `/` structure, must start with `/`, no domain\nprefixes, plural resource names. No duplicate endpoints. Path parameters\nclearly named. Nested paths reflect entity relationships."
}
},
required: [
"type",
"analysis",
"rationale",
"designs"
],
description: "Submit endpoint designs."
},
AutoBeInterfaceEndpointDesign: {
type: "object",
properties: {
description: {
type: "string",
description: "Functional description of what this endpoint does and why. Keep concise."
},
authorizationActors: {
type: "array",
items: {
type: "string",
pattern: "^[a-z][a-zA-Z0-9]*$",
minLength: 1
},
description: "Authorization actors associated with this endpoint (camelCase).\n\nInclude an actor if it can call this endpoint or the endpoint is\nsemantically related to it (e.g., `/auth/users/login` \u2192 `[\"user\"]`). Empty\narray for public endpoints.\n\nEach actor may generate a separate endpoint \u2014 minimize to prevent endpoint\nexplosion."
},
authorizationType: {
oneOf: [
{
type: "null"
},
{
"const": "login"
},
{
"const": "join"
},
{
"const": "refresh"
},
{
"const": "password"
},
{
"const": "session"
},
{
"const": "withdraw"
},
{
"const": "management"
}
],
description: "Authorization type of the endpoint.\n\n- `\"login\"`: Credential validation\n- `\"join\"`: Account registration\n- `\"withdraw\"`: Account deactivation\n- `\"refresh\"`: Token renewal\n- `\"session\"`: Session management (logout, etc.)\n- `\"password\"`: Password reset/change\n- `\"management\"`: Other auth-related (2FA, OAuth, verification)\n- `null`: All other endpoints"
},
endpoint: {
$ref: "#/components/schemas/AutoBeOpenApi.IEndpoint",
description: "The endpoint definition containing path and HTTP method."
}
},
required: [
"description",
"authorizationActors",
"authorizationType",
"endpoint"
],
description: "Endpoint design with description, authorization, and endpoint definition."
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeInterfaceEndpointWriteApplication.IProps"
}
}
],
description: "Process task or retrieve preliminary data."
}
]
},
kinds: [
"analysisSections",
"databaseSchemas",
"previousAnalysisSections",
"previousDatabaseSchemas",
"previousInterfaceOperations",
"complete",
],
source: SOURCE,
local: {
analysisSections: ragSections,
databaseSchemas: props.group.databaseSchemas
.map((key) => databaseSchemas.get(key))
.filter((m) => m !== undefined),
},
});
const event = yield preliminary.orchestrate(ctx, (out) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c, _d, _e, _f;
const pointer = {
value: null,
};
const result = yield ctx.conversate(Object.assign({ source: SOURCE, controller: createController({
actors: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.actors) !== null && _b !== void 0 ? _b : [],
preliminary,
build: (next) => {
pointer.value = next;
},
}), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, props.programmer.history({
group: props.group,
preliminary,
})));
if (pointer.value === null)
return out(result)(null);
const actors = (_d = (_c = ctx.state().analyze) === null || _c === void 0 ? void 0 : _c.actors) !== null && _d !== void 0 ? _d : [];
const designs = new tstl_1.HashMap(pointer.value.designs.map((c) => new tstl_1.Pair(c.endpoint, c)), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals)
.toJSON()
.map((it) => AutoBeInterfaceEndpointProgrammer_1.AutoBeInterfaceEndpointProgrammer.fixDesign({
actors,
design: it.second,
}))
.filter((design) => AutoBeInterfaceEndpointProgrammer_1.AutoBeInterfaceEndpointProgrammer.filter({
kind: props.programmer.kind,
design,
actors,
}));
return out(result)({
id: (0, uuid_1.v7)(),
type: SOURCE,
kind: props.programmer.kind,
group: props.group.name,
analysis: pointer.value.analysis,
rationale: pointer.value.rationale,
designs,
acquisition: preliminary.getAcquisition(),
metric: result.metric,
tokenUsage: result.tokenUsage,
created_at: start.toISOString(),
step: (_f = (_e = ctx.state().analyze) === null || _e === void 0 ? void 0 : _e.step) !== null && _f !== void 0 ? _f : 0,
completed: props.counter.get(),
total: props.progress.total,
});
}));
ctx.dispatch(event);
return event.designs;
});
exports.orchestrateInterfaceEndpointWrite = orchestrateInterfaceEndpointWrite;
const createController = (props) => {
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 => "complete" === input.type; const _io2 = input => "getAnalysisSections" === input.type && (Array.isArray(input.sectionIds) && (1 <= input.sectionIds.length && input.sectionIds.length <= 100 && input.sectionIds.every(elem => "number" === typeof elem && __typia_transform__isTypeUint32._isTypeUint32(elem)))); const _io3 = input => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io4 = input => "getPreviousAnalysisSections" === input.type && (Array.isArray(input.sectionIds) && (1 <= input.sectionIds.length && input.sectionIds.every(elem => "number" === typeof elem && __typia_transform__isTypeUint32._isTypeUint32(elem)))); const _io5 = input => "getPreviousDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io6 = input => "getPreviousInterfaceOperations" === input.type && (Array.isArray(input.endpoints) && (1 <= input.endpoints.length && input.endpoints.every(elem => "object" === typeof elem && null !== elem && _io7(elem)))); const _io7 = input => "string" === typeof input.path && RegExp("^\\/[a-zA-Z0-9\\/_{}.-]*$").test(input.path) && ("get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method); const _io8 = input => "write" === input.type && "string" === typeof input.analysis && "string" === typeof input.rationale && (Array.isArray(input.designs) && input.designs.every(elem => "object" === typeof elem && null !== elem && _io9(elem))); const _io9 = input => "string" === typeof input.description && (Array.isArray(input.authorizationActors) && input.authorizationActors.every(elem => "string" === typeof elem && (RegExp("^[a-z][a-zA-Z0-9]*$").test(elem) && 1 <= elem.length))) && (null === input.authorizationType || "login" === input.authorizationType || "join" === input.authorizationType || "refresh" === input.authorizationType || "password" === input.authorizationType || "session" === input.authorizationType || "withdraw" === input.authorizationType || "management" === input.authorizationType) && ("object" === typeof input.endpoint && null !== input.endpoint && _io7(input.endpoint)); const _iu0 = input => (() => {
if ("complete" === input.type)
return _io1(input);
else if ("getAnalysisSections" === input.type)
return _io2(input);
else if ("getDatabaseSchemas" === input.type)
return _io3(input);
else if ("getPreviousAnalysisSections" === input.type)
return _io4(input);
else if ("getPreviousDatabaseSchemas" === input.type)
return _io5(input);
else if ("getPreviousInterfaceOperations" === input.type)
return _io6(input);
else if ("write" === input.type)
return _io8(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: "(IAutoBeInterfaceEndpointWriteApplication.IWrite | IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetPreviousAnalysisSections | IAutoBePreliminaryGetPreviousDatabaseSchemas | IAutoBePreliminaryGetPreviousInterfaceOperations)",
value: input.request
})) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".request",
expected: "(IAutoBeInterfaceEndpointWriteApplication.IWrite | IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetPreviousAnalysisSections | IAutoBePreliminaryGetPreviousDatabaseSchemas | IAutoBePreliminaryGetPreviousInterfaceOperations)",
value: input.request
})].every(flag => flag); const _vo1 = (input, _path, _exceptionable = true) => ["complete" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"complete\"",
value: input.type
})].every(flag => flag); const _vo2 = (input, _path, _exceptionable = true) => ["getAnalysisSections" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getAnalysisSections\"",
value: input.type
}), (Array.isArray(input.sectionIds) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1> & MaxItems<100>)",
value: input.sectionIds
})) && ((1 <= input.sectionIds.length || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "Array<> & MinItems<1>",
value: input.sectionIds
})) && (input.sectionIds.length <= 100 || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "Array<> & MaxItems<100>",
value: input.sectionIds
})) && input.sectionIds.map((elem, _index8) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index8 + "]",
expected: "number & Type<\"uint32\">",
value: elem
})) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index8 + "]",
expected: "(number & Type<\"uint32\">)",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1> & MaxItems<100>)",
value: input.sectionIds
})].every(flag => flag); const _vo3 = (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, _index9) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index9 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})].every(flag => flag); const _vo4 = (input, _path, _exceptionable = true) => ["getPreviousAnalysisSections" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPreviousAnalysisSections\"",
value: input.type
}), (Array.isArray(input.sectionIds) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1>)",
value: input.sectionIds
})) && ((1 <= input.sectionIds.length || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "Array<> & MinItems<1>",
value: input.sectionIds
})) && input.sectionIds.map((elem, _index10) => "number" === typeof elem && (__typia_transform__isTypeUint32._isTypeUint32(elem) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index10 + "]",
expected: "number & Type<\"uint32\">",
value: elem
})) || _report(_exceptionable, {
path: _path + ".sectionIds[" + _index10 + "]",
expected: "(number & Type<\"uint32\">)",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".sectionIds",
expected: "(Array<number & Type<\"uint32\">> & MinItems<1>)",
value: input.sectionIds
})].every(flag => flag); const _vo5 = (input, _path, _exceptionable = true) => ["getPreviousDatabaseSchemas" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPreviousDatabaseSchemas\"",
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, _index11) => "string" === typeof elem || _report(_exceptionable, {
path: _path + ".schemaNames[" + _index11 + "]",
expected: "string",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".schemaNames",
expected: "(Array<string> & MinItems<1>)",
value: input.schemaNames
})].every(flag => flag); const _vo6 = (input, _path, _exceptionable = true) => ["getPreviousInterfaceOperations" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"getPreviousInterfaceOperations\"",
value: input.type
}), (Array.isArray(input.endpoints) || _report(_exceptionable, {
path: _path + ".endpoints",
expected: "(Array<AutoBeOpenApi.IEndpoint> & MinItems<1>)",
value: input.endpoints
})) && ((1 <= input.endpoints.length || _report(_exceptionable, {
path: _path + ".endpoints",
expected: "Array<> & MinItems<1>",
value: input.endpoints
})) && input.endpoints.map((elem, _index12) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".endpoints[" + _index12 + "]",
expected: "AutoBeOpenApi.IEndpoint",
value: elem
})) && _vo7(elem, _path + ".endpoints[" + _index12 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".endpoints[" + _index12 + "]",
expected: "AutoBeOpenApi.IEndpoint",
value: elem
})).every(flag => flag)) || _report(_exceptionable, {
path: _path + ".endpoints",
expected: "(Array<AutoBeOpenApi.IEndpoint> & MinItems<1>)",
value: input.endpoints
})].every(flag => flag); const _vo7 = (input, _path, _exceptionable = true) => ["string" === typeof input.path && (RegExp("^\\/[a-zA-Z0-9\\/_{}.-]*$").test(input.path) || _report(_exceptionable, {
path: _path + ".path",
expected: "string & Pattern<\"^\\\\/[a-zA-Z0-9\\\\/_{}.-]*$\">",
value: input.path
})) || _report(_exceptionable, {
path: _path + ".path",
expected: "(string & Pattern<\"^\\\\/[a-zA-Z0-9\\\\/_{}.-]*$\">)",
value: input.path
}), "get" === input.method || "post" === input.method || "put" === input.method || "delete" === input.method || "patch" === input.method || _report(_exceptionable, {
path: _path + ".method",
expected: "(\"delete\" | \"get\" | \"patch\" | \"post\" | \"put\")",
value: input.method
})].every(flag => flag); const _vo8 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, {
path: _path + ".type",
expected: "\"write\"",
value: input.type
}), "string" === typeof input.analysis || _report(_exceptionable, {
path: _path + ".analysis",
expected: "string",
value: input.analysis
}), "string" === typeof input.rationale || _report(_exceptionable, {
path: _path + ".rationale",
expected: "string",
value: input.rationale
}), (Array.isArray(input.designs) || _report(_exceptionable, {
path: _path + ".designs",
expected: "Array<AutoBeInterfaceEndpointDesign>",
value: input.designs
})) && input.designs.map((elem, _index13) => ("object" === typeof elem && null !== elem || _report(_exceptionable, {
path: _path + ".designs[" + _index13 + "]",
expected: "AutoBeInterfaceEndpointDesign",
value: elem
})) && _vo9(elem, _path + ".designs[" + _index13 + "]", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".designs[" + _index13 + "]",
expected: "AutoBeInterfaceEndpointDesign",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".designs",
expected: "Array<AutoBeInterfaceEndpointDesign>",
value: input.designs
})].every(flag => flag); const _vo9 = (input, _path, _exceptionable = true) => ["string" === typeof input.description || _report(_exceptionable, {
path: _path + ".description",
expected: "string",
value: input.description
}), (Array.isArray(input.authorizationActors) || _report(_exceptionable, {
path: _path + ".authorizationActors",
expected: "Array<string & CamelCasePattern & MinLength<1>>",
value: input.authorizationActors
})) && input.authorizationActors.map((elem, _index14) => "string" === typeof elem && (RegExp("^[a-z][a-zA-Z0-9]*$").test(elem) || _report(_exceptionable, {
path: _path + ".authorizationActors[" + _index14 + "]",
expected: "string & CamelCasePattern",
value: elem
})) && (1 <= elem.length || _report(_exceptionable, {
path: _path + ".authorizationActors[" + _index14 + "]",
expected: "string & MinLength<1>",
value: elem
})) || _report(_exceptionable, {
path: _path + ".authorizationActors[" + _index14 + "]",
expected: "(string & CamelCasePattern & MinLength<1>)",
value: elem
})).every(flag => flag) || _report(_exceptionable, {
path: _path + ".authorizationActors",
expected: "Array<string & CamelCasePattern & MinLength<1>>",
value: input.authorizationActors
}), null === input.authorizationType || "login" === input.authorizationType || "join" === input.authorizationType || "refresh" === input.authorizationType || "password" === input.authorizationType || "session" === input.authorizationType || "withdraw" === input.authorizationType || "management" === input.authorizationType || _report(_exceptionable, {
path: _path + ".authorizationType",
expected: "(\"join\" | \"login\" | \"management\" | \"password\" | \"refresh\" | \"session\" | \"withdraw\" | null)",
value: input.authorizationType
}), ("object" === typeof input.endpoint && null !== input.endpoint || _report(_exceptionable, {
path: _path + ".endpoint",
expected: "AutoBeOpenApi.IEndpoint",
value: input.endpoint
})) && _vo7(input.endpoint, _path + ".endpoint", true && _exceptionable) || _report(_exceptionable, {
path: _path + ".endpoint",
expected: "AutoBeOpenApi.IEndpoint",
value: input.endpoint
})].every(flag => flag); const _vu0 = (input, _path, _exceptionable = true) => (() => {
if ("complete" === input.type)
return _vo1(input, _path, true && _exceptionable);
else if ("getAnalysisSections" === input.type)
return _vo2(input, _path, true && _exceptionable);
else if ("getDatabaseSchemas" === input.type)
return _vo3(input, _path, true && _exceptionable);
else if ("getPreviousAnalysisSections" === input.type)
return _vo4(input, _path, true && _exceptionable);
else if ("getPreviousDatabaseSchemas" === input.type)
return _vo5(input, _path, true && _exceptionable);
else if ("getPreviousInterfaceOperations" === input.type)
return _vo6(input, _path, true && _exceptionable);
else if ("write" === input.type)
return _vo8(input, _path, true && _exceptionable);
else
return _report(_exceptionable, {
path: _path,
expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetAnalysisSections | IAutoBePreliminaryGetDatabaseSchemas | IAutoBePreliminaryGetPreviousAnalysisSections | IAutoBePreliminaryGetPreviousDatabaseSchemas | IAutoBePreliminaryGetPreviousInterfaceOperations | IAutoBeInterfaceEndpointWriteApplication.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: "IAutoBeInterfaceEndpointWriteApplication.IProps",
value: input
})) && _vo0(input, _path + "", true) || _report(true, {
path: _path + "",
expected: "IAutoBeInterfaceEndpointWriteApplication.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 props.preliminary.validate({
thinking: result.data.thinking,
request: result.data.request,
});
const designs = result.data.request.designs;
const errors = [];
designs.forEach((d, i) => {
AutoBeInterfaceEndpointProgrammer_1.AutoBeInterfaceEndpointProgrammer.validateDesign({
actors: props.actors,
design: d,
errors,
path: `$input.request.designs[${i}]`,
});
});
if (errors.length !== 0)
return {
success: false,
errors,
data: input,
};
return result;
};
const application = props.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({
functions: [
{
name: "process",
parameters: {
description: "Current Type: {@link IAutoBeInterfaceEndpointWriteApplication.IProps}",
type: "object",
properties: {
thinking: {
description: "Reasoning: what's missing (preliminary), what you're submitting (write),\nor why you're finalizing (complete).",
type: "string"
},
request: {
description: "Action to perform. Exhausted preliminary types are removed from the\nunion.",
anyOf: [
{
$ref: "#/$defs/IAutoBePreliminaryComplete"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetAnalysisSections"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetPreviousAnalysisSections"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetPreviousDatabaseSchemas"
},
{
$ref: "#/$defs/IAutoBePreliminaryGetPreviousInterfaceOperations"
},
{
$ref: "#/$defs/IAutoBeInterfaceEndpointWriteApplication.IWrite"
}
],
"x-discriminator": {
propertyName: "type",
mapping: {
complete: "#/$defs/IAutoBePreliminaryComplete",
getAnalysisSections: "#/$defs/IAutoBePreliminaryGetAnalysisSections",
getDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas",
getPreviousAnalysisSections: "#/$defs/IAutoBePreliminaryGetPreviousAnalysisSections",
getPreviousDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetPreviousDatabaseSchemas",
getPreviousInterfaceOperations: "#/$defs/IAutoBePreliminaryGetPreviousInterfaceOperations",
write: "#/$defs/IAutoBeInterfaceEndpointWriteApplication.IWrite"
}
}
}
},
required: [
"thinking",
"request"
],
additionalProperties: false,
$defs: {
IAutoBePreliminaryComplete: {
description: "Finalize the write loop by accepting your most recent `write` as-is.\n\nAfter submitting a `write`, review it yourself thoroughly against the review\nchecklist in your instructions. If you find issues worth fixing, submit\nanother `write` with corrections. When you are satisfied with the quality,\ncall `complete` to finalize.\n\nYou have a maximum of 3 write attempts, but this is a safety cap \u2014 not a\ntarget to fill.\n\nOnly valid after at least one `write` submission \u2014 rejected otherwise.",
type: "object",
properties: {
type: {
description: "Type discriminator for completion requ