@autobe/agent 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/agent/src/AutoBeAgent.js +2 -2
- package/lib/agent/src/AutoBeAgent.js.map +1 -1
- package/lib/agent/src/constants/AutoBeConfigConstant.d.ts +3 -0
- package/lib/agent/src/{orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js → constants/AutoBeConfigConstant.js} +1 -1
- package/lib/agent/src/constants/AutoBeConfigConstant.js.map +1 -0
- package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +27 -27
- package/lib/agent/src/context/AutoBeContext.d.ts +1 -0
- package/lib/agent/src/context/AutoBeTokenUsageComponent.js +4 -3
- package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
- package/lib/agent/src/factory/consentFunctionCall.js +4 -4
- package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
- package/lib/agent/src/factory/createAutoBeContext.js +13 -10
- package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +2 -2
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +6 -6
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +50 -8
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +4 -4
- package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
- package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
- package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js +1 -1
- package/lib/agent/src/orchestrate/facade/transformFacadeStateMessage.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +19 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +3 -3
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +2 -2
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +2 -2
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +2 -2
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +5 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +16 -10
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +3731 -228
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +2 -2
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +2 -2
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +43 -63
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +1261 -1628
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +3466 -103
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +3672 -358
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
- package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js +1385 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaFactory.js.map +1 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js +78 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaNamingConvention.js.map +1 -0
- package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
- package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js +81 -0
- package/lib/agent/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.js.map +1 -0
- package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +2 -2
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +2 -2
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +2 -2
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +22 -7
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +13 -29
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
- package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js +2 -8
- package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +6 -49
- package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +4 -2
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +5 -3
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +206 -118
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +24 -39
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js +3 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.js.map +1 -0
- package/{src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts → lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts} +2 -13
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js +3 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js +86 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js +55 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteDto.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js +20 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteImportStatements.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js +73 -0
- package/lib/agent/src/orchestrate/realize/utils/getRealizeWriteInputType.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
- package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +63 -69
- package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +15 -14
- package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
- package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js +19 -0
- package/lib/agent/src/orchestrate/test/compile/getTestImportStatements.js.map +1 -0
- package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js +2 -0
- package/lib/agent/src/orchestrate/test/compile/getTestScenarioArtifacts.js.map +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
- package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js +21 -0
- package/lib/agent/src/orchestrate/test/compile/getTestTemplateCode.js.map +1 -0
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +16 -17
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +5 -4
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +21 -2
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -0
- package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +126 -72
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +46 -40
- package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +121 -42
- package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js +3 -0
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.js.map +1 -0
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
- package/lib/agent/src/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
- package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js +28 -0
- package/lib/agent/src/orchestrate/test/utils/getReferenceIds.js.map +1 -0
- package/lib/agent/src/structures/IAutoBeConfig.d.ts +2 -0
- package/lib/constants/AutoBeConfigConstant.d.ts +3 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +27 -27
- package/lib/context/AutoBeContext.d.ts +1 -0
- package/lib/index.mjs +13805 -3871
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +6 -0
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.d.ts +4 -0
- package/lib/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceComplement.d.ts +1 -1
- package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +6 -1
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +0 -38
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +48 -141
- package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +29 -23
- package/lib/orchestrate/interface/utils/JsonSchemaFactory.d.ts +9 -0
- package/lib/orchestrate/interface/utils/JsonSchemaNamingConvention.d.ts +5 -0
- package/lib/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.d.ts +2 -0
- package/lib/orchestrate/prisma/orchestratePrismaCorrect.d.ts +1 -1
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +6 -6
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -8
- package/lib/orchestrate/realize/internal/compileRealizeFiles.d.ts +2 -2
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +13 -6
- package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +2 -2
- package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +2 -2
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +17 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.d.ts +20 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.d.ts +33 -73
- package/lib/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.d.ts +5 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.d.ts +36 -0
- package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +33 -22
- package/lib/orchestrate/realize/utils/getRealizeWriteCodeTemplate.d.ts +31 -0
- package/lib/orchestrate/realize/utils/getRealizeWriteDto.d.ts +4 -0
- package/lib/orchestrate/realize/utils/getRealizeWriteImportStatements.d.ts +2 -0
- package/lib/orchestrate/realize/utils/getRealizeWriteInputType.d.ts +30 -0
- package/lib/orchestrate/realize/utils/replaceImportStatements.d.ts +6 -2
- package/lib/orchestrate/test/compile/getTestImportStatements.d.ts +2 -0
- package/lib/orchestrate/test/compile/getTestScenarioArtifacts.d.ts +1 -1
- package/lib/orchestrate/test/compile/getTestTemplateCode.d.ts +2 -0
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +2 -2
- package/lib/orchestrate/test/orchestrateTestCorrect.d.ts +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +48 -45
- package/lib/orchestrate/test/structures/IAutoBeTestFunctionFailure.d.ts +6 -0
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.d.ts +1 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +13 -0
- package/lib/orchestrate/test/utils/getReferenceIds.d.ts +5 -0
- package/lib/structures/IAutoBeConfig.d.ts +2 -0
- package/package.json +5 -5
- package/src/AutoBeAgent.ts +2 -0
- package/src/constants/AutoBeConfigConstant.ts +3 -0
- package/src/constants/AutoBeSystemPromptConstant.ts +27 -27
- package/src/context/AutoBeContext.ts +1 -0
- package/src/context/AutoBeTokenUsageComponent.ts +3 -3
- package/src/factory/consentFunctionCall.ts +2 -0
- package/src/factory/createAutoBeContext.ts +145 -136
- package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +6 -0
- package/src/orchestrate/analyze/structures/IAutoBeAnalyzeWriteApplication.ts +4 -0
- package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +19 -1
- package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +1 -4
- package/src/orchestrate/interface/orchestrateInterface.ts +15 -4
- package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +13 -5
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +58 -19
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +11 -11
- package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +13 -117
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +33 -91
- package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +72 -95
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +0 -39
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +50 -146
- package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +31 -27
- package/src/orchestrate/interface/utils/JsonSchemaFactory.ts +171 -0
- package/src/orchestrate/interface/utils/JsonSchemaNamingConvention.ts +83 -0
- package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +90 -0
- package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +2 -2
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +1 -2
- package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +30 -15
- package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +27 -49
- package/src/orchestrate/realize/internal/compileRealizeFiles.ts +4 -11
- package/src/orchestrate/realize/orchestrateRealize.ts +19 -75
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +1 -1
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +114 -25
- package/src/orchestrate/realize/orchestrateRealizeScenario.ts +2 -2
- package/src/orchestrate/realize/orchestrateRealizeWrite.ts +11 -15
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +17 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationCorrectApplication.ts +20 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.ts +40 -74
- package/src/orchestrate/realize/structures/IAutoBeRealizeFunctionFailure.ts +9 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioResult.ts +45 -0
- package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +33 -22
- package/src/orchestrate/realize/utils/getRealizeWriteCodeTemplate.ts +97 -0
- package/src/orchestrate/realize/utils/getRealizeWriteDto.ts +64 -0
- package/src/orchestrate/realize/utils/getRealizeWriteImportStatements.ts +29 -0
- package/src/orchestrate/realize/utils/getRealizeWriteInputType.ts +82 -0
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +101 -111
- package/src/orchestrate/test/compile/completeTestCode.ts +15 -26
- package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +1 -0
- package/src/orchestrate/test/compile/getTestImportStatements.ts +25 -0
- package/src/orchestrate/test/compile/getTestScenarioArtifacts.ts +6 -1
- package/src/orchestrate/test/compile/getTestTemplateCode.ts +25 -0
- package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +26 -26
- package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +6 -5
- package/src/orchestrate/test/histories/transformTestWriteHistories.ts +19 -0
- package/src/orchestrate/test/orchestrateTest.ts +6 -0
- package/src/orchestrate/test/orchestrateTestCorrect.ts +46 -15
- package/src/orchestrate/test/orchestrateTestScenario.ts +52 -48
- package/src/orchestrate/test/orchestrateTestWrite.ts +23 -5
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +49 -46
- package/src/orchestrate/test/structures/IAutoBeTestFunctionFailure.ts +8 -0
- package/src/orchestrate/test/structures/IAutoBeTestScenarioArtifacts.ts +1 -0
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +14 -0
- package/src/orchestrate/test/utils/getReferenceIds.ts +25 -0
- package/src/structures/IAutoBeConfig.ts +3 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.js.map +0 -1
- package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import { IAutoBeRealizeAuthorizationApplication } from "./IAutoBeRealizeAuthorizationApplication";
|
|
2
2
|
|
|
3
3
|
export interface IAutoBeRealizeAuthorizationCorrectApplication {
|
|
4
|
+
/**
|
|
5
|
+
* Corrects TypeScript compilation errors in authentication components.
|
|
6
|
+
*
|
|
7
|
+
* This method analyzes and fixes compilation errors in previously generated
|
|
8
|
+
* authentication provider, decorator, and payload type implementations. It
|
|
9
|
+
* performs systematic error diagnosis and generates corrected versions of
|
|
10
|
+
* all three components while maintaining their interconnected functionality.
|
|
11
|
+
*
|
|
12
|
+
* The correction process includes:
|
|
13
|
+
* - TypeScript error analysis and categorization by component
|
|
14
|
+
* - Identification of type mismatches, import issues, and syntax errors
|
|
15
|
+
* - Clear solution guidance for each identified problem
|
|
16
|
+
* - Regeneration of all components with fixes applied
|
|
17
|
+
*
|
|
18
|
+
* The corrected components maintain the same naming conventions and
|
|
19
|
+
* architectural patterns as the original generation while resolving all
|
|
20
|
+
* compilation issues.
|
|
21
|
+
*
|
|
22
|
+
* @param next Properties containing error analysis, solution guidance, and corrected components
|
|
23
|
+
*/
|
|
4
24
|
correctDecorator: (
|
|
5
25
|
next: IAutoBeRealizeAuthorizationCorrectApplication.IProps,
|
|
6
26
|
) => void;
|
|
@@ -1,81 +1,47 @@
|
|
|
1
|
-
import { IAutoBeRealizeWriteApplication } from "./IAutoBeRealizeWriteApplication";
|
|
2
|
-
|
|
3
1
|
export interface IAutoBeRealizeCorrectApplication {
|
|
2
|
+
/**
|
|
3
|
+
* Reviews and corrects TypeScript compilation errors.
|
|
4
|
+
*
|
|
5
|
+
* Fixes TypeScript compilation errors while preserving original business
|
|
6
|
+
* logic, applying minimal intervention principle.
|
|
7
|
+
*
|
|
8
|
+
* @param props Properties containing the multi-phase error correction process
|
|
9
|
+
*/
|
|
4
10
|
review: (props: IAutoBeRealizeCorrectApplication.IProps) => void;
|
|
5
11
|
}
|
|
6
12
|
|
|
7
13
|
export namespace IAutoBeRealizeCorrectApplication {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
* - Identification of assumed fields that don't exist
|
|
41
|
-
* - Correct field types and relationships
|
|
42
|
-
*
|
|
43
|
-
* ⚠️ COMMON ERROR PATTERNS TO CHECK:
|
|
44
|
-
*
|
|
45
|
-
* - Using non-existent fields (e.g., deleted_at, created_by)
|
|
46
|
-
* - Type mismatches in Prisma operations
|
|
47
|
-
* - Incorrect date handling (using Date instead of string)
|
|
48
|
-
* - Missing required fields in create/update operations
|
|
49
|
-
* - Incorrect relation handling in nested operations
|
|
50
|
-
*
|
|
51
|
-
* 🎯 CORRECTION APPROACH:
|
|
52
|
-
*
|
|
53
|
-
* - Remove references to non-existent fields
|
|
54
|
-
* - Fix type conversions (especially dates with toISOStringSafe())
|
|
55
|
-
* - Simplify complex nested operations into separate queries
|
|
56
|
-
* - Add missing required fields
|
|
57
|
-
* - Use correct Prisma input types
|
|
58
|
-
*
|
|
59
|
-
* Example structure:
|
|
60
|
-
*
|
|
61
|
-
* Errors Found:
|
|
62
|
-
* 1. TS2339: Property 'deleted_at' does not exist on type 'User'
|
|
63
|
-
* - Cause: Field assumed but not in schema
|
|
64
|
-
* - Fix: Remove all deleted_at references
|
|
65
|
-
*
|
|
66
|
-
* 2. TS2345: Type 'Date' is not assignable to type 'string'
|
|
67
|
-
* - Cause: Direct Date assignment without conversion
|
|
68
|
-
* - Fix: Use toISOStringSafe() for all date values
|
|
69
|
-
*
|
|
70
|
-
* Resolution Plan:
|
|
71
|
-
* 1. First, remove all non-existent field references
|
|
72
|
-
* 2. Then, fix all date type conversions
|
|
73
|
-
* 3. Finally, adjust Prisma query structures
|
|
74
|
-
*
|
|
75
|
-
* This analysis ensures the review process addresses all compilation errors
|
|
76
|
-
* systematically and produces error-free code in the corrected
|
|
77
|
-
* implementation.
|
|
78
|
-
*/
|
|
79
|
-
errorAnalysis: string;
|
|
14
|
+
/**
|
|
15
|
+
* Properties for error correction following Chain of Thinking (CoT).
|
|
16
|
+
*
|
|
17
|
+
* All phases are wrapped in a `revise` object for systematic error
|
|
18
|
+
* resolution.
|
|
19
|
+
*/
|
|
20
|
+
export interface IProps {
|
|
21
|
+
/** Revision process containing all error correction phases. */
|
|
22
|
+
revise: IRevise;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IRevise {
|
|
26
|
+
/** Step 1: Compilation error analysis and resolution strategy. */
|
|
27
|
+
errorAnalysis?: string;
|
|
28
|
+
|
|
29
|
+
/** Step 2: Provider function implementation plan. */
|
|
30
|
+
plan?: string;
|
|
31
|
+
|
|
32
|
+
/** Step 3: Relevant Prisma schema definitions. */
|
|
33
|
+
prismaSchemas?: string;
|
|
34
|
+
|
|
35
|
+
/** Step 4: Initial draft without using native Date type. */
|
|
36
|
+
draftWithoutDateType?: string;
|
|
37
|
+
|
|
38
|
+
/** Step 5: Refined version with improved completeness. */
|
|
39
|
+
review?: string;
|
|
40
|
+
|
|
41
|
+
/** Step 6: Corrected implementation after compiler feedback. */
|
|
42
|
+
withCompilerFeedback?: string;
|
|
43
|
+
|
|
44
|
+
/** Step 7: Final complete TypeScript function implementation. */
|
|
45
|
+
implementationCode: string;
|
|
80
46
|
}
|
|
81
47
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AutoBeOpenApi,
|
|
3
|
+
AutoBeRealizeAuthorization,
|
|
4
|
+
AutoBeTestFile,
|
|
5
|
+
} from "@autobe/interface";
|
|
6
|
+
|
|
7
|
+
export interface IAutoBeRealizeScenarioResult {
|
|
8
|
+
/** The OpenAPI operation to be realized. */
|
|
9
|
+
operation: AutoBeOpenApi.IOperation;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The name of the function to be generated.
|
|
13
|
+
*
|
|
14
|
+
* Derived from the Swagger path and method. The function name must be
|
|
15
|
+
* written in snake_case. It serves as the entry point in both code
|
|
16
|
+
* generation and test code.
|
|
17
|
+
*
|
|
18
|
+
* Once the function is generated, the function name and file name will be
|
|
19
|
+
* the same. The generated file will be located at
|
|
20
|
+
* `src/providers/${function_name}.ts`.
|
|
21
|
+
*/
|
|
22
|
+
functionName: string;
|
|
23
|
+
|
|
24
|
+
/** For example, `src/providers/${function_name}.ts`. */
|
|
25
|
+
location: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* List of scenario descriptions for test code generation.
|
|
29
|
+
*
|
|
30
|
+
* Each scenario describes the expected behavior of the function under
|
|
31
|
+
* certain conditions. Used as a basis for TDD-style automated test
|
|
32
|
+
* generation.
|
|
33
|
+
*/
|
|
34
|
+
testFiles: AutoBeTestFile[];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Optional decorator event for customizing code generation behavior.
|
|
38
|
+
*
|
|
39
|
+
* Provides additional metadata or instructions that can modify how the
|
|
40
|
+
* function implementation is generated. Can include custom annotations,
|
|
41
|
+
* middleware configurations, or special handling directives that affect the
|
|
42
|
+
* final code output.
|
|
43
|
+
*/
|
|
44
|
+
decoratorEvent?: AutoBeRealizeAuthorization;
|
|
45
|
+
}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
export interface IAutoBeRealizeWriteApplication {
|
|
2
|
+
/**
|
|
3
|
+
* Generates provider function implementation through multi-phase development.
|
|
4
|
+
*
|
|
5
|
+
* This method implements a systematic approach to generate NestJS provider
|
|
6
|
+
* functions that handle business logic for API operations. It follows a
|
|
7
|
+
* schema-first approach with multiple refinement phases to ensure type-safe,
|
|
8
|
+
* error-free code generation.
|
|
9
|
+
*
|
|
10
|
+
* The generation process includes:
|
|
11
|
+
* 1. Strategic planning based on Prisma schema analysis
|
|
12
|
+
* 2. Initial draft without Date type usage
|
|
13
|
+
* 3. Review and refinement for completeness
|
|
14
|
+
* 4. Compiler feedback integration if errors detected
|
|
15
|
+
* 5. Final implementation with all validations and type safety
|
|
16
|
+
*
|
|
17
|
+
* @param next Properties containing the multi-phase implementation plan and code
|
|
18
|
+
*/
|
|
2
19
|
coding: (next: IAutoBeRealizeWriteApplication.IProps) => void;
|
|
3
20
|
}
|
|
4
21
|
|
|
5
22
|
export namespace IAutoBeRealizeWriteApplication {
|
|
23
|
+
/**
|
|
24
|
+
* Properties for the Realize Write Application following Chain of Thinking (CoT).
|
|
25
|
+
*
|
|
26
|
+
* Each field represents a distinct phase in the reasoning and implementation process,
|
|
27
|
+
* building upon the previous step to create a complete, error-free implementation.
|
|
28
|
+
* This structured approach ensures clarity, debuggability, and systematic thinking.
|
|
29
|
+
*/
|
|
6
30
|
export interface IProps {
|
|
7
31
|
/**
|
|
8
|
-
* Step 1
|
|
32
|
+
* Step 1 - Planning Phase (CoT: Initial Reasoning)
|
|
9
33
|
*
|
|
10
34
|
* 🧠 Provider Function Implementation Plan
|
|
11
35
|
*
|
|
@@ -22,12 +46,14 @@ export namespace IAutoBeRealizeWriteApplication {
|
|
|
22
46
|
* - Examine the actual Prisma schema model definition
|
|
23
47
|
* - List EVERY field that exists in the model with exact types
|
|
24
48
|
* - Explicitly note fields that DO NOT exist
|
|
49
|
+
* - Verify database compatibility (PostgreSQL AND SQLite)
|
|
25
50
|
*
|
|
26
51
|
* DO NOT:
|
|
27
52
|
*
|
|
28
53
|
* - Assume common fields exist without verification
|
|
29
54
|
* - Use fields like deleted_at, created_by, updated_by, is_deleted, is_active
|
|
30
55
|
* without checking
|
|
56
|
+
* - Use PostgreSQL-specific features like mode: "insensitive"
|
|
31
57
|
*
|
|
32
58
|
* 📋 STEP 2 - FIELD INVENTORY:
|
|
33
59
|
*
|
|
@@ -136,7 +162,7 @@ export namespace IAutoBeRealizeWriteApplication {
|
|
|
136
162
|
plan: string;
|
|
137
163
|
|
|
138
164
|
/**
|
|
139
|
-
* Step 2
|
|
165
|
+
* Step 2 - Schema Definition (CoT: Context Establishment)
|
|
140
166
|
*
|
|
141
167
|
* The Prisma schema string that will be used to validate the implementation
|
|
142
168
|
* logic in this file.
|
|
@@ -158,7 +184,7 @@ export namespace IAutoBeRealizeWriteApplication {
|
|
|
158
184
|
prisma_schemas: string;
|
|
159
185
|
|
|
160
186
|
/**
|
|
161
|
-
* Step 3
|
|
187
|
+
* Step 3 - Initial Draft (CoT: First Implementation Attempt)
|
|
162
188
|
*
|
|
163
189
|
* Draft WITHOUT using native Date type.
|
|
164
190
|
*
|
|
@@ -195,7 +221,7 @@ export namespace IAutoBeRealizeWriteApplication {
|
|
|
195
221
|
draft_without_date_type: string;
|
|
196
222
|
|
|
197
223
|
/**
|
|
198
|
-
* Step 4
|
|
224
|
+
* Step 4 - Review and Refinement (CoT: Self-Reflection)
|
|
199
225
|
*
|
|
200
226
|
* A refined version of the draft with improved completeness.
|
|
201
227
|
*
|
|
@@ -209,29 +235,13 @@ export namespace IAutoBeRealizeWriteApplication {
|
|
|
209
235
|
* - Avoid unsafe `as` casts unless only for branding or literal narrowing.
|
|
210
236
|
* - Use `toISOStringSafe()` for all date conversions (NOT `.toISOString()`).
|
|
211
237
|
* - Ensure all object keys strictly conform to the expected type definitions.
|
|
238
|
+
* - NEVER use `mode: "insensitive"` in string operations (breaks SQLite).
|
|
212
239
|
*/
|
|
213
240
|
review: string;
|
|
214
241
|
|
|
215
|
-
/**
|
|
216
|
-
* 🛠 Phase 4-2: With compiler feedback (optional)
|
|
217
|
-
*
|
|
218
|
-
* A correction pass that applies fixes for compile-time errors that arose
|
|
219
|
-
* during the review stage (if any).
|
|
220
|
-
*
|
|
221
|
-
* ✅ Must:
|
|
222
|
-
*
|
|
223
|
-
* - Only include this field if TypeScript errors are detected in the Review
|
|
224
|
-
* phase.
|
|
225
|
-
* - Resolve all TypeScript errors without using `as any`.
|
|
226
|
-
* - Provide safe brand casting only if required (e.g., `as string &
|
|
227
|
-
* tags.Format<'uuid'>`).
|
|
228
|
-
* - If no TypeScript errors exist, this field MUST contain the text: "No
|
|
229
|
-
* TypeScript errors detected - skipping this phase"
|
|
230
|
-
*/
|
|
231
|
-
withCompilerFeedback: string;
|
|
232
242
|
|
|
233
243
|
/**
|
|
234
|
-
* Step 5
|
|
244
|
+
* Step 5 - Complete Implementation (CoT: Final Synthesis)
|
|
235
245
|
*
|
|
236
246
|
* The complete and fully correct TypeScript function implementation.
|
|
237
247
|
*
|
|
@@ -243,6 +253,7 @@ export namespace IAutoBeRealizeWriteApplication {
|
|
|
243
253
|
* - Uses only allowed imports (e.g., from `../api/structures` and
|
|
244
254
|
* `MyGlobal.prisma`).
|
|
245
255
|
* - NEVER creates intermediate variables for Prisma operations.
|
|
256
|
+
* - NEVER uses `mode: "insensitive"` (PostgreSQL-only, breaks SQLite).
|
|
246
257
|
*
|
|
247
258
|
* ⚠️ Fallback Behavior:
|
|
248
259
|
*
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
|
|
2
|
+
import { StringUtil } from "@autobe/utils";
|
|
3
|
+
|
|
4
|
+
import { IAutoBeRealizeScenarioResult } from "../structures/IAutoBeRealizeScenarioResult";
|
|
5
|
+
import { getRealizeWriteImportStatements } from "./getRealizeWriteImportStatements";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generate a TypeScript function template for the Realize Agent to complete
|
|
9
|
+
*
|
|
10
|
+
* This utility creates a function skeleton with proper imports, parameters, and
|
|
11
|
+
* return type that the AI needs to implement. The template includes:
|
|
12
|
+
*
|
|
13
|
+
* - Import statements for required dependencies
|
|
14
|
+
* - Function signature with all parameters
|
|
15
|
+
* - Return type specification
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Returns a template like:
|
|
19
|
+
* ```typescript
|
|
20
|
+
* import { MyGlobal } from "../MyGlobal";
|
|
21
|
+
* // ... other imports
|
|
22
|
+
*
|
|
23
|
+
* async function post__users_create(
|
|
24
|
+
* body: IUserCreateRequest
|
|
25
|
+
* ): Promise<IUserResponse> {
|
|
26
|
+
* ...
|
|
27
|
+
* }
|
|
28
|
+
* ```;
|
|
29
|
+
*
|
|
30
|
+
* @param scenario - The realize scenario containing function metadata
|
|
31
|
+
* @param operation - OpenAPI operation definition
|
|
32
|
+
* @param authorization - Authorization context if endpoint is authenticated
|
|
33
|
+
* @returns Complete TypeScript code template as a formatted string
|
|
34
|
+
*/
|
|
35
|
+
export function getRealizeWriteCodeTemplate(
|
|
36
|
+
scenario: IAutoBeRealizeScenarioResult,
|
|
37
|
+
operation: AutoBeOpenApi.IOperation,
|
|
38
|
+
authorization: AutoBeRealizeAuthorization | null,
|
|
39
|
+
): string {
|
|
40
|
+
// Collect all function parameters in order
|
|
41
|
+
const functionParameters: string[] = [];
|
|
42
|
+
|
|
43
|
+
// Add authentication parameter if needed (e.g., user: IUser, admin: IAdmin)
|
|
44
|
+
if (authorization && authorization.role.name) {
|
|
45
|
+
// Debug: Log the values to check what's being used
|
|
46
|
+
const authParameter = `${authorization.role.name}: ${authorization.payload.name}`;
|
|
47
|
+
functionParameters.push(authParameter);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Add path parameters (e.g., id, postId, etc.)
|
|
51
|
+
const pathParameters = operation.parameters.map((param) => {
|
|
52
|
+
const paramType = param.schema.type;
|
|
53
|
+
const paramFormat =
|
|
54
|
+
"format" in param.schema
|
|
55
|
+
? ` & tags.Format<'${param.schema.format}'>`
|
|
56
|
+
: "";
|
|
57
|
+
return `${param.name}: ${paramType}${paramFormat}`;
|
|
58
|
+
});
|
|
59
|
+
functionParameters.push(...pathParameters);
|
|
60
|
+
|
|
61
|
+
// Add request body parameter if present
|
|
62
|
+
if (operation.requestBody?.typeName) {
|
|
63
|
+
const bodyParameter = `body: ${operation.requestBody.typeName}`;
|
|
64
|
+
functionParameters.push(bodyParameter);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Format parameters for props object
|
|
68
|
+
const hasParameters = functionParameters.length > 0;
|
|
69
|
+
|
|
70
|
+
let formattedSignature: string;
|
|
71
|
+
if (hasParameters) {
|
|
72
|
+
const propsFields = functionParameters
|
|
73
|
+
.map((param) => ` ${param}`)
|
|
74
|
+
.join(";\n");
|
|
75
|
+
|
|
76
|
+
formattedSignature = `props: {\n${propsFields};\n}`;
|
|
77
|
+
} else {
|
|
78
|
+
formattedSignature = "";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Determine return type
|
|
82
|
+
const returnType = operation.responseBody?.typeName ?? "void";
|
|
83
|
+
|
|
84
|
+
// Generate the complete template
|
|
85
|
+
return StringUtil.trim`
|
|
86
|
+
Complete the code below, disregard the import part and return only the function part.
|
|
87
|
+
|
|
88
|
+
\`\`\`typescript
|
|
89
|
+
${getRealizeWriteImportStatements(operation).join("\n")}
|
|
90
|
+
|
|
91
|
+
// ONLY YOU HAVE TO WRITE THIS, AND USE IMPORTED.
|
|
92
|
+
export async function ${scenario.functionName}(${formattedSignature}): Promise<${returnType}> {
|
|
93
|
+
...
|
|
94
|
+
}
|
|
95
|
+
\`\`\`
|
|
96
|
+
`;
|
|
97
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AutoBeOpenApi, IAutoBeCompiler } from "@autobe/interface";
|
|
2
|
+
import { ILlmSchema, OpenApiTypeChecker } from "@samchon/openapi";
|
|
3
|
+
|
|
4
|
+
import { AutoBeContext } from "../../../context/AutoBeContext";
|
|
5
|
+
|
|
6
|
+
export async function getRealizeWriteDto<Model extends ILlmSchema.Model>(
|
|
7
|
+
ctx: AutoBeContext<Model>,
|
|
8
|
+
operation: AutoBeOpenApi.IOperation,
|
|
9
|
+
): Promise<Record<string, string>> {
|
|
10
|
+
const document: AutoBeOpenApi.IDocument = filterDocument(
|
|
11
|
+
operation,
|
|
12
|
+
ctx.state().interface!.document,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const compiler: IAutoBeCompiler = await ctx.compiler();
|
|
16
|
+
const entries: [string, string][] = Object.entries(
|
|
17
|
+
await compiler.interface.write(document),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const filter = (prefix: string, exclude?: string) => {
|
|
21
|
+
const result: [string, string][] = entries.filter(
|
|
22
|
+
([key]) => key.startsWith(prefix) === true,
|
|
23
|
+
);
|
|
24
|
+
return Object.fromEntries(
|
|
25
|
+
exclude
|
|
26
|
+
? result.filter(([key]) => key.startsWith(exclude) === false)
|
|
27
|
+
: result,
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const dto: Record<string, string> = filter("src/api/structures");
|
|
32
|
+
return dto;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function filterDocument(
|
|
36
|
+
operation: AutoBeOpenApi.IOperation,
|
|
37
|
+
document: AutoBeOpenApi.IDocument,
|
|
38
|
+
): AutoBeOpenApi.IDocument {
|
|
39
|
+
const components: AutoBeOpenApi.IComponents = {
|
|
40
|
+
authorization: document.components.authorization,
|
|
41
|
+
schemas: {},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const visit = (typeName: string) => {
|
|
45
|
+
OpenApiTypeChecker.visit({
|
|
46
|
+
components: document.components,
|
|
47
|
+
schema: { $ref: `#/components/schemas/${typeName}` },
|
|
48
|
+
closure: (s) => {
|
|
49
|
+
if (OpenApiTypeChecker.isReference(s)) {
|
|
50
|
+
const key: string = s.$ref.split("/").pop()!;
|
|
51
|
+
components.schemas[key] = document.components.schemas[key];
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (operation.requestBody) visit(operation.requestBody.typeName);
|
|
58
|
+
if (operation.responseBody) visit(operation.responseBody.typeName);
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
operations: [operation],
|
|
62
|
+
components,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
|
|
3
|
+
export function getRealizeWriteImportStatements(
|
|
4
|
+
operation: AutoBeOpenApi.IOperation,
|
|
5
|
+
) {
|
|
6
|
+
const typeReferences: string[] = Array.from(
|
|
7
|
+
new Set(
|
|
8
|
+
[operation.requestBody, operation.responseBody]
|
|
9
|
+
.filter((el) => el !== null)
|
|
10
|
+
.map((el) => el.typeName.split(".")[0]!),
|
|
11
|
+
),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
// Build the standard imports
|
|
15
|
+
const imports = [
|
|
16
|
+
'import jwt from "jsonwebtoken";',
|
|
17
|
+
'import { MyGlobal } from "../MyGlobal";',
|
|
18
|
+
'import typia, { tags } from "typia";',
|
|
19
|
+
'import { Prisma } from "@prisma/client";',
|
|
20
|
+
'import { v4 } from "uuid";',
|
|
21
|
+
'import { toISOStringSafe } from "../util/toISOStringSafe"',
|
|
22
|
+
...typeReferences.map(
|
|
23
|
+
(ref) =>
|
|
24
|
+
`import { ${ref} } from "@ORGANIZATION/PROJECT-api/lib/structures/${ref}";`,
|
|
25
|
+
),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
return imports;
|
|
29
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { AutoBeOpenApi, AutoBeRealizeAuthorization } from "@autobe/interface";
|
|
2
|
+
import { StringUtil } from "@autobe/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Generate TypeScript type definition string for provider function props
|
|
6
|
+
*
|
|
7
|
+
* This utility creates the exact props interface that the Realize Agent's
|
|
8
|
+
* generated provider functions must accept. It combines:
|
|
9
|
+
*
|
|
10
|
+
* - Authentication context (user/admin/member from authorization)
|
|
11
|
+
* - URL path parameters (e.g., id, boardId, postId)
|
|
12
|
+
* - Request body type (if applicable)
|
|
13
|
+
*
|
|
14
|
+
* The output is injected into REALIZE_WRITE_ARTIFACT.md template to tell the AI
|
|
15
|
+
* exactly what parameter type the function should accept.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // For DELETE /posts/:id (authenticated)
|
|
19
|
+
* // Returns: "props: { user: IUser; id: string & tags.Format<'uuid'>; }"
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // For GET /public/info (no auth, no params)
|
|
23
|
+
* // Returns: "// No props parameter needed - function should have no parameters"
|
|
24
|
+
*
|
|
25
|
+
* @param operation - OpenAPI operation definition containing parameters and
|
|
26
|
+
* auth requirements
|
|
27
|
+
* @param authorization - Authorization context with user/role information (if
|
|
28
|
+
* authenticated endpoint)
|
|
29
|
+
* @returns TypeScript interface string like "props: { user: IUser; id: string;
|
|
30
|
+
* body: IRequest; }"
|
|
31
|
+
*/
|
|
32
|
+
export function getRealizeWriteInputType(
|
|
33
|
+
operation: AutoBeOpenApi.IOperation,
|
|
34
|
+
authorization: AutoBeRealizeAuthorization | null,
|
|
35
|
+
): string {
|
|
36
|
+
const functionParameterFields: string[] = [];
|
|
37
|
+
|
|
38
|
+
// Add authentication field (user/admin/member) if endpoint requires auth
|
|
39
|
+
const hasAuthentication = authorization && operation.authorizationRole;
|
|
40
|
+
if (hasAuthentication) {
|
|
41
|
+
const authFieldName = operation.authorizationRole;
|
|
42
|
+
const authFieldType = authorization.payload.name;
|
|
43
|
+
functionParameterFields.push(`${authFieldName}: ${authFieldType};`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Add URL path parameters (e.g., /posts/:id → id parameter)
|
|
47
|
+
const pathParameters = operation.parameters;
|
|
48
|
+
pathParameters.forEach((pathParam) => {
|
|
49
|
+
const paramName = pathParam.name;
|
|
50
|
+
const paramType = pathParam.schema.type;
|
|
51
|
+
const paramFormat =
|
|
52
|
+
"format" in pathParam.schema
|
|
53
|
+
? ` & tags.Format<'${pathParam.schema.format}'>`
|
|
54
|
+
: "";
|
|
55
|
+
|
|
56
|
+
const parameterField = `${paramName}: ${paramType}${paramFormat};`;
|
|
57
|
+
functionParameterFields.push(parameterField);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Add request body if present (POST/PUT/PATCH operations)
|
|
61
|
+
const hasRequestBody = operation.requestBody?.typeName;
|
|
62
|
+
if (hasRequestBody) {
|
|
63
|
+
const bodyTypeName = operation.requestBody?.typeName;
|
|
64
|
+
functionParameterFields.push(`body: ${bodyTypeName};`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Format as TypeScript props interface or indicate no parameters needed
|
|
68
|
+
const hasParameters = functionParameterFields.length > 0;
|
|
69
|
+
|
|
70
|
+
if (!hasParameters) {
|
|
71
|
+
return `// No props parameter needed - function should have no parameters`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const formattedFields = functionParameterFields
|
|
75
|
+
.map((field) => ` ${field}`)
|
|
76
|
+
.join("\n");
|
|
77
|
+
|
|
78
|
+
return StringUtil.trim`
|
|
79
|
+
props: {
|
|
80
|
+
${formattedFields}
|
|
81
|
+
}`;
|
|
82
|
+
}
|