UNPKG

@autobe/agent

Version:

AI backend server code generator

820 lines (819 loc) 50.9 kB
"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.orchestrateRealizeAuthorizationWrite = orchestrateRealizeAuthorizationWrite; const __typia_transform__validateReport = __importStar(require("typia/lib/internal/_validateReport")); const __typia_transform__llmApplicationFinalize = __importStar(require("typia/lib/internal/_llmApplicationFinalize")); const tstl_1 = require("tstl"); const typia_1 = __importDefault(require("typia")); const uuid_1 = require("uuid"); const executeCachedBatch_1 = require("../../utils/executeCachedBatch"); const forceRetry_1 = require("../../utils/forceRetry"); const AutoBePreliminaryController_1 = require("../common/AutoBePreliminaryController"); const transformRealizeAuthorizationWriteHistory_1 = require("./histories/transformRealizeAuthorizationWriteHistory"); const orchestrateRealizeAuthorizationCorrect_1 = require("./orchestrateRealizeAuthorizationCorrect"); const AuthorizationFileSystem_1 = require("./utils/AuthorizationFileSystem"); const InternalFileSystem_1 = require("./utils/InternalFileSystem"); /** * 1. Create decorator and its parameters. and design the Authorization Provider. * 2. According to Authorization Provider design, create the Provider. * * @param ctx */ function orchestrateRealizeAuthorizationWrite(ctx) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f; ctx.dispatch({ type: "realizeAuthorizationStart", id: (0, uuid_1.v7)(), step: (_b = (_a = ctx.state().test) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0, created_at: new Date().toISOString(), }); const actors = (_d = (_c = ctx.state().analyze) === null || _c === void 0 ? void 0 : _c.actors) !== null && _d !== void 0 ? _d : []; const progress = { total: actors.length, completed: 0, }; const templates = yield (yield ctx.compiler()).getTemplate({ phase: "realize", dbms: "sqlite", }); const authorizations = yield (0, executeCachedBatch_1.executeCachedBatch)(ctx, actors.map((a) => (promptCacheKey) => __awaiter(this, void 0, void 0, function* () { const counter = new tstl_1.Singleton(() => ++progress.completed); try { return yield (0, forceRetry_1.forceRetry)(() => process(ctx, { actor: a, templates: InternalFileSystem_1.InternalFileSystem.DEFAULT.map((el) => ({ [el]: templates[el], })).reduce((acc, cur) => Object.assign(acc, cur), {}), progress, promptCacheKey, counter, })); } catch (error) { counter.get(); throw error; } }))); ctx.dispatch({ type: "realizeAuthorizationComplete", id: (0, uuid_1.v7)(), created_at: new Date().toISOString(), step: (_f = (_e = ctx.state().test) === null || _e === void 0 ? void 0 : _e.step) !== null && _f !== void 0 ? _f : 0, }); return authorizations; }); } function process(ctx, props) { return __awaiter(this, void 0, void 0, function* () { var _a; const preliminary = new AutoBePreliminaryController_1.AutoBePreliminaryController({ source: SOURCE, dispatch: (e) => ctx.dispatch(e), application: { version: "3.1", components: { schemas: { "IAutoBeRealizeAuthorizationWriteApplication.IProps": { type: "object", properties: { thinking: { type: "string", description: "Think before you act.\n\nFor preliminary requests: what database schemas are missing and why?\n\nFor write: what authentication components you're submitting.\n\nFor complete: why you consider the last write final." }, request: { oneOf: [ { $ref: "#/components/schemas/IAutoBePreliminaryComplete" }, { $ref: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas" }, { $ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IWrite" } ], discriminator: { propertyName: "type", mapping: { complete: "#/components/schemas/IAutoBePreliminaryComplete", getDatabaseSchemas: "#/components/schemas/IAutoBePreliminaryGetDatabaseSchemas", write: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.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." }, 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." }, "IAutoBeRealizeAuthorizationWriteApplication.IWrite": { type: "object", properties: { type: { "const": "write", description: "Type discriminator for write submission." }, provider: { $ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IProvider", description: "Authentication Provider function (JWT verification, role validation, DB\nqueries)." }, decorator: { $ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IDecorator", description: "Authentication Decorator (NestJS parameter decorator injecting\nauthenticated user data)." }, payload: { $ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IPayloadType", description: "Authentication Payload Type (TypeScript type for authenticated user data\nin Controller methods)." } }, required: [ "type", "provider", "decorator", "payload" ], description: "Request to generate authentication components (provider, decorator,\npayload)." }, "IAutoBeRealizeAuthorizationWriteApplication.IProvider": { type: "object", properties: { name: { type: "string", pattern: "^[a-z][a-zA-Z0-9]*$", description: "Provider function name in {role}Authorize format (e.g., adminAuthorize).\nMUST use camelCase." }, content: { type: "string", description: "Complete TypeScript code. MUST include: jwtAuthorize call, role type\ncheck, MyGlobal.prisma.{tableName} query,\nForbiddenException/UnauthorizedException handling." } }, required: [ "name", "content" ] }, "IAutoBeRealizeAuthorizationWriteApplication.IDecorator": { type: "object", properties: { name: { type: "string", pattern: "^[A-Z][a-zA-Z0-9]*$", description: "Decorator name in {Actor}Auth format (e.g., AdminAuth, UserAuth). MUST\nuse PascalCase." }, content: { type: "string", description: "Complete TypeScript code. MUST include: SwaggerCustomizer integration,\ncreateParamDecorator calling Provider, Singleton pattern via tstl." } }, required: [ "name", "content" ] }, "IAutoBeRealizeAuthorizationWriteApplication.IPayloadType": { type: "object", properties: { name: { type: "string", pattern: "^[A-Z][a-zA-Z0-9]*$", description: "Payload type name in {Actor}Payload format (e.g., AdminPayload,\nUserPayload). MUST use PascalCase." }, content: { type: "string", description: "Complete TypeScript code. MUST include: id field with UUID validation,\ntype field as role discriminator, typia tags." } }, required: [ "name", "content" ] } } }, functions: [ { name: "process", async: false, parameters: [ { name: "next", description: " Preliminary data request, write submission, or completion\nconfirmation", required: true, schema: { $ref: "#/components/schemas/IAutoBeRealizeAuthorizationWriteApplication.IProps" } } ], description: "Process authentication generation task." } ] }, kinds: ["databaseSchemas", "complete"], state: ctx.state(), }); 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: "realizeAuthorizationWrite", controller: createController({ build: (next) => { pointer.value = next; }, preliminary, }), enforceFunctionCall: true, promptCacheKey: props.promptCacheKey }, (0, transformRealizeAuthorizationWriteHistory_1.transformRealizeAuthorizationWriteHistory)({ actor: props.actor, preliminary, }))); if (pointer.value === null) return out(result)(null); const compiler = yield ctx.compiler(); const authorization = { actor: props.actor, decorator: { location: AuthorizationFileSystem_1.AuthorizationFileSystem.decoratorPath(pointer.value.decorator.name), name: pointer.value.decorator.name, content: pointer.value.decorator.content, }, payload: { location: AuthorizationFileSystem_1.AuthorizationFileSystem.payloadPath(pointer.value.payload.name), name: pointer.value.payload.name, content: yield compiler.typescript.beautify(pointer.value.payload.content), }, provider: { location: AuthorizationFileSystem_1.AuthorizationFileSystem.providerPath(pointer.value.provider.name), name: pointer.value.provider.name, content: pointer.value.provider.content, }, }; return out(result)({ type: "realizeAuthorizationWrite", id: (0, uuid_1.v7)(), created_at: new Date().toISOString(), authorization: authorization, acquisition: preliminary.getAcquisition(), metric: result.metric, tokenUsage: result.tokenUsage, completed: props.counter.get(), total: props.progress.total, step: (_b = (_a = ctx.state().test) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 0, }); })); ctx.dispatch(event); const prismaCompiled = (_a = ctx.state().database) === null || _a === void 0 ? void 0 : _a.compiled; const prismaClient = (prismaCompiled === null || prismaCompiled === void 0 ? void 0 : prismaCompiled.type) === "success" ? prismaCompiled.client : {}; return yield (0, orchestrateRealizeAuthorizationCorrect_1.orchestrateRealizeAuthorizationCorrect)(ctx, { template: props.templates, authorization: event.authorization, prismaClient, }); }); } function 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 => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io3 = input => "write" === input.type && ("object" === typeof input.provider && null !== input.provider && _io4(input.provider)) && ("object" === typeof input.decorator && null !== input.decorator && _io5(input.decorator)) && ("object" === typeof input.payload && null !== input.payload && _io6(input.payload)); 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 _io6 = input => "string" === typeof input.name && RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _iu0 = input => (() => { if ("complete" === input.type) return _io1(input); else if ("getDatabaseSchemas" === input.type) return _io2(input); else if ("write" === input.type) return _io3(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: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeAuthorizationWriteApplication.IWrite)", value: input.request })) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, { path: _path + ".request", expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeAuthorizationWriteApplication.IWrite)", 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) => ["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, _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 _vo3 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"write\"", value: input.type }), ("object" === typeof input.provider && null !== input.provider || _report(_exceptionable, { path: _path + ".provider", expected: "IAutoBeRealizeAuthorizationWriteApplication.IProvider", value: input.provider })) && _vo4(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 })) && _vo5(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 })) && _vo6(input.payload, _path + ".payload", true && _exceptionable) || _report(_exceptionable, { path: _path + ".payload", expected: "IAutoBeRealizeAuthorizationWriteApplication.IPayloadType", value: input.payload })].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 & 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 _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 _vo6 = (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 ("complete" === input.type) return _vo1(input, _path, true && _exceptionable); else if ("getDatabaseSchemas" === input.type) return _vo2(input, _path, true && _exceptionable); else if ("write" === input.type) return _vo3(input, _path, true && _exceptionable); else return _report(_exceptionable, { path: _path, expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeAuthorizationWriteApplication.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: "IAutoBeRealizeAuthorizationWriteApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeRealizeAuthorizationWriteApplication.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 === "write") return result; return props.preliminary.validate({ thinking: result.data.thinking, request: result.data.request, }); }; const application = props.preliminary.fixApplication(__typia_transform__llmApplicationFinalize._llmApplicationFinalize({ functions: [ { name: "process", parameters: { description: "Current Type: {@link IAutoBeRealizeAuthorizationWriteApplication.IProps}", type: "object", properties: { thinking: { description: "Think before you act.\n\nFor preliminary requests: what database schemas are missing and why?\n\nFor write: what authentication components you're submitting.\n\nFor complete: why you consider the last write final.", type: "string" }, request: { description: "Action to perform. Exhausted preliminary types are removed from the\nunion, physically preventing repeated calls.", anyOf: [ { $ref: "#/$defs/IAutoBePreliminaryComplete" }, { $ref: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas" }, { $ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IWrite" } ], "x-discriminator": { propertyName: "type", mapping: { complete: "#/$defs/IAutoBePreliminaryComplete", getDatabaseSchemas: "#/$defs/IAutoBePreliminaryGetDatabaseSchemas", write: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.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 request.", type: "string", "enum": [ "complete" ] } }, required: [ "type" ] }, IAutoBePreliminaryGetDatabaseSchemas: { description: "Request to retrieve database schema definitions for context.", type: "object", properties: { type: { description: "Type discriminator.", type: "string", "enum": [ "getDatabaseSchemas" ] }, schemaNames: { description: "Database table names to retrieve. DO NOT request same names already\nrequested in previous calls.", type: "array", items: { type: "string" }, minItems: 1 } }, required: [ "type", "schemaNames" ] }, "IAutoBeRealizeAuthorizationWriteApplication.IWrite": { description: "Request to generate authentication components (provider, decorator,\npayload).", type: "object", properties: { type: { description: "Type discriminator for write submission.", type: "string", "enum": [ "write" ] }, provider: { description: "Authentication Provider function (JWT verification, role validation, DB\nqueries).", $ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IProvider" }, decorator: { description: "Authentication Decorator (NestJS parameter decorator injecting\nauthenticated user data).", $ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IDecorator" }, payload: { description: "Authentication Payload Type (TypeScript type for authenticated user data\nin Controller methods).", $ref: "#/$defs/IAutoBeRealizeAuthorizationWriteApplication.IPayloadType" } }, required: [ "type", "provider", "decorator", "payload" ] }, "IAutoBeRealizeAuthorizationWriteApplication.IProvider": { type: "object", properties: { name: { description: "Provider function name in {role}Authorize format (e.g., adminAuthorize).\nMUST use camelCase.", type: "string", pattern: "^[a-z][a-zA-Z0-9]*$" }, content: { description: "Complete TypeScript code. MUST include: jwtAuthorize call, role type\ncheck, MyGlobal.prisma.{tableName} query,\nForbiddenException/UnauthorizedException handling.", type: "string" } }, required: [ "name", "content" ] }, "IAutoBeRealizeAuthorizationWriteApplication.IDecorator": { type: "object", properties: { name: { description: "Decorator name in {Actor}Auth format (e.g., AdminAuth, UserAuth). MUST\nuse PascalCase.", type: "string", pattern: "^[A-Z][a-zA-Z0-9]*$" }, content: { description: "Complete TypeScript code. MUST include: SwaggerCustomizer integration,\ncreateParamDecorator calling Provider, Singleton pattern via tstl.", type: "string" } }, required: [ "name", "content" ] }, "IAutoBeRealizeAuthorizationWriteApplication.IPayloadType": { type: "object", properties: { name: { description: "Payload type name in {Actor}Payload format (e.g., AdminPayload,\nUserPayload). MUST use PascalCase.", type: "string", pattern: "^[A-Z][a-zA-Z0-9]*$" }, content: { description: "Complete TypeScript code. MUST include: id field with UUID validation,\ntype field as role discriminator, typia tags.", type: "string" } }, required: [ "name", "content" ] } } }, description: "Process authentication generation task.", validate: (() => { 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 => "getDatabaseSchemas" === input.type && (Array.isArray(input.schemaNames) && (1 <= input.schemaNames.length && input.schemaNames.every(elem => "string" === typeof elem))); const _io3 = input => "write" === input.type && ("object" === typeof input.provider && null !== input.provider && _io4(input.provider)) && ("object" === typeof input.decorator && null !== input.decorator && _io5(input.decorator)) && ("object" === typeof input.payload && null !== input.payload && _io6(input.payload)); 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 _io6 = input => "string" === typeof input.name && RegExp("^[A-Z][a-zA-Z0-9]*$").test(input.name) && "string" === typeof input.content; const _iu0 = input => (() => { if ("complete" === input.type) return _io1(input); else if ("getDatabaseSchemas" === input.type) return _io2(input); else if ("write" === input.type) return _io3(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: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeAuthorizationWriteApplication.IWrite)", value: input.request })) && _vu0(input.request, _path + ".request", true && _exceptionable) || _report(_exceptionable, { path: _path + ".request", expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeAuthorizationWriteApplication.IWrite)", 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) => ["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, _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 _vo3 = (input, _path, _exceptionable = true) => ["write" === input.type || _report(_exceptionable, { path: _path + ".type", expected: "\"write\"", value: input.type }), ("object" === typeof input.provider && null !== input.provider || _report(_exceptionable, { path: _path + ".provider", expected: "IAutoBeRealizeAuthorizationWriteApplication.IProvider", value: input.provider })) && _vo4(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 })) && _vo5(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 })) && _vo6(input.payload, _path + ".payload", true && _exceptionable) || _report(_exceptionable, { path: _path + ".payload", expected: "IAutoBeRealizeAuthorizationWriteApplication.IPayloadType", value: input.payload })].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 & 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 _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 _vo6 = (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 ("complete" === input.type) return _vo1(input, _path, true && _exceptionable); else if ("getDatabaseSchemas" === input.type) return _vo2(input, _path, true && _exceptionable); else if ("write" === input.type) return _vo3(input, _path, true && _exceptionable); else return _report(_exceptionable, { path: _path, expected: "(IAutoBePreliminaryComplete | IAutoBePreliminaryGetDatabaseSchemas | IAutoBeRealizeAuthorizationWriteApplication.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: "IAutoBeRealizeAuthorizationWriteApplication.IProps", value: input })) && _vo0(input, _path + "", true) || _report(true, { path: _path + "", expected: "IAutoBeRealizeAuthorizationWriteApplication.IProps", value: input }))(input, "$input", true); const success = 0 === errors.length;