@autobe/agent
Version:
AI backend server code generator
779 lines • 153 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.orchestrateInterfaceOperation = orchestrateInterfaceOperation;
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 utils_2 = require("@typia/utils");
const tstl_1 = require("tstl");
const typia_1 = __importDefault(require("typia"));
const uuid_1 = require("uuid");
const RAGRetrieval_1 = require("../../utils/RAGRetrieval");
const executeCachedBatch_1 = require("../../utils/executeCachedBatch");
const forceRetry_1 = require("../../utils/forceRetry");
const getEmbedder_1 = require("../../utils/getEmbedder");
const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController");
const convertToSectionEntries_1 = require("../common/internal/convertToSectionEntries");
const transformInterfaceOperationHistory_1 = require("./histories/transformInterfaceOperationHistory");
const AutoBeInterfaceAuthorizationProgrammer_1 = require("./programmers/AutoBeInterfaceAuthorizationProgrammer");
const AutoBeInterfaceOperationProgrammer_1 = require("./programmers/AutoBeInterfaceOperationProgrammer");
const AutoBeJsonSchemaCollection_1 = require("./utils/AutoBeJsonSchemaCollection");
const AutoBeJsonSchemaFactory_1 = require("./utils/AutoBeJsonSchemaFactory");
const AutoBeJsonSchemaNamingConvention_1 = require("./utils/AutoBeJsonSchemaNamingConvention");
function orchestrateInterfaceOperation(ctx, props) {
return __awaiter(this, void 0, void 0, function* () {
// write
const progress = {
total: props.designs.length,
completed: 0,
};
const written = (yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, props.designs.map((design) => (promptCacheKey) => __awaiter(this, void 0, void 0, function* () {
const counter = new tstl_1.Singleton(() => ++progress.completed);
try {
const row = yield (0, forceRetry_1.forceRetry)(() => process(ctx, {
counter,
design,
progress,
promptCacheKey,
instruction: props.instruction,
}), 3, () => true);
return row;
}
catch (error) {
console.log("operation", design, error);
counter.get();
throw error;
}
})))).flat();
// unique dictionary
const unique = new tstl_1.HashMap(written.map((w) => new tstl_1.Pair({
path: w.path,
method: w.method,
}, w)), utils_1.AutoBeOpenApiEndpointComparator.hashCode, utils_1.AutoBeOpenApiEndpointComparator.equals);
// review removed — write agents self-review during rewrite loop
const operations = unique
.toJSON()
.map((it) => it.second);
AutoBeJsonSchemaNamingConvention_1.AutoBeJsonSchemaNamingConvention.normalize({
operations,
collection: new AutoBeJsonSchemaCollection_1.AutoBeJsonSchemaCollection({}, {}),
});
const analyze = ctx.state().analyze;
const sessionTypeNames = analyze.actors.map((actor) => AutoBeInterfaceAuthorizationProgrammer_1.AutoBeInterfaceAuthorizationProgrammer.getSessionTypeName({
prefix: analyze.prefix,
actor: actor.name,
}));
if (sessionTypeNames.length === 0)
return operations;
return operations.filter((op) => {
var _a, _b;
const predicate = (typeName) => {
if (typeName === undefined)
return true;
return sessionTypeNames.every((x) => typeName !== `${x}.ICreate` && typeName !== `${x}.IUpdate`);
};
return (predicate((_a = op.requestBody) === null || _a === void 0 ? void 0 : _a.typeName) &&
predicate((_b = op.responseBody) === null || _b === void 0 ? void 0 : _b.typeName));
});
});
}
function process(ctx, props) {
return __awaiter(this, void 0, void 0, function* () {
var _a, _b;
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 pathSegments = props.design.endpoint.path
.split("/")
.filter((p) => p && !p.startsWith(":") && !p.startsWith("{"));
const queryText = [
"operation",
props.design.endpoint.method,
...pathSegments,
].join(" ");
const ragSections = yield (0, RAGRetrieval_1.buildAnalysisContextSections)((0, getEmbedder_1.getEmbedder)(), allSections, queryText, "TOPK", { log: false, logPrefix: "interfaceOperation" });
const prefix = utils_2.NamingConvention.camel(ctx.state().analyze.prefix);
const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({
dispatch: (e) => ctx.dispatch(e),
state: ctx.state(),
application: {
version: "3.1",
components: {
schemas: {
"IAutoBeInterfaceOperationApplication.IProps": {
type: "object",
properties: {
thinking: {
type: "string",
description: "Think before you act.\n\nFor preliminary requests: what information is missing and why?\n\nFor write: what you're submitting and key design decisions.\n\nFor complete: why you consider the last write final."
},
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/IAutoBeInterfaceOperationApplication.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/IAutoBeInterfaceOperationApplication.IWrite"
}
},
description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls."
}
},
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."
},
"IAutoBeInterfaceOperationApplication.IWrite": {
type: "object",
properties: {
type: {
"const": "write",
description: "Type discriminator for write submission."
},
analysis: {
type: "string",
description: "Analysis of the endpoint's purpose and context."
},
rationale: {
type: "string",
description: "Rationale for the operation design decisions."
},
operation: {
$ref: "#/components/schemas/IAutoBeInterfaceOperationApplication.IOperation",
description: "The API operation to generate.\n\nFollow CRUD operation patterns:\n\n- List/search (PATCH `index`): include pagination, search, and sorting in\n request body\n- Detail retrieval (GET `at`): return single full entity\n- Creation (POST): use `.ICreate` request body\n- Modification (PUT): use `.IUpdate` request body\n\nUse object types for request/response bodies, reference named component\ntypes, and `application/json` content-type."
}
},
required: [
"type",
"analysis",
"rationale",
"operation"
],
description: "Submit a detailed API operation."
},
"IAutoBeInterfaceOperationApplication.IOperation": {
type: "object",
properties: {
name: {
type: "string",
pattern: "^[a-z][a-zA-Z0-9]*$",
description: "Functional name of the API endpoint. MUST use camelCase.\n\nMUST NOT be a JS/TS reserved word (`delete`, `for`, `if`, `class`,\n`return`, `new`, `this`, `void`, `const`, `let`, `var`, `async`, `await`,\n`export`, `import`, `switch`, `case`, `throw`, `try`). Use `erase`\ninstead of `delete`, `iterate` instead of `for`.\n\nStandard names:\n\n- `index`: list/search (PATCH), `at`: get by ID (GET)\n- `create`: POST, `update`: PUT, `erase`: DELETE\n\nAccessor uniqueness: the accessor is formed by joining non-parameter path\nsegments with dots, then appending the name. E.g., path\n`/shopping/sale/{saleId}/review/{reviewId}` + name `at` = accessor\n`shopping.sale.review.at`. Must be globally unique."
},
specification: {
type: "string",
description: "Internal implementation guidance for downstream agents (Realize, Test).\n\nDescribe HOW this operation should be implemented: service logic, DB\nqueries, business rules, edge cases, and error handling.\n\n> MUST be written in English. Never use other languages."
},
description: {
type: "string",
description: "API documentation for consumers. Describe the operation's purpose,\nbusiness logic, relationships, and error handling.\n\nFormat: summary sentence first, `\\n\\n`, then paragraphs grouped by topic.\nReference DB schema table/column descriptions for consistency.\n\nDo NOT use \"soft delete\" / \"soft-delete\" unless the operation actually\nimplements soft deletion (triggers validation expecting\nsoft_delete_column).\n\n> MUST be written in English. Never use other languages."
},
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."
},
responseBody: {
oneOf: [
{
type: "null"
},
{
$ref: "#/components/schemas/AutoBeOpenApi.IResponseBody"
}
],
description: "Response body of the API operation, or `null` if none."
},
parameters: {
type: "array",
items: {
$ref: "#/components/schemas/AutoBeOpenApi.IParameter"
},
description: "List of path parameters.\n\nEach parameter name must correspond to a `{paramName}` in the\n{@link path}."
},
requestBody: {
oneOf: [
{
type: "null"
},
{
$ref: "#/components/schemas/AutoBeOpenApi.IRequestBody"
}
],
description: "Request body of the API operation, or `null` if none."
}
},
required: [
"name",
"specification",
"description",
"path",
"method",
"responseBody",
"parameters",
"requestBody"
],
description: "RESTful API operation (excludes authorization and prerequisite fields).\n\nUse object types for request/response bodies, reference named component\ntypes, use `application/json` content-type, and `string &\ntags.Format<\"uri\">` for file operations."
},
"AutoBeOpenApi.IResponseBody": {
type: "object",
properties: {
description: {
type: "string",
description: "Description of the response body.\n\n> MUST be written in English. Never use other languages."
},
typeName: {
type: "string",
description: "Type name referencing a component schema.\n\nNaming convention: `IEntityName` (full), `IEntityName.ISummary`,\n`IEntityName.IInvert`, `IPageIEntityName` (paginated)."
}
},
required: [
"description",
"typeName"
],
description: "Response body for an API operation.\n\nContent-type is always `application/json`. For file downloads, use a URI\nstring property instead of `application/octet-stream`."
},
"AutoBeOpenApi.IParameter": {
type: "object",
properties: {
description: {
type: "string",
description: "Description of the path parameter.\n\n> MUST be written in English. Never use other languages."
},
name: {
type: "string",
pattern: "^[a-z][a-zA-Z0-9]*$",
description: "Identifier name in camelCase. Must match the `{paramName}` in the\n{@link AutoBeOpenApi.IOperation.path}."
},
schema: {
oneOf: [
{
$ref: "#/components/schemas/AutoBeOpenApi.IJsonSchema.INumber"
},
{
$ref: "#/components/schemas/AutoBeOpenApi.IJsonSchema.IInteger"
},
{
$ref: "#/components/schemas/AutoBeOpenApi.IJsonSchema.IString"
}
],
discriminator: {
propertyName: "type",
mapping: {
number: "#/components/schemas/AutoBeOpenApi.IJsonSchema.INumber",
integer: "#/components/schemas/AutoBeOpenApi.IJsonSchema.IInteger",
string: "#/components/schemas/AutoBeOpenApi.IJsonSchema.IString"
}
},
description: "Type schema of the path parameter (primitive types only)."
}
},
required: [
"description",
"name",
"schema"
],
description: "Path parameter definition for an API route."
},
"AutoBeOpenApi.IJsonSchema.INumber": {
type: "object",
properties: {
minimum: {
type: "number"
},
maximum: {
type: "number"
},
exclusiveMinimum: {
type: "number"
},
exclusiveMaximum: {
type: "number"
},
multipleOf: {
type: "number",
exclusiveMinimum: 0
},
type: {
"const": "number",
description: "Discriminator value. MUST be a single string, NEVER an array.\n\nFor nullable types, use `IOneOf` instead: `{ oneOf: [{ type: \"string\"\n}, { type: \"null\" }] }`"
}
},
required: [
"type"
],
description: "Number (double) type info."
},
"AutoBeOpenApi.IJsonSchema.IInteger": {
type: "object",
properties: {
minimum: {
type: "integer"
},
maximum: {
type: "integer"
},
exclusiveMinimum: {
type: "integer"
},
exclusiveMaximum: {
type: "integer"
},
multipleOf: {
type: "integer",
exclusiveMinimum: 0
},
type: {
"const": "integer",
description: "Discriminator value. MUST be a single string, NEVER an array.\n\nFor nullable types, use `IOneOf` instead: `{ oneOf: [{ type: \"string\"\n}, { type: \"null\" }] }`"
}
},
required: [
"type"
],
description: "Integer type info."
},
"AutoBeOpenApi.IJsonSchema.IString": {
type: "object",
properties: {
format: {
oneOf: [
{
"const": "password"
},
{
"const": "regex"
},
{
"const": "uuid"
},
{
"const": "email"
},
{
"const": "hostname"
},
{
"const": "idn-email"
},
{
"const": "idn-hostname"
},
{
"const": "iri"
},
{
"const": "iri-reference"
},
{
"const": "ipv4"
},
{
"const": "ipv6"
},
{
"const": "uri"
},
{
"const": "uri-reference"
},
{
"const": "uri-template"
},
{
"const": "url"
},
{
"const": "date-time"
},
{
"const": "date"
},
{
"const": "time"
},
{
"const": "duration"
},
{
"const": "json-pointer"
},
{
"const": "relative-json-pointer"
}
],
description: "Format restriction."
},
pattern: {
type: "string",
description: "Pattern restriction."
},
contentMediaType: {
type: "string",
description: "Content media type restriction.\n\nFor multiple media types, use `oneOf` with separate string schemas per\n`contentMediaType` value. Never use an array here."
},
minLength: {
type: "integer",
minimum: 0
},
maxLength: {
type: "integer",
minimum: 0
},
type: {
"const": "string",
description: "Discriminator value. MUST be a single string, NEVER an array.\n\nFor nullable types, use `IOneOf` instead: `{ oneOf: [{ type: \"string\"\n}, { type: \"null\" }] }`"
}
},
required: [
"type"
],
description: "String type info."
},
"AutoBeOpenApi.IRequestBody": {
type: "object",
properties: {
description: {
type: "string",
description: "Description of the request body.\n\n> MUST be written in English. Never use other languages."
},
typeName: {
type: "string",
description: "Type name referencing a component schema.\n\nNaming convention: `IEntityName.ICreate` (POST), `IEntityName.IUpdate`\n(PUT), `IEntityName.IRequest` (list/search)."
}
},
required: [
"description",
"typeName"
],
description: "Request body for an API operation.\n\nContent-type is always `application/json`. For file uploads, use a URI\nstring property instead of `multipart/form-data`."
}
}
},
functions: [
{
name: "process",
async: false,
parameters: [
{
name: "props",
description: " Preliminary data request, write submission, or completion\nconfirmation",
required: true,
schema: {
$ref: "#/components/schemas/IAutoBeInterfaceOperationApplication.IProps"
}
}
],
description: "Process operation generation task."
}
]
},
source: SOURCE,
kinds: [
"analysisSections",
"databaseSchemas",
"previousAnalysisSections",
"previousDatabaseSchemas",
"previousInterfaceOperations",
"complete",
],
local: {
analysisSections: ragSections,
},
});
const event = 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: SOURCE, controller: createController({
preliminary,
build: (complete) => {
pointer.value = complete;
},
}), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, (0, transformInterfaceOperationHistory_1.transformInterfaceOperationHistory)({
endpoint: props.design.endpoint,
instruction: props.instruction,
prefix,
preliminary,
})));
if (pointer.value === null)
return out(result)(null);
AutoBeInterfaceOperationProgrammer_1.AutoBeInterfaceOperationProgrammer.fix(pointer.value.operation);
for (const p of pointer.value.operation.parameters)
p.schema = AutoBeJsonSchemaFactory_1.AutoBeJsonSchemaFactory.fixSchema(p.schema);
// Use authorizationActors from endpoint design (not from LLM)
const authorizationActors = props.design.authorizationActors;
const matrix = authorizationActors.length === 0
? [
Object.assign(Object.assign({}, pointer.value.operation), { path: "/" +
[prefix, ...pointer.value.operation.path.split("/")]
.filter((it) => it !== "")
.join("/"), authorizationActor: null, authorizationType: null, prerequisites: [] }),
]
: authorizationActors.map((actor) => (Object.assign(Object.assign({}, pointer.value.operation), { path: "/" +
[prefix, actor, ...pointer.value.operation.path.split("/")]
.filter((it) => it !== "")
.join("/"), authorizationActor: actor, authorizationType: null, prerequisites: [] })));
props.counter.get();
return out(result)(Object.assign(Object.assign({ type: SOURCE, id: (0, uuid_1.v7)(), analysis: pointer.value.analysis, rationale: pointer.value.rationale, operations: matrix, acquisition: preliminary.getAcquisition(), metric: result.metric, tokenUsage: result.tokenUsage }, props.progress), { step: (_b = (_a = ctx.state().analyze) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0, created_at: new Date().toISOString() }));
}));
ctx.dispatch(event);
return event.operations;
});
}
function createController(props) {
const validate = (next) => {
const result = (() => { const _iv7 = new Set(["password", "regex", "uuid", "email", "hostname", "idn-email", "idn-hostname", "iri", "iri-reference", "ipv4", "ipv6", "uri", "uri-reference", "uri-template", "url", "date-time", "date", "time", "duration", "json-pointer", "relative-json-pointer"]); const _vv14 = new Set(["password", "regex", "uuid", "email", "hostname", "idn-email", "idn-hostname", "iri", "iri-reference", "ipv4", "ipv6", "uri", "uri-reference", "uri-template", "url", "date-time", "date", "time", "duration", "json-pointer", "relative-json-pointer"]); 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 && ("object" === typeof input.operation && null !== input.operation && _io9(input.operation)); const _io9 = input => "string" === typeof input.name && RegExp("^[a-z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.specification && "string" === typeof input.description && ("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) && (null === input.responseBody || "object" === typeof input.responseBody && null !== input.responseBody && _io10(input.responseBody)) && (Array.isArray(input.parameters) && input.parameters.every(elem => "object" === typeof elem && null !== elem && _io11(elem))) && (null === input.requestBody || "object" === typeof input.requestBody && null !== input.requestBody && _io15(input.requestBody)); const _io10 = input => "string" === typeof input.description && "string" === typeof input.typeName; const _io11 = input => "string" === typeof input.description && ("string" === typeof input.name && RegExp("^[a-z][a-zA-Z0-9]*$").test(input.name)) && ("object" === typeof input.schema && null !== input.schema && _iu1(input.schema)); const _io12 = input => (undefined === input.minimum || "number" === typeof input.minimum && (Math.floor(input.minimum) === input.minimum && -9223372036854776000 <= input.minimum && input.minimum <= 9223372036854776000)) && (undefined === input.maximum || "number" === typeof input.maximum && (Math.floor(input.maximum) === input.maximum && -9223372036854776000 <= input.maximum && input.maximum <= 9223372036854776000)) && (undefined === input.exclusiveMinimum || "number" === typeof input.exclusiveMinimum && (Math.floor(input.exclusiveMinimum) === input.exclusiveMinimum && -9223372036854776000 <= input.exclusiveMinimum && input.exclusiveMinimum <= 9223372036854776000)) && (