@autobe/agent 0.21.0 → 0.22.1
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 +3468 -105
- 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 +3674 -360
- 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/JsonSchemaValidator.d.ts +10 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.js +59 -0
- package/lib/agent/src/orchestrate/interface/utils/JsonSchemaValidator.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/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.d.ts +3 -1
- package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +25 -18
- package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js +5 -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 +123 -75
- 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 +117 -45
- 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 +13871 -3912
- 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/JsonSchemaValidator.d.ts +10 -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/completeTestCode.d.ts +3 -1
- 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 +6 -6
- 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 +35 -93
- package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +74 -97
- 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/JsonSchemaValidator.ts +66 -0
- package/src/orchestrate/interface/utils/fulfillJsonSchemaErrorMessages.ts +90 -0
- 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 +18 -31
- package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +12 -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 +44 -20
- package/src/orchestrate/test/orchestrateTestScenario.ts +52 -48
- package/src/orchestrate/test/orchestrateTestWrite.ts +20 -10
- 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/interface/utils/validateAuthorizationSchema.d.ts +0 -7
- package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js +0 -35
- package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +0 -1
- 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/interface/utils/validateAuthorizationSchema.d.ts +0 -7
- package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +0 -38
- package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +0 -41
|
@@ -91,45 +91,6 @@ export namespace IAutoBeInterfaceOperationApplication {
|
|
|
91
91
|
AutoBeOpenApi.IOperation,
|
|
92
92
|
"authorizationRole" | "authorizationType"
|
|
93
93
|
> {
|
|
94
|
-
/**
|
|
95
|
-
* Prisma schema models relevant to this operation.
|
|
96
|
-
*
|
|
97
|
-
* Contains the complete Prisma schema definitions for all entities involved
|
|
98
|
-
* in this operation, including their fields, relations, and database
|
|
99
|
-
* constraints. This enables comprehensive validation and schema-aware
|
|
100
|
-
* operation design.
|
|
101
|
-
*
|
|
102
|
-
* The schema information serves multiple critical purposes:
|
|
103
|
-
*
|
|
104
|
-
* - **Field Verification**: Ensures all referenced fields actually exist in
|
|
105
|
-
* the database schema and have the correct types
|
|
106
|
-
* - **Relationship Validation**: Confirms that entity relationships are
|
|
107
|
-
* properly defined and can support the operation's data access patterns
|
|
108
|
-
* - **Soft-Delete Detection**: For DELETE operations, identifies whether
|
|
109
|
-
* entities have soft-delete fields (deleted_at, is_deleted, etc.) to
|
|
110
|
-
* determine if the operation should perform logical deletion instead of
|
|
111
|
-
* physical removal
|
|
112
|
-
* - **Constraint Awareness**: Understands unique constraints, required
|
|
113
|
-
* fields, and default values to generate accurate request/response
|
|
114
|
-
* schemas
|
|
115
|
-
*
|
|
116
|
-
* Example content might include:
|
|
117
|
-
*
|
|
118
|
-
* ```prisma
|
|
119
|
-
* model User {
|
|
120
|
-
* id String @id @default(uuid())
|
|
121
|
-
* email String @unique
|
|
122
|
-
* name String
|
|
123
|
-
* deleted_at DateTime? // Indicates soft-delete capability
|
|
124
|
-
* posts Post[]
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
127
|
-
*
|
|
128
|
-
* This schema context ensures operations are fully aligned with the actual
|
|
129
|
-
* database structure and business logic requirements.
|
|
130
|
-
*/
|
|
131
|
-
prisma_schemas: string;
|
|
132
|
-
|
|
133
94
|
/**
|
|
134
95
|
* Authorization roles required to access this API operation.
|
|
135
96
|
*
|
|
@@ -5,19 +5,21 @@ import { AutoBeOpenApi } from "@autobe/interface";
|
|
|
5
5
|
*
|
|
6
6
|
* Provides functionality to systematically review generated API operations
|
|
7
7
|
* against business requirements, technical specifications, and OpenAPI
|
|
8
|
-
* standards. The review process
|
|
9
|
-
*
|
|
8
|
+
* standards. The review process outputs a structured thinking process with
|
|
9
|
+
* analytical findings and actionable improvements, along with the final
|
|
10
|
+
* enhanced operations ready for implementation.
|
|
10
11
|
*/
|
|
11
12
|
export interface IAutoBeInterfaceOperationsReviewApplication {
|
|
12
13
|
/**
|
|
13
14
|
* Reviews a batch of API operations for quality and correctness.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Analyzes operations for security vulnerabilities, schema compliance,
|
|
17
|
+
* logical consistency, and standard adherence. Outputs a structured thinking
|
|
18
|
+
* process containing review findings and improvement plans, plus the final
|
|
19
|
+
* production-ready operations with all critical issues resolved.
|
|
18
20
|
*
|
|
19
|
-
* @param input
|
|
20
|
-
*
|
|
21
|
+
* @param input Properties containing the thinking process (review & plan)
|
|
22
|
+
* and the enhanced operations content
|
|
21
23
|
*/
|
|
22
24
|
reviewOperations(
|
|
23
25
|
input: IAutoBeInterfaceOperationsReviewApplication.IProps,
|
|
@@ -33,6 +35,47 @@ export namespace IAutoBeInterfaceOperationsReviewApplication {
|
|
|
33
35
|
* of the AutoBeInterfaceOperationsReviewEvent.
|
|
34
36
|
*/
|
|
35
37
|
export interface IProps {
|
|
38
|
+
/**
|
|
39
|
+
* Comprehensive thinking process for API operation review.
|
|
40
|
+
*
|
|
41
|
+
* Encapsulates the agent's analytical review findings and actionable
|
|
42
|
+
* improvement plan. This structured thinking process ensures systematic
|
|
43
|
+
* evaluation of API operations against AutoBE's quality standards before
|
|
44
|
+
* generating the final enhanced operations.
|
|
45
|
+
*/
|
|
46
|
+
think: IThink;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Production-ready operations with all critical issues resolved.
|
|
50
|
+
*
|
|
51
|
+
* Final API operations after systematic enhancement:
|
|
52
|
+
*
|
|
53
|
+
* - **Security Fixes Applied**: All authentication boundaries enforced,
|
|
54
|
+
* sensitive data removed from responses, proper authorization
|
|
55
|
+
* implemented
|
|
56
|
+
* - **Logic Corrections Made**: Return types match operation intent, HTTP
|
|
57
|
+
* methods align with semantics, parameters properly utilized
|
|
58
|
+
* - **Schema Alignment Verified**: All fields exist in Prisma schema, types
|
|
59
|
+
* correctly mapped, relationships properly defined
|
|
60
|
+
* - **Quality Improvements Added**: Enhanced documentation, format
|
|
61
|
+
* specifications, validation rules, consistent naming patterns
|
|
62
|
+
*
|
|
63
|
+
* If no issues were found during review, this contains the exact original
|
|
64
|
+
* operations unchanged. These operations are validated and ready for schema
|
|
65
|
+
* generation and subsequent implementation phases.
|
|
66
|
+
*/
|
|
67
|
+
content: AutoBeOpenApi.IOperation[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Structured thinking process for comprehensive API operation review.
|
|
72
|
+
*
|
|
73
|
+
* Combines analytical review findings with actionable improvement planning
|
|
74
|
+
* to guide the systematic enhancement of API operations. This thinking
|
|
75
|
+
* structure ensures all aspects of API quality are evaluated and addressed
|
|
76
|
+
* before producing the final operations.
|
|
77
|
+
*/
|
|
78
|
+
export interface IThink {
|
|
36
79
|
/**
|
|
37
80
|
* Comprehensive review analysis with prioritized findings.
|
|
38
81
|
*
|
|
@@ -77,144 +120,5 @@ export namespace IAutoBeInterfaceOperationsReviewApplication {
|
|
|
77
120
|
* needed, and the rationale for the modification.
|
|
78
121
|
*/
|
|
79
122
|
plan: string;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Production-ready operations with all critical issues resolved.
|
|
83
|
-
*
|
|
84
|
-
* Final API operations after systematic enhancement:
|
|
85
|
-
*
|
|
86
|
-
* - **Security Fixes Applied**: All authentication boundaries enforced,
|
|
87
|
-
* sensitive data removed from responses, proper authorization
|
|
88
|
-
* implemented
|
|
89
|
-
* - **Logic Corrections Made**: Return types match operation intent, HTTP
|
|
90
|
-
* methods align with semantics, parameters properly utilized
|
|
91
|
-
* - **Schema Alignment Verified**: All fields exist in Prisma schema, types
|
|
92
|
-
* correctly mapped, relationships properly defined
|
|
93
|
-
* - **Quality Improvements Added**: Enhanced documentation, format
|
|
94
|
-
* specifications, validation rules, consistent naming patterns
|
|
95
|
-
*
|
|
96
|
-
* If no issues were found during review, this contains the exact original
|
|
97
|
-
* operations unchanged. These operations are validated and ready for schema
|
|
98
|
-
* generation and subsequent implementation phases.
|
|
99
|
-
*/
|
|
100
|
-
content: IOperation[];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Operation of the Restful API.
|
|
105
|
-
*
|
|
106
|
-
* This interface defines a single API endpoint with its HTTP {@link method},
|
|
107
|
-
* {@link path}, {@link parameters path parameters},
|
|
108
|
-
* {@link requestBody request body}, and {@link responseBody} structure. It
|
|
109
|
-
* corresponds to an individual operation in the paths section of an OpenAPI
|
|
110
|
-
* document.
|
|
111
|
-
*
|
|
112
|
-
* Each operation requires a detailed explanation of its purpose through the
|
|
113
|
-
* reason and description fields, making it clear why the API was designed and
|
|
114
|
-
* how it should be used.
|
|
115
|
-
*
|
|
116
|
-
* All request bodies and responses for this operation must be object types
|
|
117
|
-
* and must reference named types defined in the components section. The
|
|
118
|
-
* content-type is always `application/json`. For file upload/download
|
|
119
|
-
* operations, use `string & tags.Format<"uri">` in the appropriate schema
|
|
120
|
-
* instead of binary data formats.
|
|
121
|
-
*
|
|
122
|
-
* In OpenAPI, this might represent:
|
|
123
|
-
*
|
|
124
|
-
* ```json
|
|
125
|
-
* {
|
|
126
|
-
* "/shoppings/customers/orders": {
|
|
127
|
-
* "post": {
|
|
128
|
-
* "description": "Create a new order application from shopping cart...",
|
|
129
|
-
* "parameters": [...],
|
|
130
|
-
* "requestBody": {...},
|
|
131
|
-
* "responses": {...}
|
|
132
|
-
* }
|
|
133
|
-
* }
|
|
134
|
-
* }
|
|
135
|
-
* ```
|
|
136
|
-
*/
|
|
137
|
-
export interface IOperation
|
|
138
|
-
extends Omit<AutoBeOpenApi.IOperation, "authorizationType"> {
|
|
139
|
-
/**
|
|
140
|
-
* Prisma schema models relevant to this operation.
|
|
141
|
-
*
|
|
142
|
-
* Contains the complete Prisma schema definitions for all entities involved
|
|
143
|
-
* in this operation, including their fields, relations, and database
|
|
144
|
-
* constraints. This enables comprehensive validation and schema-aware
|
|
145
|
-
* operation design.
|
|
146
|
-
*
|
|
147
|
-
* The schema information serves multiple critical purposes:
|
|
148
|
-
*
|
|
149
|
-
* - **Field Verification**: Ensures all referenced fields actually exist in
|
|
150
|
-
* the database schema and have the correct types
|
|
151
|
-
* - **Relationship Validation**: Confirms that entity relationships are
|
|
152
|
-
* properly defined and can support the operation's data access patterns
|
|
153
|
-
* - **Soft-Delete Detection**: For DELETE operations, identifies whether
|
|
154
|
-
* entities have soft-delete fields (deleted_at, is_deleted, etc.) to
|
|
155
|
-
* determine if the operation should perform logical deletion instead of
|
|
156
|
-
* physical removal
|
|
157
|
-
* - **Constraint Awareness**: Understands unique constraints, required
|
|
158
|
-
* fields, and default values to generate accurate request/response
|
|
159
|
-
* schemas
|
|
160
|
-
*
|
|
161
|
-
* Example content might include:
|
|
162
|
-
*
|
|
163
|
-
* ```prisma
|
|
164
|
-
* model User {
|
|
165
|
-
* id String @id @default(uuid())
|
|
166
|
-
* email String @unique
|
|
167
|
-
* name String
|
|
168
|
-
* deleted_at DateTime? // Indicates soft-delete capability
|
|
169
|
-
* posts Post[]
|
|
170
|
-
* }
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* This schema context ensures operations are fully aligned with the actual
|
|
174
|
-
* database structure and business logic requirements.
|
|
175
|
-
*/
|
|
176
|
-
prisma_schemas: string;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Primary Prisma model name for this operation.
|
|
180
|
-
*
|
|
181
|
-
* Identifies the main database table/model that this operation targets.
|
|
182
|
-
* This must match exactly with the Prisma model name defined in the schema.
|
|
183
|
-
* When soft deletion is specified, this model name indicates which table
|
|
184
|
-
* should be soft-deleted.
|
|
185
|
-
*
|
|
186
|
-
* For example:
|
|
187
|
-
* - In a "GET /users/:id" operation, this would be "User"
|
|
188
|
-
* - In a "POST /articles" operation, this would be "Article"
|
|
189
|
-
* - In a "DELETE /comments/:id" with soft delete, this specifies the "Comment" model to soft-delete
|
|
190
|
-
*
|
|
191
|
-
* This property is essential for:
|
|
192
|
-
* - Determining the primary entity for CRUD operations
|
|
193
|
-
* - Identifying which table to apply soft deletion to
|
|
194
|
-
* - Validating operations against the correct Prisma model
|
|
195
|
-
* - Generating appropriate database queries and validations
|
|
196
|
-
*/
|
|
197
|
-
model_name: string;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Soft delete column name for the Prisma models.
|
|
201
|
-
*
|
|
202
|
-
* Specifies the column name used for soft deletion in the database tables
|
|
203
|
-
* associated with this operation. When set to a non-null value, it indicates
|
|
204
|
-
* that the related entities support soft deletion through this column
|
|
205
|
-
* (typically a timestamp field like `deleted_at` or `deletedAt`).
|
|
206
|
-
*
|
|
207
|
-
* When null, it means the entities involved in this operation use hard
|
|
208
|
-
* deletion or don't support deletion at all. This information is crucial
|
|
209
|
-
* for generating appropriate CRUD operations and ensuring data integrity
|
|
210
|
-
* policies are correctly implemented.
|
|
211
|
-
*
|
|
212
|
-
* Common soft delete patterns:
|
|
213
|
-
* - `"deleted_at"`: Records deletion timestamp
|
|
214
|
-
* - `"deletedAt"`: Camel-cased deletion timestamp
|
|
215
|
-
* - `"is_deleted"`: Boolean flag for deletion status
|
|
216
|
-
* - `null`: No soft deletion (hard delete only)
|
|
217
|
-
*/
|
|
218
|
-
soft_delete_column: string | null;
|
|
219
123
|
}
|
|
220
124
|
}
|
|
@@ -29,15 +29,44 @@ export namespace IAutoBeInterfaceSchemasReviewApplication {
|
|
|
29
29
|
* interface to understand what outputs are required.
|
|
30
30
|
*/
|
|
31
31
|
export interface IProps {
|
|
32
|
+
think: IThink;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Final validated and enhanced schemas ready for production use.
|
|
36
|
+
*
|
|
37
|
+
* DO:
|
|
38
|
+
*
|
|
39
|
+
* - Include valid OpenAPI schema definitions
|
|
40
|
+
* - Include all entities that were in the original input
|
|
41
|
+
* - Provide fixed versions if original schemas have issues
|
|
42
|
+
* - Rename entities correctly if names are wrong
|
|
43
|
+
* - Include created variants if schemas are missing them
|
|
44
|
+
*
|
|
45
|
+
* DO NOT:
|
|
46
|
+
*
|
|
47
|
+
* - Return an empty object {} (this will delete all schemas)
|
|
48
|
+
* - Return undefined or null
|
|
49
|
+
* - Include explanations or excuses in schema descriptions
|
|
50
|
+
* - Leave broken schemas unfixed
|
|
51
|
+
*
|
|
52
|
+
* When original schemas are beyond repair, recreate them properly based on
|
|
53
|
+
* entity names and context. This field becomes the final schemas used by
|
|
54
|
+
* the system, so it must always contain complete, valid schemas.
|
|
55
|
+
*/
|
|
56
|
+
content: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface IThink {
|
|
32
60
|
/**
|
|
33
61
|
* Issues and problems found during schema analysis.
|
|
34
62
|
*
|
|
35
|
-
* DO: Document only problems that need fixing.
|
|
36
|
-
*
|
|
63
|
+
* DO: Document only problems that need fixing. DO NOT: Include positive
|
|
64
|
+
* feedback, compliments, or confirmations
|
|
37
65
|
*
|
|
38
66
|
* Focus exclusively on issues organized by severity:
|
|
39
67
|
*
|
|
40
68
|
* Severity levels:
|
|
69
|
+
*
|
|
41
70
|
* - Security vulnerabilities (exposed passwords, missing auth boundaries)
|
|
42
71
|
* - Missing required variants, incorrect type mappings
|
|
43
72
|
* - Missing format specifications, incomplete relationships
|
|
@@ -63,30 +92,5 @@ export namespace IAutoBeInterfaceSchemasReviewApplication {
|
|
|
63
92
|
* field.
|
|
64
93
|
*/
|
|
65
94
|
plan: string;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Final validated and enhanced schemas ready for production use.
|
|
69
|
-
*
|
|
70
|
-
* DO:
|
|
71
|
-
* - Include valid OpenAPI schema definitions
|
|
72
|
-
* - Include all entities that were in the original input
|
|
73
|
-
* - Provide fixed versions if original schemas have issues
|
|
74
|
-
* - Rename entities correctly if names are wrong
|
|
75
|
-
* - Include created variants if schemas are missing them
|
|
76
|
-
*
|
|
77
|
-
* DO NOT:
|
|
78
|
-
* - Return an empty object {} (this will delete all schemas)
|
|
79
|
-
* - Return undefined or null
|
|
80
|
-
* - Include explanations or excuses in schema descriptions
|
|
81
|
-
* - Leave broken schemas unfixed
|
|
82
|
-
*
|
|
83
|
-
* When original schemas are beyond repair, recreate them properly based on
|
|
84
|
-
* entity names and context. This field becomes the final schemas used by
|
|
85
|
-
* the system, so it must always contain complete, valid schemas.
|
|
86
|
-
*/
|
|
87
|
-
content: Record<
|
|
88
|
-
string,
|
|
89
|
-
AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema>
|
|
90
|
-
>;
|
|
91
95
|
}
|
|
92
96
|
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
import { AutoBeOpenApiTypeChecker, StringUtil } from "@autobe/utils";
|
|
3
|
+
import typia, { tags } from "typia";
|
|
4
|
+
|
|
5
|
+
export namespace JsonSchemaFactory {
|
|
6
|
+
export const presets = (
|
|
7
|
+
typeNames: Set<string>,
|
|
8
|
+
): Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> => {
|
|
9
|
+
const schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {};
|
|
10
|
+
for (const [key, value] of Object.entries(DEFAULT_SCHEMAS)) {
|
|
11
|
+
schemas[key] = value;
|
|
12
|
+
typeNames.delete(key);
|
|
13
|
+
}
|
|
14
|
+
for (const key of typeNames)
|
|
15
|
+
if (isPage(key)) {
|
|
16
|
+
const data: string = getPageName(key);
|
|
17
|
+
schemas[key] = page(data);
|
|
18
|
+
typeNames.delete(key);
|
|
19
|
+
typeNames.add(data);
|
|
20
|
+
}
|
|
21
|
+
return schemas;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const authorize = (
|
|
25
|
+
schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>,
|
|
26
|
+
): void => {
|
|
27
|
+
for (const [key, value] of Object.entries(schemas)) {
|
|
28
|
+
if (key.endsWith(".IAuthorized") === false) continue;
|
|
29
|
+
else if (AutoBeOpenApiTypeChecker.isObject(value) === false) continue;
|
|
30
|
+
|
|
31
|
+
const parent: AutoBeOpenApi.IJsonSchemaDescriptive | undefined =
|
|
32
|
+
schemas[key.substring(0, key.length - ".IAuthorized".length)];
|
|
33
|
+
if (parent === undefined) continue;
|
|
34
|
+
else if (AutoBeOpenApiTypeChecker.isObject(parent) === false) continue;
|
|
35
|
+
|
|
36
|
+
value.properties = {
|
|
37
|
+
...parent.properties,
|
|
38
|
+
...value.properties,
|
|
39
|
+
};
|
|
40
|
+
value.required = [...parent.required];
|
|
41
|
+
if (value.required.includes("id") === false) value.required.push("id");
|
|
42
|
+
if (value.required.includes("token") === false)
|
|
43
|
+
value.required.push("token");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const page = (
|
|
48
|
+
key: string,
|
|
49
|
+
): AutoBeOpenApi.IJsonSchemaDescriptive.IObject => ({
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
pagination: {
|
|
53
|
+
$ref: "#/components/schemas/IPage.IPagination",
|
|
54
|
+
description: "Page information.",
|
|
55
|
+
},
|
|
56
|
+
data: {
|
|
57
|
+
type: "array",
|
|
58
|
+
items: {
|
|
59
|
+
$ref: `#/components/schemas/${key}`,
|
|
60
|
+
},
|
|
61
|
+
description: "List of records.",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
required: ["pagination", "data"],
|
|
65
|
+
description: StringUtil.trim`
|
|
66
|
+
A page.
|
|
67
|
+
|
|
68
|
+
Collection of records with pagination information.
|
|
69
|
+
`,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export const fix = (path: string, input: unknown): void => {
|
|
73
|
+
if (isRecord(input) === false || isRecord(input[path]) === false) return;
|
|
74
|
+
|
|
75
|
+
if (input[path].description) delete input[path].description;
|
|
76
|
+
if (input[path].required) delete input[path].required;
|
|
77
|
+
|
|
78
|
+
for (const key of Object.keys(input[path]))
|
|
79
|
+
if (DEFAULT_SCHEMAS[key] !== undefined)
|
|
80
|
+
input[path][key] = DEFAULT_SCHEMAS[key];
|
|
81
|
+
else if (isPage(key) === true) {
|
|
82
|
+
const data: string = key.substring("IPage".length);
|
|
83
|
+
input[path][key] = page(data);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const isPage = (key: string): boolean =>
|
|
88
|
+
key.startsWith("IPage") === true &&
|
|
89
|
+
key.startsWith("IPage.") === false &&
|
|
90
|
+
key !== "IPage";
|
|
91
|
+
|
|
92
|
+
export const getPageName = (key: string): string =>
|
|
93
|
+
key.substring("IPage".length);
|
|
94
|
+
|
|
95
|
+
const isRecord = (input: unknown): input is Record<string, unknown> =>
|
|
96
|
+
typeof input === "object" && input !== null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const DEFAULT_SCHEMAS = typia.assertEquals<
|
|
100
|
+
Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>
|
|
101
|
+
>(
|
|
102
|
+
typia.json.schemas<[IPage.IPagination, IAuthorizationToken]>().components
|
|
103
|
+
?.schemas,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
namespace IPage {
|
|
107
|
+
/** Page information. */
|
|
108
|
+
export interface IPagination {
|
|
109
|
+
/** Current page number. */
|
|
110
|
+
current: number & tags.Type<"uint32">;
|
|
111
|
+
|
|
112
|
+
/** Limitation of records per a page. */
|
|
113
|
+
limit: number & tags.Type<"uint32">;
|
|
114
|
+
|
|
115
|
+
/** Total records in the database. */
|
|
116
|
+
records: number & tags.Type<"uint32">;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Total pages.
|
|
120
|
+
*
|
|
121
|
+
* Equal to {@link records} / {@link limit} with ceiling.
|
|
122
|
+
*/
|
|
123
|
+
pages: number & tags.Type<"uint32">;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Authorization token response structure.
|
|
129
|
+
*
|
|
130
|
+
* This interface defines the structure of the authorization token response
|
|
131
|
+
* returned after successful user authentication. It contains both access and
|
|
132
|
+
* refresh tokens along with their expiration information.
|
|
133
|
+
*
|
|
134
|
+
* This token structure is automatically included in API schemas when the system
|
|
135
|
+
* detects authorization roles in the requirements analysis phase. It provides a
|
|
136
|
+
* standard format for JWT-based authentication across the generated backend
|
|
137
|
+
* applications.
|
|
138
|
+
*/
|
|
139
|
+
interface IAuthorizationToken {
|
|
140
|
+
/**
|
|
141
|
+
* JWT access token for authenticated requests.
|
|
142
|
+
*
|
|
143
|
+
* This token should be included in the Authorization header for subsequent
|
|
144
|
+
* authenticated API requests as `Bearer {token}`.
|
|
145
|
+
*/
|
|
146
|
+
access: string;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Refresh token for obtaining new access tokens.
|
|
150
|
+
*
|
|
151
|
+
* This token can be used to request new access tokens when the current access
|
|
152
|
+
* token expires, extending the user's session.
|
|
153
|
+
*/
|
|
154
|
+
refresh: string;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Access token expiration timestamp.
|
|
158
|
+
*
|
|
159
|
+
* ISO 8601 date-time string indicating when the access token will expire and
|
|
160
|
+
* can no longer be used for authentication.
|
|
161
|
+
*/
|
|
162
|
+
expired_at: string & tags.Format<"date-time">;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Refresh token expiration timestamp.
|
|
166
|
+
*
|
|
167
|
+
* ISO 8601 date-time string indicating the latest time until which the
|
|
168
|
+
* refresh token can be used to obtain new access tokens.
|
|
169
|
+
*/
|
|
170
|
+
refreshable_until: string & tags.Format<"date-time">;
|
|
171
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
import { MapUtil } from "@autobe/utils";
|
|
3
|
+
import { OpenApiTypeChecker } from "@samchon/openapi";
|
|
4
|
+
|
|
5
|
+
export namespace JsonSchemaNamingConvention {
|
|
6
|
+
export const operations = (operations: AutoBeOpenApi.IOperation[]): void => {
|
|
7
|
+
const typeNames: Set<string> = new Set();
|
|
8
|
+
operate(typeNames, operations);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const schemas = (
|
|
12
|
+
operations: AutoBeOpenApi.IOperation[],
|
|
13
|
+
...componentSchemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>[]
|
|
14
|
+
): void => {
|
|
15
|
+
const typeNames: Set<string> = new Set();
|
|
16
|
+
for (const schemas of componentSchemas)
|
|
17
|
+
for (const key of Object.keys(schemas)) typeNames.add(key);
|
|
18
|
+
const answer = operate(typeNames, operations);
|
|
19
|
+
|
|
20
|
+
for (const dict of componentSchemas)
|
|
21
|
+
for (const x of Object.keys(dict)) {
|
|
22
|
+
const y: string = answer(x);
|
|
23
|
+
if (x === y) continue;
|
|
24
|
+
dict[y] = dict[x]!;
|
|
25
|
+
delete dict[x];
|
|
26
|
+
}
|
|
27
|
+
for (const dict of componentSchemas)
|
|
28
|
+
for (const x of Object.values(dict)) {
|
|
29
|
+
OpenApiTypeChecker.visit({
|
|
30
|
+
components: { schemas: dict },
|
|
31
|
+
schema: x,
|
|
32
|
+
closure: (s) => {
|
|
33
|
+
if (OpenApiTypeChecker.isReference(s) === false) return;
|
|
34
|
+
s.$ref = `#/components/schemas/${answer(s.$ref.split("/").pop()!)}`;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const operate = (
|
|
41
|
+
typeNames: Set<string>,
|
|
42
|
+
operations: AutoBeOpenApi.IOperation[],
|
|
43
|
+
): ((v: string) => string) => {
|
|
44
|
+
for (const op of operations) {
|
|
45
|
+
if (op.requestBody) typeNames.add(op.requestBody.typeName);
|
|
46
|
+
if (op.responseBody) typeNames.add(op.responseBody.typeName);
|
|
47
|
+
}
|
|
48
|
+
const answer = prepare(typeNames);
|
|
49
|
+
for (const op of operations) {
|
|
50
|
+
if (op.requestBody)
|
|
51
|
+
op.requestBody.typeName = answer(op.requestBody.typeName);
|
|
52
|
+
if (op.responseBody)
|
|
53
|
+
op.responseBody.typeName = answer(op.responseBody.typeName);
|
|
54
|
+
}
|
|
55
|
+
return answer;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const prepare = (typeNames: Set<string>): ((v: string) => string) => {
|
|
59
|
+
const similar: Map<string, string[]> = new Map();
|
|
60
|
+
const getKey = (v: string) => v.split(".")[0]!.toLowerCase();
|
|
61
|
+
const getValue = (v: string) => v.split(".")[0]!;
|
|
62
|
+
const emplace = (v: string) =>
|
|
63
|
+
MapUtil.take(similar, getKey(v), () => []).push(getValue(v));
|
|
64
|
+
|
|
65
|
+
for (const v of typeNames) emplace(v);
|
|
66
|
+
|
|
67
|
+
const solution: Map<string, string> = new Map();
|
|
68
|
+
for (const [key, values] of similar) {
|
|
69
|
+
if (values.length === 1) continue;
|
|
70
|
+
const winner: string = values.sort(
|
|
71
|
+
(a, b) => countCapitalLetters(b) - countCapitalLetters(a),
|
|
72
|
+
)[0]!;
|
|
73
|
+
solution.set(key, winner);
|
|
74
|
+
}
|
|
75
|
+
return (v: string) => {
|
|
76
|
+
const key: string = getKey(v);
|
|
77
|
+
if (solution.has(key) === false) return v;
|
|
78
|
+
return [solution.get(key), ...v.split(".").slice(1)].join(".");
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const countCapitalLetters = (str: string) => (str.match(/[A-Z]/g) || []).length;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
2
|
+
import { AutoBeOpenApiTypeChecker, StringUtil } from "@autobe/utils";
|
|
3
|
+
import { IValidation } from "typia";
|
|
4
|
+
import { Escaper } from "typia/lib/utils/Escaper";
|
|
5
|
+
|
|
6
|
+
export namespace JsonSchemaValidator {
|
|
7
|
+
export interface IProps {
|
|
8
|
+
errors: IValidation.IError[];
|
|
9
|
+
schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive>;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const validate = (props: IProps): void => {
|
|
14
|
+
authorization(props);
|
|
15
|
+
validateKey(props);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const authorization = (props: IProps): void => {
|
|
19
|
+
for (const [key, value] of Object.entries(props.schemas)) {
|
|
20
|
+
if (!key.endsWith(".IAuthorized")) continue;
|
|
21
|
+
|
|
22
|
+
// Check if it's an object type
|
|
23
|
+
if (AutoBeOpenApiTypeChecker.isObject(value) === false) {
|
|
24
|
+
props.errors.push({
|
|
25
|
+
path: `${props.path}.${key}`,
|
|
26
|
+
expected: `AutoBeOpenApi.IJsonSchemaDescriptive<AutoBeOpenApi.IJsonSchema.IObject>`,
|
|
27
|
+
value: value,
|
|
28
|
+
description: `${key} must be an object type for authorization responses`,
|
|
29
|
+
});
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Check if token property exists
|
|
34
|
+
value.properties ??= {};
|
|
35
|
+
value.properties["token"] = {
|
|
36
|
+
$ref: "#/components/schemas/IAuthorizationToken",
|
|
37
|
+
description: "JWT token information for authentication",
|
|
38
|
+
} as AutoBeOpenApi.IJsonSchemaDescriptive.IReference;
|
|
39
|
+
|
|
40
|
+
value.required ??= [];
|
|
41
|
+
if (value.required.includes("token") === false)
|
|
42
|
+
value.required.push("token");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const validateKey = (props: IProps): void => {
|
|
47
|
+
for (const key of Object.keys(props.schemas)) {
|
|
48
|
+
const variable: boolean = key.split(".").every(Escaper.variable);
|
|
49
|
+
if (variable === false)
|
|
50
|
+
props.errors.push({
|
|
51
|
+
path: `${props.path}[${JSON.stringify(key)}]`,
|
|
52
|
+
expected: "Valid variable name",
|
|
53
|
+
value: key,
|
|
54
|
+
description: StringUtil.trim`
|
|
55
|
+
JSON schema type name must be a valid variable name.
|
|
56
|
+
|
|
57
|
+
Even though JSON schema type name allows dot(.) character, but
|
|
58
|
+
each segment separated by dot(.) must be a valid variable name.
|
|
59
|
+
|
|
60
|
+
Current key name ${JSON.stringify(key)} is not valid. Change
|
|
61
|
+
it to a valid variable name at the next time.
|
|
62
|
+
`,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|