@autobe/agent 0.18.0 → 0.20.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/AutoBeMockAgent.d.ts +2 -10
- package/lib/agent/src/AutoBeAgent.js +8 -2
- package/lib/agent/src/AutoBeAgent.js.map +1 -1
- package/lib/agent/src/AutoBeMockAgent.d.ts +2 -10
- package/lib/agent/src/AutoBeMockAgent.js +10 -5
- package/lib/agent/src/AutoBeMockAgent.js.map +1 -1
- package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +23 -29
- package/lib/agent/src/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/agent/src/context/AutoBeContext.d.ts +1 -0
- package/lib/agent/src/context/AutoBeTokenUsageComponent.d.ts +1 -0
- package/lib/agent/src/context/AutoBeTokenUsageComponent.js +14 -0
- package/lib/agent/src/context/AutoBeTokenUsageComponent.js.map +1 -1
- package/lib/agent/src/factory/consentFunctionCall.d.ts +10 -0
- package/lib/agent/src/factory/consentFunctionCall.js +213 -0
- package/lib/agent/src/factory/consentFunctionCall.js.map +1 -0
- package/lib/agent/src/factory/createAgenticaHistory.js +1 -0
- package/lib/agent/src/factory/createAgenticaHistory.js.map +1 -1
- package/lib/agent/src/factory/createAutoBeContext.js +79 -19
- package/lib/agent/src/factory/createAutoBeContext.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.d.ts +6 -0
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js +41 -0
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.js.map +1 -0
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js +12 -9
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +3 -1
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js +45 -31
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js +25 -6
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +8 -3
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +15 -12
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +33 -44
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +6 -4
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js +10 -4
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +16 -16
- package/lib/agent/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +5 -5
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js +45 -45
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +14 -14
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js +31 -30
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js +24 -31
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +4 -4
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js +27 -26
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js +13 -12
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.js +4 -4
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js +11 -10
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js +36 -29
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +31 -9
- package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +2 -2
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +1571 -1144
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +24 -4
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +6 -2
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.d.ts +2 -2
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js +12 -14
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +103 -71
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.d.ts +2 -3
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +147 -116
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +401 -233
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +2 -5
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js +362 -178
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +38 -0
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +16 -16
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +97 -14
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +75 -1
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +46 -14
- package/lib/agent/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +18 -24
- package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +7 -0
- package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js +35 -0
- package/lib/agent/src/orchestrate/interface/utils/validateAuthorizationSchema.js.map +1 -0
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +60 -66
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +19 -30
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +38 -35
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +39 -26
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js +15 -4
- package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -2
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js +7 -9
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +38 -2
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js +61 -10
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js +68 -24
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js +24 -21
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorization.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js +59 -57
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +1 -0
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js +17 -13
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.d.ts +3 -0
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js +287 -0
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -2
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +46 -49
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts +7 -0
- package/lib/agent/src/orchestrate/realize/internal/{compile.js → compileRealizeFiles.js} +12 -29
- package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +76 -45
- package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +15 -9
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +9 -7
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +9 -6
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +25 -20
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.d.ts +0 -66
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +8 -6
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +36 -27
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +3 -3
- package/lib/agent/src/orchestrate/{internal/IProgress.js → realize/structures/IAutoBeRealizeCorrectApplication.js} +1 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCorrectApplication.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +19 -16
- package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js +5 -1
- package/lib/agent/src/orchestrate/realize/utils/replaceImportStatements.js.map +1 -1
- package/lib/agent/src/orchestrate/test/compile/completeTestCode.js +13 -10
- package/lib/agent/src/orchestrate/test/compile/completeTestCode.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +17 -16
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js +33 -32
- package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.d.ts +2 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +97 -49
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +3 -3
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTest.js +17 -4
- package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +18 -9
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +138 -23
- package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +17 -17
- package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +7 -6
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +1 -1
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.d.ts +6 -0
- package/lib/agent/src/orchestrate/{realize/structures/IAutoBeRealizeCoderApplication.js → test/structures/IAutoBeTestScenarioAuthorizationRole.js} +1 -1
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.js.map +1 -0
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +2 -2
- package/lib/agent/src/utils/executeCachedBatch.d.ts +1 -0
- package/lib/agent/src/utils/executeCachedBatch.js +23 -0
- package/lib/agent/src/utils/executeCachedBatch.js.map +1 -0
- package/lib/agent/src/utils/predicateStateMessage.d.ts +4 -0
- package/lib/agent/src/utils/predicateStateMessage.js +87 -0
- package/lib/agent/src/utils/predicateStateMessage.js.map +1 -0
- package/lib/constants/AutoBeSystemPromptConstant.d.ts +23 -29
- package/lib/context/AutoBeContext.d.ts +1 -0
- package/lib/context/AutoBeTokenUsageComponent.d.ts +1 -0
- package/lib/factory/consentFunctionCall.d.ts +10 -0
- package/lib/index.mjs +4799 -2637
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.d.ts +6 -0
- package/lib/orchestrate/analyze/histories/transformAnalyzeWriteHistories.d.ts +3 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +8 -3
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +6 -4
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.d.ts +16 -16
- package/lib/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.d.ts +5 -5
- package/lib/orchestrate/interface/orchestrateInterfaceAuthorizations.d.ts +2 -2
- package/lib/orchestrate/interface/orchestrateInterfaceGroups.d.ts +2 -2
- package/lib/orchestrate/interface/orchestrateInterfaceOperationsReview.d.ts +2 -3
- package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +2 -5
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.d.ts +38 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.d.ts +16 -16
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +97 -14
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +75 -1
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.d.ts +46 -14
- package/lib/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.d.ts +18 -24
- package/lib/orchestrate/interface/utils/validateAuthorizationSchema.d.ts +7 -0
- package/lib/orchestrate/prisma/orchestratePrismaComponent.d.ts +1 -2
- package/lib/orchestrate/realize/histories/transformRealizeCorrectHistories.d.ts +1 -0
- package/lib/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.d.ts +3 -0
- package/lib/orchestrate/realize/histories/transformRealizeWriteHistories.d.ts +5 -2
- package/lib/orchestrate/realize/internal/compileRealizeFiles.d.ts +7 -0
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +9 -6
- package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +0 -66
- package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +8 -6
- package/lib/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.d.ts +3 -3
- package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +19 -16
- package/lib/orchestrate/test/histories/transformTestScenarioHistories.d.ts +2 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +7 -6
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +1 -1
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.d.ts +6 -0
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +2 -2
- package/lib/utils/executeCachedBatch.d.ts +1 -0
- package/lib/utils/predicateStateMessage.d.ts +4 -0
- package/package.json +6 -6
- package/src/AutoBeAgent.ts +18 -3
- package/src/AutoBeMockAgent.ts +13 -15
- package/src/constants/AutoBeSystemPromptConstant.ts +23 -29
- package/src/context/AutoBeContext.ts +1 -0
- package/src/context/AutoBeTokenUsageComponent.ts +20 -0
- package/src/factory/consentFunctionCall.ts +129 -0
- package/src/factory/createAgenticaHistory.ts +1 -0
- package/src/factory/createAutoBeContext.ts +108 -20
- package/src/orchestrate/analyze/histories/transformAnalyzeReviewHistories.ts +53 -0
- package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +13 -10
- package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +68 -47
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +33 -21
- package/src/orchestrate/analyze/orchestrateAnalyzeReview.ts +21 -10
- package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +18 -40
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +15 -8
- package/src/orchestrate/analyze/structures/IAutoBeAnalyzeReviewApplication.ts +16 -16
- package/src/orchestrate/analyze/structures/IAutoBeAnalyzeScenarioApplication.ts +5 -5
- package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +47 -47
- package/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts +14 -14
- package/src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts +31 -30
- package/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.ts +20 -29
- package/src/orchestrate/interface/histories/transformInterfaceGroupHistories.ts +3 -3
- package/src/orchestrate/interface/histories/transformInterfaceOperationHistories.ts +23 -22
- package/src/orchestrate/interface/histories/transformInterfaceOperationsReviewHistories.ts +12 -11
- package/src/orchestrate/interface/histories/transformInterfacePrerequisiteHistories.ts +5 -5
- package/src/orchestrate/interface/histories/transformInterfaceSchemaHistories.ts +11 -10
- package/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.ts +37 -30
- package/src/orchestrate/interface/orchestrateInterface.ts +53 -12
- package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +142 -32
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +2 -0
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +13 -9
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +8 -19
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +82 -74
- package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +51 -32
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +174 -56
- package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +149 -63
- package/src/orchestrate/interface/structures/IAutoBeInterfaceComplementApplication.ts +39 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceGroupApplication.ts +16 -16
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +101 -14
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +77 -1
- package/src/orchestrate/interface/structures/IAutoBeInterfaceSchemaApplication.ts +47 -14
- package/src/orchestrate/interface/structures/IAutobeInterfaceSchemasReviewApplication.ts +18 -24
- package/src/orchestrate/interface/utils/validateAuthorizationSchema.ts +41 -0
- package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +61 -66
- package/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.ts +19 -30
- package/src/orchestrate/prisma/histories/transformPrismaReviewHistories.ts +38 -35
- package/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.ts +36 -23
- package/src/orchestrate/prisma/orchestratePrisma.ts +17 -6
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +8 -19
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +3 -0
- package/src/orchestrate/prisma/orchestratePrismaReview.ts +37 -18
- package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +25 -17
- package/src/orchestrate/realize/histories/transformRealizeAuthorization.ts +24 -21
- package/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts +57 -59
- package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +20 -14
- package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +294 -0
- package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +62 -57
- package/src/orchestrate/realize/internal/compileRealizeFiles.ts +71 -0
- package/src/orchestrate/realize/orchestrateRealize.ts +109 -86
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +22 -13
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +3 -0
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +28 -24
- package/src/orchestrate/realize/orchestrateRealizeScenario.ts +0 -74
- package/src/orchestrate/realize/orchestrateRealizeWrite.ts +37 -28
- package/src/orchestrate/realize/structures/IAutoBeRealizeAuthorizationApplication.ts +3 -3
- package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +19 -16
- package/src/orchestrate/realize/utils/replaceImportStatements.ts +7 -0
- package/src/orchestrate/test/compile/completeTestCode.ts +17 -13
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +4 -4
- package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +17 -16
- package/src/orchestrate/test/histories/transformTestHistories.ts +35 -34
- package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +116 -60
- package/src/orchestrate/test/histories/transformTestWriteHistories.ts +3 -3
- package/src/orchestrate/test/orchestrateTest.ts +18 -8
- package/src/orchestrate/test/orchestrateTestCorrect.ts +34 -24
- package/src/orchestrate/test/orchestrateTestScenario.ts +179 -36
- package/src/orchestrate/test/orchestrateTestWrite.ts +18 -19
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +7 -6
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +1 -1
- package/src/orchestrate/test/structures/IAutoBeTestScenarioAuthorizationRole.ts +7 -0
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +2 -2
- package/src/utils/executeCachedBatch.ts +15 -0
- package/src/utils/predicateStateMessage.ts +107 -0
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +0 -4
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.js +0 -46
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.js.map +0 -1
- package/lib/agent/src/orchestrate/internal/IProgress.d.ts +0 -4
- package/lib/agent/src/orchestrate/internal/IProgress.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCoderHistories.d.ts +0 -7
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCoderHistories.js +0 -213
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeCoderHistories.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/internal/compile.d.ts +0 -7
- package/lib/agent/src/orchestrate/realize/internal/compile.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +0 -345
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +0 -56
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCompile.js +0 -3
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeCompile.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.d.ts +0 -2
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.js +0 -5
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeReviewApplication.js +0 -3
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeReviewApplication.js.map +0 -1
- package/lib/agent/src/utils/pipe.d.ts +0 -5
- package/lib/agent/src/utils/pipe.js +0 -14
- package/lib/agent/src/utils/pipe.js.map +0 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +0 -4
- package/lib/orchestrate/internal/IProgress.d.ts +0 -4
- package/lib/orchestrate/realize/histories/transformRealizeCoderHistories.d.ts +0 -7
- package/lib/orchestrate/realize/internal/compile.d.ts +0 -7
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.d.ts +0 -345
- package/lib/orchestrate/realize/structures/IAutoBeRealizeCompile.d.ts +0 -56
- package/lib/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.d.ts +0 -2
- package/lib/utils/pipe.d.ts +0 -5
- package/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.ts +0 -53
- package/src/orchestrate/internal/IProgress.ts +0 -4
- package/src/orchestrate/realize/histories/transformRealizeCoderHistories.ts +0 -248
- package/src/orchestrate/realize/internal/compile.ts +0 -84
- package/src/orchestrate/realize/structures/IAutoBeRealizeCoderApplication.ts +0 -358
- package/src/orchestrate/realize/structures/IAutoBeRealizeCompile.ts +0 -70
- package/src/orchestrate/realize/structures/IAutoBeRealizeFailedSymbol.ts +0 -2
- package/src/utils/pipe.ts +0 -39
- /package/lib/agent/src/orchestrate/realize/structures/{IAutoBeRealizeReviewApplication.d.ts → IAutoBeRealizeCorrectApplication.d.ts} +0 -0
- /package/lib/orchestrate/realize/structures/{IAutoBeRealizeReviewApplication.d.ts → IAutoBeRealizeCorrectApplication.d.ts} +0 -0
- /package/src/orchestrate/realize/structures/{IAutoBeRealizeReviewApplication.ts → IAutoBeRealizeCorrectApplication.ts} +0 -0
package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformRealizeAuthorizationCorrectHistories = void 0;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
4
5
|
const uuid_1 = require("uuid");
|
|
5
6
|
const transformRealizeAuthorizationCorrectHistories = (ctx, auth, templateFiles, diagnostics) => {
|
|
6
7
|
var _a;
|
|
7
8
|
return [
|
|
8
9
|
{
|
|
9
|
-
id: (0, uuid_1.
|
|
10
|
+
id: (0, uuid_1.v7)(),
|
|
10
11
|
created_at: new Date().toISOString(),
|
|
11
12
|
type: "systemMessage",
|
|
12
|
-
text: "# NestJS Authentication Provider & Decorator Generation AI Agent \n\n## Naming Conventions\n\n### Notation Types\nThe following naming conventions (notations) are used throughout the system:\n- **camelCase**: First word lowercase, subsequent words capitalized (e.g., `userAccount`, `productItem`)\n- **PascalCase**: All words capitalized (e.g., `UserAccount`, `ProductItem`)\n- **snake_case**: All lowercase with underscores between words (e.g., `user_account`, `product_item`)\n\n### Specific Property Notations\n- **IAutoBeRealizeAuthorizationApplication.IProvider.name**: Use camelCase notation (format: `{Role.name(PascalCase)}Authorize`)\n- **IAutoBeRealizeAuthorizationApplication.IDecorator.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Auth`)\n- **IAutoBeRealizeAuthorizationApplication.IPayloadType.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Payload`)\n\nYou are a world-class NestJS expert and TypeScript developer. Your role is to automatically generate Provider functions and Decorators for JWT authentication based on given Role information and Prisma Schema. \n\n## Core Mission \n\nGenerate authentication Provider and Decorator code specialized for specific Roles based on Role information provided by users. \n\n## Input Information \n\n- **Role Name**: The authentication role to generate (e.g., admin, user, manager, etc.) \n- **Prisma Schema**: Database table information.\n\n## File Structure\n\n**IMPORTANT: Understanding the file structure is crucial for correct import paths:**\n\n```\nsrc/\n\u251C\u2500\u2500 MyGlobal.ts\n\u251C\u2500\u2500 decorators/\n\u2502 \u251C\u2500\u2500 AdminAuth.ts\n\u2502 \u251C\u2500\u2500 UserAuth.ts\n\u2502 \u2514\u2500\u2500 payload/\n\u2502 \u251C\u2500\u2500 AdminPayload.ts\n\u2502 \u2514\u2500\u2500 UserPayload.ts\n\u2514\u2500\u2500 providers/\n \u2514\u2500\u2500 authorize/\n \u251C\u2500\u2500 jwtAuthorize.ts \u2190 Shared JWT verification function\n \u251C\u2500\u2500 adminAuthorize.ts \u2190 Same directory as jwtAuthorize\n \u2514\u2500\u2500 userAuthorize.ts \u2190 Same directory as jwtAuthorize\n```\n\n## Code Generation Rules \n\n### 1. Provider Function Generation Rules \n\n- Function name: `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize) \n- Must use the `jwtAuthorize` function for JWT token verification \n- **\u26A0\uFE0F CRITICAL: Import jwtAuthorize using `import { jwtAuthorize } from \"./jwtAuthorize\";` (NOT from \"../../providers/authorize/jwtAuthorize\" or any other path)**\n- Verify payload type and check if `payload.type` matches the correct role \n- Query database using `MyGlobal.prisma.{tableName}` format to fetch **only the authorization model itself** - do not include relations or business logic models (no `include` statements for profile, etc.) \n- Verify that the user actually exists in the database \n- Function return type should be `{Role.name(PascalCase)}Payload` interface \n- Return the `payload` variable whenever feasible in provider functions. \n- **Always check the Prisma schema for validation columns (e.g., `deleted_at`, status fields) within the authorization model and include them in the `where` clause to ensure the user is valid and active.** \n\n### 2. Payload Interface Generation Rules \n\n- Interface name: `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload) \n- Required fields: \n - `id: string & tags.Format<\"uuid\">`: User ID (UUID format) \n - `type: \"{role}\"`: Discriminator for role identification \n- Additional fields should be generated according to Role characteristics and \"Prisma Schema\" \n\n### 3. Decorator Generation Rules \n\n- Decorator name: `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth) \n- Use SwaggerCustomizer to add bearer token security schema to API documentation \n- Use createParamDecorator to implement actual authentication logic \n- Use Singleton pattern to manage decorator instances \n\n### 4. Code Style and Structure\n\n- Comply with TypeScript strict mode \n- Utilize NestJS Exception classes (ForbiddenException, UnauthorizedException) \n- Ensure type safety using typia tags \n- Add appropriate JSDoc comments \n\n## Reference Functions and Examples \n\n### JWT Authentication Function \n\n```typescript\n// File path: src/providers/authorize/jwtAuthorize.ts\nimport { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n``` \n\n### Provider Function Example \n\n**\u26A0\uFE0F CRITICAL IMPORT PATHS:**\n- `jwtAuthorize` MUST be imported from `\"./jwtAuthorize\"` (same directory)\n- NOT `\"../../providers/authorize/jwtAuthorize\"` \u274C\n- NOT `\"../jwtAuthorize\"` \u274C\n- ONLY `\"./jwtAuthorize\"` \u2705\n\n```typescript\n// File path: src/providers/authorize/adminAuthorize.ts\nimport { ForbiddenException } from \"@nestjs/common\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\nimport { jwtAuthorize } from \"./jwtAuthorize\"; // \u2190 CORRECT: Same directory import\nimport { AdminPayload } from \"../../decorators/payload/AdminPayload\";\n\nexport async function adminAuthorize(request: {\n headers: {\n authorization?: string;\n };\n}): Promise<AdminPayload> {\n const payload: AdminPayload = jwtAuthorize({ request }) as AdminPayload;\n\n if (payload.type !== \"admin\") {\n throw new ForbiddenException(`You're not ${payload.type}`);\n }\n\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: {\n id: payload.id,\n user: {\n deleted_at: null,\n is_banned: false,\n },\n },\n });\n\n if (admin === null) {\n throw new ForbiddenException(\"You're not enrolled\");\n }\n\n return payload;\n}\n``` \n\n### Decorator Example\n\n```typescript\n// File path: src/decorators/AdminAuth.ts\nimport { SwaggerCustomizer } from \"@nestia/core\";\nimport { ExecutionContext, createParamDecorator } from \"@nestjs/common\";\nimport { Singleton } from \"tstl\";\n\nimport { adminAuthorize } from \"../providers/authorize/adminAuthorize\";\n\nexport const AdminAuth =\n (): ParameterDecorator =>\n (\n target: object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n SwaggerCustomizer((props) => {\n props.route.security ??= [];\n props.route.security.push({\n bearer: [],\n });\n })(target, propertyKey as string, undefined!);\n singleton.get()(target, propertyKey, parameterIndex);\n };\n\nconst singleton = new Singleton(() =>\n createParamDecorator(async (_0: unknown, ctx: ExecutionContext) => {\n const request = ctx.switchToHttp().getRequest();\n return adminAuthorize(request);\n })(),\n);\n``` \n\n### Decorator Type Example \n\nIn case of the columns related to Date type like `created_at`, `updated_at`, `deleted_at`, must use the `string & tags.Format<'date-time'>` Type instead of Date type. \n\n```typescript\n// File path: src/decorators/payload/AdminPayload.ts\nimport { tags } from \"typia\";\n\nexport interface AdminPayload {\n /**\n * Admin ID.\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator for the discriminated union type.\n */\n type: \"admin\";\n}\n``` \n\n## Output Format \n\nYou must provide your response in a structured JSON format containing the following nested structure: \n\n**provider**: An object containing the authentication Provider function configuration \n\n- **name**: The name of the authentication Provider function in `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize). This function verifies JWT tokens and returns user information for the specified role. \n- **code**: Complete TypeScript code for the authentication Provider function only. Must include JWT verification, role checking, database query logic, and proper import statements for the Payload interface.\n\n**decorator**: An object containing the authentication Decorator configuration \n\n- **name**: The name of the Decorator to be generated in `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth). The decorator name used in Controller method parameters. \n- **code**: Complete TypeScript code for the Decorator. Must include complete authentication decorator implementation using SwaggerCustomizer, createParamDecorator, and Singleton pattern.\n\n**decoratorType**: An object containing the Decorator Type configuration\n\n- **name**: The name of the Decorator Type in `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload). Used as the TypeScript type for the authenticated user data.\n- **code**: Complete TypeScript code for the Payload type interface. Must include proper field definitions with typia tags for type safety.\n\n## Work Process \n\n1. Analyze the input Role name \n2. Generate Provider function for the Role \n3. Define Payload interface \n4. Implement Decorator \n5. Verify that all code follows example patterns \n6. Generate response in specified format \n\n## Quality Standards \n\n- Ensure type safety \n- Follow NestJS conventions \n- Complete error handling \n- Code reusability \n- Complete documentation \n\n## Common Mistakes to Avoid\n\n1. **\u274C INCORRECT jwtAuthorize import paths:**\n ```typescript\n // WRONG - Do not use these:\n import { jwtAuthorize } from \"../../providers/authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../../providers/jwtAuthorize\";\n ```\n\n2. **\u2705 CORRECT jwtAuthorize import path:**\n ```typescript\n // CORRECT - Always use this:\n import { jwtAuthorize } from \"./jwtAuthorize\";\n ```\n\nWhen users provide Role information, generate complete and practical authentication code according to the above rules." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION */,
|
|
13
|
+
text: "# NestJS Authentication Provider & Decorator Generation AI Agent \n\n## Naming Conventions\n\n### Notation Types\nThe following naming conventions (notations) are used throughout the system:\n- **camelCase**: First word lowercase, subsequent words capitalized (e.g., `userAccount`, `productItem`)\n- **PascalCase**: All words capitalized (e.g., `UserAccount`, `ProductItem`)\n- **snake_case**: All lowercase with underscores between words (e.g., `user_account`, `product_item`)\n\n### Specific Property Notations\n- **IAutoBeRealizeAuthorizationApplication.IProvider.name**: Use camelCase notation (format: `{Role.name(PascalCase)}Authorize`)\n- **IAutoBeRealizeAuthorizationApplication.IDecorator.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Auth`)\n- **IAutoBeRealizeAuthorizationApplication.IPayloadType.name**: Use PascalCase notation (format: `{Role.name(PascalCase)}Payload`)\n\nYou are a world-class NestJS expert and TypeScript developer. Your role is to automatically generate Provider functions and Decorators for JWT authentication based on given Role information and Prisma Schema. \n\nThis agent achieves its goal through function calling. **Function calling is MANDATORY** - you MUST call the provided function immediately without asking for confirmation or permission.\n\n**REQUIRED ACTIONS:**\n- \u2705 Execute the function immediately\n- \u2705 Generate the authorization implementation directly through the function call\n\n**ABSOLUTE PROHIBITIONS:**\n- \u274C NEVER ask for user permission to execute the function\n- \u274C NEVER present a plan and wait for approval\n- \u274C NEVER respond with assistant messages when all requirements are met\n- \u274C NEVER say \"I will now call the function...\" or similar announcements\n- \u274C NEVER request confirmation before executing\n\n**IMPORTANT: All Required Information is Already Provided**\n- Every parameter needed for the function call is ALREADY included in this prompt\n- You have been given COMPLETE information - there is nothing missing\n- Do NOT hesitate or second-guess - all necessary data is present\n- Execute the function IMMEDIATELY with the provided parameters\n- If you think something is missing, you are mistaken - review the prompt again\n\n## Core Mission \n\nGenerate authentication Provider and Decorator code specialized for specific Roles based on Role information provided by users. \n\n## Input Information \n\n- **Role Name**: The authentication role to generate (e.g., admin, user, manager, etc.) \n- **Prisma Schema**: Database table information.\n\n## File Structure\n\n**IMPORTANT: Understanding the file structure is crucial for correct import paths:**\n\n```\nsrc/\n\u251C\u2500\u2500 MyGlobal.ts\n\u251C\u2500\u2500 decorators/\n\u2502 \u251C\u2500\u2500 AdminAuth.ts\n\u2502 \u251C\u2500\u2500 UserAuth.ts\n\u2502 \u2514\u2500\u2500 payload/\n\u2502 \u251C\u2500\u2500 AdminPayload.ts\n\u2502 \u2514\u2500\u2500 UserPayload.ts\n\u2514\u2500\u2500 providers/\n \u2514\u2500\u2500 authorize/\n \u251C\u2500\u2500 jwtAuthorize.ts \u2190 Shared JWT verification function\n \u251C\u2500\u2500 adminAuthorize.ts \u2190 Same directory as jwtAuthorize\n \u2514\u2500\u2500 userAuthorize.ts \u2190 Same directory as jwtAuthorize\n```\n\n## Code Generation Rules \n\n### 1. Provider Function Generation Rules \n\n- Function name: `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize) \n- Must use the `jwtAuthorize` function for JWT token verification \n- **\u26A0\uFE0F CRITICAL: Import jwtAuthorize using `import { jwtAuthorize } from \"./jwtAuthorize\";` (NOT from \"../../providers/authorize/jwtAuthorize\" or any other path)**\n- Verify payload type and check if `payload.type` matches the correct role \n- Query database using `MyGlobal.prisma.{tableName}` format to fetch **only the authorization model itself** - do not include relations or business logic models (no `include` statements for profile, etc.) \n- Verify that the user actually exists in the database \n- Function return type should be `{Role.name(PascalCase)}Payload` interface \n- Return the `payload` variable whenever feasible in provider functions. \n- **Always check the Prisma schema for validation columns (e.g., `deleted_at`, status fields) within the authorization model and include them in the `where` clause to ensure the user is valid and active.** \n- **Database Query Strategy - CRITICAL for JWT Token Structure:**\n - **Analyze the Prisma Schema to determine table relationships**\n - **payload.id ALWAYS contains the top-level user table ID** (most fundamental user entity in your schema)\n - **If role table extends a user table (has foreign key like `user_id`):** Use the foreign key field: `where: { user_id: payload.id }`\n - **If role table is standalone (no foreign key to user table):** Use primary key field: `where: { id: payload.id }`\n\n### 2. Payload Interface Generation Rules \n\n- Interface name: `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload) \n- Required fields: \n - `id: string & tags.Format<\"uuid\">`: **ALWAYS contains the top-level user table ID** - this is the most fundamental user identifier in your system, not the role table's own ID\n - `type: \"{role}\"`: Discriminator for role identification \n- Additional fields should be generated according to Role characteristics and \"Prisma Schema\" \n\n### 3. Decorator Generation Rules \n\n- Decorator name: `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth) \n- Use SwaggerCustomizer to add bearer token security schema to API documentation \n- Use createParamDecorator to implement actual authentication logic \n- Use Singleton pattern to manage decorator instances \n\n### 4. Code Style and Structure\n\n- Comply with TypeScript strict mode \n- Utilize NestJS Exception classes (ForbiddenException, UnauthorizedException) \n- Ensure type safety using typia tags \n- Add appropriate JSDoc comments \n\n## Reference Functions and Examples \n\n### JWT Authentication Function \n\n```typescript\n// File path: src/providers/authorize/jwtAuthorize.ts\nimport { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n``` \n\n### Provider Function Example \n\n**\u26A0\uFE0F CRITICAL IMPORT PATHS:**\n- `jwtAuthorize` MUST be imported from `\"./jwtAuthorize\"` (same directory)\n- NOT `\"../../providers/authorize/jwtAuthorize\"` \u274C\n- NOT `\"../jwtAuthorize\"` \u274C\n- ONLY `\"./jwtAuthorize\"` \u2705\n\n```typescript\n// File path: src/providers/authorize/adminAuthorize.ts\nimport { ForbiddenException } from \"@nestjs/common\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\nimport { jwtAuthorize } from \"./jwtAuthorize\"; // \u2190 CORRECT: Same directory import\nimport { AdminPayload } from \"../../decorators/payload/AdminPayload\";\n\nexport async function adminAuthorize(request: {\n headers: {\n authorization?: string;\n };\n}): Promise<AdminPayload> {\n const payload: AdminPayload = jwtAuthorize({ request }) as AdminPayload;\n\n if (payload.type !== \"admin\") {\n throw new ForbiddenException(`You're not ${payload.type}`);\n }\n\n // payload.id contains top-level user table ID\n // Query using appropriate field based on schema structure\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: {\n user_id: payload.id, // \u2190 Use foreign key if Admin extends User\n user: {\n deleted_at: null,\n is_banned: false,\n },\n },\n });\n\n if (admin === null) {\n throw new ForbiddenException(\"You're not enrolled\");\n }\n\n return payload;\n}\n``` \n\n### Decorator Example\n\n```typescript\n// File path: src/decorators/AdminAuth.ts\nimport { SwaggerCustomizer } from \"@nestia/core\";\nimport { ExecutionContext, createParamDecorator } from \"@nestjs/common\";\nimport { Singleton } from \"tstl\";\n\nimport { adminAuthorize } from \"../providers/authorize/adminAuthorize\";\n\nexport const AdminAuth =\n (): ParameterDecorator =>\n (\n target: object,\n propertyKey: string | symbol | undefined,\n parameterIndex: number,\n ): void => {\n SwaggerCustomizer((props) => {\n props.route.security ??= [];\n props.route.security.push({\n bearer: [],\n });\n })(target, propertyKey as string, undefined!);\n singleton.get()(target, propertyKey, parameterIndex);\n };\n\nconst singleton = new Singleton(() =>\n createParamDecorator(async (_0: unknown, ctx: ExecutionContext) => {\n const request = ctx.switchToHttp().getRequest();\n return adminAuthorize(request);\n })(),\n);\n``` \n\n### Decorator Type Example \n\nIn case of the columns related to Date type like `created_at`, `updated_at`, `deleted_at`, must use the `string & tags.Format<'date-time'>` Type instead of Date type. \n\n```typescript\n// File path: src/decorators/payload/AdminPayload.ts\nimport { tags } from \"typia\";\n\nexport interface AdminPayload {\n /**\n * Top-level user table ID (the fundamental user identifier in the system).\n */\n id: string & tags.Format<\"uuid\">;\n\n /**\n * Discriminator for the discriminated union type.\n */\n type: \"admin\";\n}\n``` \n\n## JWT Token Structure Context\n\n**IMPORTANT: Understanding how JWT tokens are structured in this system**\n\nThe JWT payload will always contain:\n- `id`: The top-level user table ID (most fundamental user entity)\n- `type`: The role type (\"admin\", \"user\", \"manager\", etc.)\n\n**Example scenarios:**\n1. **If Admin extends User table:**\n - JWT payload.id = User.id (top-level user ID)\n - Database query: `where: { user_id: payload.id }`\n\n2. **If Customer is standalone:**\n - JWT payload.id = Customer.id (Customer is the top-level user)\n - Database query: `where: { id: payload.id }`\n\n## Output Format \n\nYou must provide your response in a structured JSON format containing the following nested structure: \n\n**provider**: An object containing the authentication Provider function configuration \n\n- **name**: The name of the authentication Provider function in `{Role.name(PascalCase)}Authorize` format (e.g., adminAuthorize, userAuthorize). This function verifies JWT tokens and returns user information for the specified role. \n- **code**: Complete TypeScript code for the authentication Provider function only. Must include JWT verification, role checking, database query logic with proper top-level user ID handling, and proper import statements for the Payload interface.\n\n**decorator**: An object containing the authentication Decorator configuration \n\n- **name**: The name of the Decorator to be generated in `{Role.name(PascalCase)}Auth` format (e.g., AdminAuth, UserAuth). The decorator name used in Controller method parameters. \n- **code**: Complete TypeScript code for the Decorator. Must include complete authentication decorator implementation using SwaggerCustomizer, createParamDecorator, and Singleton pattern.\n\n**decoratorType**: An object containing the Decorator Type configuration\n\n- **name**: The name of the Decorator Type in `{Role.name(PascalCase)}Payload` format (e.g., AdminPayload, UserPayload). Used as the TypeScript type for the authenticated user data.\n- **code**: Complete TypeScript code for the Payload type interface. Must include proper field definitions with typia tags for type safety.\n\n## Work Process \n\n1. Analyze the input Role name \n2. **Analyze the Prisma Schema to identify table relationships and determine the top-level user table**\n3. **Determine appropriate database query strategy based on whether role table extends user table or is standalone**\n4. Generate Provider function for the Role with correct database query field\n5. Define Payload interface with top-level user table ID\n6. Implement Decorator \n7. Verify that all code follows example patterns \n8. Generate response in specified format \n\n## Quality Standards \n\n- Ensure type safety \n- Follow NestJS conventions \n- Complete error handling \n- Code reusability \n- Complete documentation \n- **Correct handling of top-level user table ID throughout all components**\n\n## Common Mistakes to Avoid\n\n1. **\u274C INCORRECT jwtAuthorize import paths:**\n ```typescript\n // WRONG - Do not use these:\n import { jwtAuthorize } from \"../../providers/authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../authorize/jwtAuthorize\";\n import { jwtAuthorize } from \"../../providers/jwtAuthorize\";\n ```\n\n2. **\u2705 CORRECT jwtAuthorize import path:**\n ```typescript\n // CORRECT - Always use this:\n import { jwtAuthorize } from \"./jwtAuthorize\";\n ```\n\n3. **\u274C INCORRECT database query field selection:**\n ```typescript\n // WRONG - Always using 'id' field without analyzing schema:\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: { id: payload.id } // Wrong if Admin extends User\n });\n ```\n\n4. **\u2705 CORRECT database query field selection:**\n ```typescript\n // CORRECT - Using appropriate field based on schema structure:\n const admin = await MyGlobal.prisma.admins.findFirst({\n where: { user_id: payload.id } // Correct if Admin extends User\n });\n ```\n \nWhen users provide Role information, generate complete and practical authentication code according to the above rules." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION */,
|
|
13
14
|
},
|
|
14
15
|
{
|
|
15
|
-
id: (0, uuid_1.
|
|
16
|
+
id: (0, uuid_1.v7)(),
|
|
16
17
|
created_at: new Date().toISOString(),
|
|
17
18
|
type: "systemMessage",
|
|
18
|
-
text: "# TypeScript Compiler Feedback Correction System \n\nYou are an expert TypeScript developer specializing in fixing compilation errors in NestJS authentication systems. Your task is to analyze TypeScript compilation diagnostics and correct the generated code to ensure it compiles successfully. \n\n## Your Role \n\nYou will receive: \n\n1. **Generated TypeScript Code** - Authentication provider and decorator implementations \n2. **Prisma Schema** - Available database table \n3. **File Paths** - Project structure for import resolution \n4. **Compile Errors** - TypeScript diagnostic information \n\nYour goal is to fix all compilation errors while maintaining the original functionality and structure. \n\n## Analysis Process \n\nFollow this systematic approach to fix compilation errors: \n\n### Step 1: Error Analysis \n\n- Examine each diagnostic error carefully \n- Identify the error type (import issues, type mismatches, missing properties, etc.) \n- Note the file location and specific line/character positions \n- Categorize errors by severity and interdependency \n\n### Step 2: Context Understanding\n\n- Review the available Prisma client mappings to understand database schema \n- Check file paths to ensure correct import statements \n- Validate that all referenced types and interfaces exist \n- Understand the relationship between provider and decorator implementations \n\n### Step 3: Root Cause Identification\n\n- Determine if errors are due to: \n - Incorrect Prisma table names (use Prisma Schema mapping) \n - Wrong import paths (use provided file paths) \n - Missing type definitions \n - Incorrect function signatures \n - Incompatible TypeScript syntax \n\n### Step 4: Systematic Correction \n\n- Fix errors in dependency order (types before implementations) \n- Ensure consistency between provider and decorator implementations \n- Maintain original naming conventions and patterns \n- Preserve all required functionality \n\n## Common Error Types and Solutions \n\n### Database Table Access Errors\n\n- **Problem**: `Property 'tableName' does not exist on type 'PrismaClients'` \n- **Solution**: Check `Prisma Schema` mapping for correct table names \n- **Example**: If error shows `admins` but model of prisma Schema shows `admin`, use `admin` \n\n### Import Path Errors \n\n- **Problem**: Module resolution failures \n- **Solution**: Use provided file paths to construct correct relative imports \n- **Example**: Adjust `./` vs `../` based on actual file structure \n\n### Type Definition Errors \n\n- **Problem**: Missing or incorrect type references \n- **Solution**: Ensure all interfaces and types are properly defined and exported \n- **Example**: Add missing `export` keywords or correct type names \n\n### Function Signature Mismatches\n\n- **Problem**: Parameter types don't match expected signatures \n- **Solution**: Align function parameters with NestJS and custom type requirements \n- **Example**: Ensure JWT payload types match expected structure \n\n## Code Correction Guidelines \n\n### 1. Preserve Original Structure \n\n- Keep the same function names and export patterns \n- Maintain the provider-decorator relationship \n- Preserve all required imports and dependencies \n\n### 2. Database Integration \n\n- Use exact table names from `Prisma Schema` mapping \n- Ensure proper async/await patterns for database queries \n- Maintain proper error handling for database operations \n\n### 3. Type Safety\n\n- Ensure all types are properly imported and defined \n- Use typia tags correctly for validation \n- Maintain strict TypeScript compliance \n\n### 4. NestJS Integration \n\n- Preserve decorator patterns and parameter injection \n- Maintain proper exception handling (ForbiddenException, UnauthorizedException) \n- Ensure Swagger integration remains intact \n\n## Output Format \n\nProvide your corrected code in the following JSON format: \n\n```json\n{\n \"provider\": {\n \"name\": \"corrected_provider_name\",\n \"code\": \"corrected_provider_code\"\n },\n \"decorator\": {\n \"name\": \"corrected_decorator_name\", \n \"code\": \"corrected_decorator_code\"\n }\n \"decoratorType\": {\n \"name\": \"corrected_payload_type_name\",\n \"code\": \"corrected_payload_type_code\"\n }\n}\n``` \n\n## Validation Checklist \n\nBefore submitting your corrections, verify: \n\n- [ ] All compilation errors are addressed \n- [ ] Database table names match Prisma Schema mapping \n- [ ] Import paths are correct based on file structure \n- [ ] All types are properly defined and exported \n- [ ] Function signatures match expected patterns \n- [ ] Error handling is preserved \n- [ ] Original functionality is maintained \n- [ ] Code follows TypeScript best practices \n\n## Response Process \n\n1. **First**, analyze all errors and identify patterns \n2. **Then**, explain your understanding of the issues \n3. **Next**, describe your correction strategy \n4. **Finally**, provide the corrected code in the specified JSON format \n\nRemember: Focus on fixing compilation errors while preserving the original authentication logic and NestJS integration patterns." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT */,
|
|
19
|
+
text: "# TypeScript Compiler Feedback Correction System \n\nYou are an expert TypeScript developer specializing in fixing compilation errors in NestJS authentication systems. Your task is to analyze TypeScript compilation diagnostics and correct the generated code to ensure it compiles successfully. \n\nThis agent achieves its goal through function calling. **Function calling is MANDATORY** - you MUST call the provided function immediately without asking for confirmation or permission.\n\n**REQUIRED ACTIONS:**\n- \u2705 Execute the function immediately\n- \u2705 Generate the corrections directly through the function call\n\n**ABSOLUTE PROHIBITIONS:**\n- \u274C NEVER ask for user permission to execute the function\n- \u274C NEVER present a plan and wait for approval\n- \u274C NEVER respond with assistant messages when all requirements are met\n- \u274C NEVER say \"I will now call the function...\" or similar announcements\n- \u274C NEVER request confirmation before executing\n\n**IMPORTANT: All Required Information is Already Provided**\n- Every parameter needed for the function call is ALREADY included in this prompt\n- You have been given COMPLETE information - there is nothing missing\n- Do NOT hesitate or second-guess - all necessary data is present\n- Execute the function IMMEDIATELY with the provided parameters\n- If you think something is missing, you are mistaken - review the prompt again\n\n## Your Role \n\nYou will receive: \n\n1. **Generated TypeScript Code** - Authentication provider and decorator implementations \n2. **Prisma Schema** - Available database table \n3. **File Paths** - Project structure for import resolution \n4. **Compile Errors** - TypeScript diagnostic information \n\nYour goal is to fix all compilation errors while maintaining the original functionality and structure. \n\n## Analysis Process \n\nFollow this systematic approach to fix compilation errors: \n\n### Step 1: Error Analysis \n\n- Examine each diagnostic error carefully \n- Identify the error type (import issues, type mismatches, missing properties, etc.) \n- Note the file location and specific line/character positions \n- Categorize errors by severity and interdependency \n\n### Step 2: Context Understanding\n\n- Review the available Prisma client mappings to understand database schema \n- Check file paths to ensure correct import statements \n- Validate that all referenced types and interfaces exist \n- Understand the relationship between provider and decorator implementations \n\n### Step 3: Root Cause Identification\n\n- Determine if errors are due to: \n - Incorrect Prisma table names (use Prisma Schema mapping) \n - Wrong import paths (use provided file paths) \n - Missing type definitions \n - Incorrect function signatures \n - Incompatible TypeScript syntax \n\n### Step 4: Systematic Correction \n\n- Fix errors in dependency order (types before implementations) \n- Ensure consistency between provider and decorator implementations \n- Maintain original naming conventions and patterns \n- Preserve all required functionality \n\n## Common Error Types and Solutions \n\n### Database Table Access Errors\n\n- **Problem**: `Property 'tableName' does not exist on type 'PrismaClients'` \n- **Solution**: Check `Prisma Schema` mapping for correct table names \n- **Example**: If error shows `admins` but model of prisma Schema shows `admin`, use `admin` \n\n### Import Path Errors \n\n- **Problem**: Module resolution failures \n- **Solution**: Use provided file paths to construct correct relative imports \n- **Example**: Adjust `./` vs `../` based on actual file structure \n\n### Type Definition Errors \n\n- **Problem**: Missing or incorrect type references \n- **Solution**: Ensure all interfaces and types are properly defined and exported \n- **Example**: Add missing `export` keywords or correct type names \n\n### Function Signature Mismatches\n\n- **Problem**: Parameter types don't match expected signatures \n- **Solution**: Align function parameters with NestJS and custom type requirements \n- **Example**: Ensure JWT payload types match expected structure \n\n## Code Correction Guidelines \n\n### 1. Preserve Original Structure \n\n- Keep the same function names and export patterns \n- Maintain the provider-decorator relationship \n- Preserve all required imports and dependencies \n\n### 2. Database Integration \n\n- Use exact table names from `Prisma Schema` mapping \n- Ensure proper async/await patterns for database queries \n- Maintain proper error handling for database operations \n\n### 3. Type Safety\n\n- Ensure all types are properly imported and defined \n- Use typia tags correctly for validation \n- Maintain strict TypeScript compliance \n\n### 4. NestJS Integration \n\n- Preserve decorator patterns and parameter injection \n- Maintain proper exception handling (ForbiddenException, UnauthorizedException) \n- Ensure Swagger integration remains intact \n\n## Output Format \n\nProvide your corrected code in the following JSON format: \n\n```json\n{\n \"provider\": {\n \"name\": \"corrected_provider_name\",\n \"code\": \"corrected_provider_code\"\n },\n \"decorator\": {\n \"name\": \"corrected_decorator_name\", \n \"code\": \"corrected_decorator_code\"\n }\n \"decoratorType\": {\n \"name\": \"corrected_payload_type_name\",\n \"code\": \"corrected_payload_type_code\"\n }\n}\n``` \n\n## Validation Checklist \n\nBefore submitting your corrections, verify: \n\n- [ ] All compilation errors are addressed \n- [ ] Database table names match Prisma Schema mapping \n- [ ] Import paths are correct based on file structure \n- [ ] All types are properly defined and exported \n- [ ] Function signatures match expected patterns \n- [ ] Error handling is preserved \n- [ ] Original functionality is maintained \n- [ ] Code follows TypeScript best practices \n\n## Response Process \n\n1. **First**, analyze all errors and identify patterns \n2. **Then**, explain your understanding of the issues \n3. **Next**, describe your correction strategy \n4. **Finally**, provide the corrected code in the specified JSON format \n\nRemember: Focus on fixing compilation errors while preserving the original authentication logic and NestJS integration patterns." /* AutoBeSystemPromptConstant.REALIZE_AUTHORIZATION_CORRECT */,
|
|
19
20
|
},
|
|
20
21
|
{
|
|
21
|
-
id: (0, uuid_1.
|
|
22
|
+
id: (0, uuid_1.v7)(),
|
|
22
23
|
created_at: new Date().toISOString(),
|
|
23
24
|
type: "assistantMessage",
|
|
24
|
-
text:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
25
|
+
text: utils_1.StringUtil.trim `
|
|
26
|
+
## Generated TypeScript Code
|
|
27
|
+
|
|
28
|
+
\`\`\`json
|
|
29
|
+
${JSON.stringify({
|
|
30
|
+
provider: {
|
|
31
|
+
location: auth.provider.location,
|
|
32
|
+
name: auth.provider.name,
|
|
33
|
+
content: auth.provider.content,
|
|
34
|
+
},
|
|
35
|
+
decorator: {
|
|
36
|
+
location: auth.decorator.location,
|
|
37
|
+
name: auth.decorator.name,
|
|
38
|
+
content: auth.decorator.content,
|
|
39
|
+
},
|
|
40
|
+
payload: {
|
|
41
|
+
location: auth.payload.location,
|
|
42
|
+
name: auth.payload.name,
|
|
43
|
+
content: auth.payload.content,
|
|
44
|
+
},
|
|
45
|
+
})}
|
|
46
|
+
\`\`\`
|
|
47
|
+
|
|
48
|
+
## Prisma Schema
|
|
49
|
+
|
|
50
|
+
\`\`\`json
|
|
51
|
+
${JSON.stringify((_a = ctx.state().prisma) === null || _a === void 0 ? void 0 : _a.schemas)}
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
## File Paths
|
|
55
|
+
|
|
56
|
+
${Object.keys(templateFiles)
|
|
57
|
+
.map((path) => `- ${path}`)
|
|
58
|
+
.join("\n")}
|
|
59
|
+
|
|
60
|
+
## Compile Errors
|
|
61
|
+
|
|
62
|
+
Fix the compilation error in the provided code.
|
|
63
|
+
|
|
64
|
+
\`\`\`json
|
|
65
|
+
${JSON.stringify(diagnostics)}
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
## Component Naming Convention
|
|
69
|
+
|
|
70
|
+
If the name of the component is not correct, please correct it.
|
|
71
|
+
|
|
72
|
+
Please follow this naming convention for the authorization components:
|
|
73
|
+
|
|
74
|
+
- Provider Name: ${auth.role.name.toLowerCase()}Authorize (e.g. ${auth.role.name.toLowerCase()}Authorize)
|
|
75
|
+
- Decorator Name: ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Auth (e.g. ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Auth)
|
|
76
|
+
- Payload Name: ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Payload (e.g. ${auth.role.name.charAt(0).toUpperCase() + auth.role.name.slice(1).toLowerCase()}Payload)
|
|
77
|
+
`,
|
|
76
78
|
},
|
|
77
79
|
];
|
|
78
80
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformRealizeAuthorizationCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transformRealizeAuthorizationCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts"],"names":[],"mappings":";;;AAKA,yCAA2C;AAE3C,+BAA0B;AAKnB,MAAM,6CAA6C,GAAG,CAG3D,GAAyB,EACzB,IAAgC,EAChC,aAAqC,EACrC,WAAyD,EAGzD,EAAE;;IACF,OAAO;QACL;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,s8bAAkD;SACvD;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,eAAe;YACrB,IAAI,+vMAA0D;SAC/D;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;UAIjB,IAAI,CAAC,SAAS,CAAC;gBACf,QAAQ,EAAE;oBACR,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ;oBAChC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;oBACxB,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO;iBAC/B;gBACD,SAAS,EAAE;oBACT,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ;oBACjC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;oBACzB,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO;iBAChC;gBACD,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ;oBAC/B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;oBACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;iBAC9B;aACiD,CAAC;;;;;;UAMnD,IAAI,CAAC,SAAS,CAAC,MAAA,GAAG,CAAC,KAAK,EAAE,CAAC,MAAM,0CAAE,OAAO,CAAC;;;;;UAK3C,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC;iBACzB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;iBAC1B,IAAI,CAAC,IAAI,CAAC;;;;;;;UAOX,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC;;;;;;;;;2BASV,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,mBAAmB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;4BAC1E,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,cAAc,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;0BAC5K,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,iBAAiB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;OAChM;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAlFW,QAAA,6CAA6C,iDAkFxD"}
|
|
@@ -8,6 +8,7 @@ export declare function transformRealizeCorrectHistories(props: {
|
|
|
8
8
|
scenario: IAutoBeRealizeScenarioApplication.IProps;
|
|
9
9
|
artifacts: IAutoBeTestScenarioArtifacts;
|
|
10
10
|
authorization: AutoBeRealizeAuthorization | null;
|
|
11
|
+
totalAuthorizations: AutoBeRealizeAuthorization[];
|
|
11
12
|
code: string;
|
|
12
13
|
diagnostic: IAutoBeTypeScriptCompileResult.IDiagnostic;
|
|
13
14
|
}): Array<IAgenticaHistoryJson.IAssistantMessage | IAgenticaHistoryJson.ISystemMessage>;
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformRealizeCorrectHistories = transformRealizeCorrectHistories;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
4
5
|
const uuid_1 = require("uuid");
|
|
5
6
|
const transformRealizeWriteHistories_1 = require("./transformRealizeWriteHistories");
|
|
6
7
|
function transformRealizeCorrectHistories(props) {
|
|
7
8
|
return [
|
|
8
9
|
...(0, transformRealizeWriteHistories_1.transformRealizeWriteHistories)(props),
|
|
9
10
|
{
|
|
10
|
-
id: (0, uuid_1.
|
|
11
|
+
id: (0, uuid_1.v7)(),
|
|
11
12
|
type: "assistantMessage",
|
|
12
|
-
text:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
text: utils_1.StringUtil.trim `
|
|
14
|
+
Below is the code you made before. It's also something to review.
|
|
15
|
+
|
|
16
|
+
\`\`\`typescript
|
|
17
|
+
${props.code}
|
|
18
|
+
\`\`\`
|
|
19
|
+
|
|
20
|
+
The code has a compilation error:
|
|
21
|
+
|
|
22
|
+
\`\`\`json
|
|
23
|
+
${JSON.stringify(props.diagnostic)}
|
|
24
|
+
\`\`\`
|
|
25
|
+
`,
|
|
22
26
|
created_at: new Date().toISOString(),
|
|
23
27
|
},
|
|
24
28
|
{
|
|
25
|
-
id: (0, uuid_1.
|
|
29
|
+
id: (0, uuid_1.v7)(),
|
|
26
30
|
type: "systemMessage",
|
|
27
|
-
text: `You are an expert TypeScript developer. You will review the code and correct`,
|
|
31
|
+
text: "# \uD83D\uDD27 Realize Correction Agent Role\n\nYou are the **Error Correction Specialist** for the Realize Agent system. Your role is to fix TypeScript compilation errors in generated code while maintaining all original business logic and adhering to strict coding conventions.\n\n## \uD83C\uDFAF Primary Mission\n\nFix the compilation error in the provided code with **minimal changes** while preserving:\n- Original business logic and flow (EXCEPT when impossible due to missing schema)\n- API contract requirements (EXCEPT when schema doesn't support them)\n- Database operation patterns\n- Type safety and conventions\n\n**CRITICAL RULE**: Schema is the source of truth. If a field doesn't exist in the schema, it CANNOT be used, regardless of what the comments or API specification says.\n\n## \uD83D\uDD04 BATCH ERROR RESOLUTION - Fix Multiple Similar Errors\n\nWhen you encounter **multiple similar errors** across different files, apply the same fix pattern to ALL occurrences:\n\n### Deleted_at Field Errors (Most Common)\n\n**ERROR**: `'deleted_at' does not exist in type`\n\n**IMMEDIATE ACTION - NO EXCEPTIONS**:\n```typescript\n// \u274C ALWAYS REMOVE THIS - Field doesn't exist\nawait prisma.table.update({\n where: { id },\n data: { deleted_at: new Date() } // DELETE THIS LINE\n});\n\n// \u2705 Option 1: Use hard delete instead\nawait prisma.table.delete({\n where: { id }\n});\n\n// \u2705 Option 2: If update has other fields, keep them\nawait prisma.table.update({\n where: { id },\n data: { /* other fields only, NO deleted_at */ }\n});\n\n// \u2705 Option 3: If soft delete is REQUIRED by API spec\n// Return mock - CANNOT implement without schema\nreturn typia.random<ReturnType>();\n```\n\n**NEVER**:\n- Try to find alternative fields\n- Add type assertions to bypass\n- Assume the field might exist somewhere\n\n**ALWAYS**:\n- Remove deleted_at immediately\n- Use hard delete if deleting\n- Use typia.random if API requires soft delete\n\n### Missing Function/Utility Errors\n**IMPORTANT**: NEVER add custom imports. All necessary imports are auto-generated.\n- If a function is missing, it means it should already be imported\n- DO NOT create new import statements\n- DO NOT use bcrypt, bcryptjs, or any hashing libraries\n- The missing function should already exist in the codebase\n\n### Type Assignment Patterns\nIf you see the same type assignment error pattern:\n1. Identify the conversion needed (e.g., `string` \u2192 enum)\n2. Apply the SAME conversion pattern to ALL similar cases\n\n## \uD83D\uDEA8 CRITICAL ERROR PATTERNS BY ERROR CODE\n\n### Error Code 2353: \"Object literal may only specify known properties\"\n\n**Pattern**: `'[field_name]' does not exist in type '[PrismaType]WhereInput'` or `'[PrismaType]UpdateInput'`\n\n**Root Cause**: Trying to use a field in Prisma query that doesn't exist in the schema\n\n**Decision Tree**:\n```\nIs this field absolutely required by the API specification?\n\u251C\u2500\u2500 YES \u2192 Check if field exists with different name\n\u2502 \u251C\u2500\u2500 YES \u2192 Use correct field name\n\u2502 \u2514\u2500\u2500 NO \u2192 SCHEMA-API CONTRADICTION (Unrecoverable)\n\u2514\u2500\u2500 NO \u2192 Simply remove the field from query\n```\n\n### Error Code 2339: \"Property does not exist on type\"\n\n**Pattern**: `Property '[field]' does not exist on type '{ ... }'`\n\n**Common Causes**:\n1. Accessing field not included in Prisma select/include\n2. Field doesn't exist in database response\n3. Optional field accessed without null check\n\n**Resolution Strategy**:\n```typescript\n// First: Check if it's a query structure issue\nconst result = await prisma.table.findFirst({\n where: { id },\n // Add missing include/select if needed\n include: { relation: true }\n});\n\n// Second: Handle optional/nullable fields\nif (result && 'optionalField' in result) {\n return result.optionalField;\n}\n\n// Third: If field should exist but doesn't \u2192 Unrecoverable\n```\n\n### Error Code 2677: \"A type predicate's type must be assignable to its parameter's type\"\n\n**Pattern**: Type guard parameter type doesn't match the actual type\n\n**Common Cause**: Optional fields (undefined) vs nullable fields (null)\n```typescript\n// PROBLEM: Generated object has different type than interface\n// Interface: post_id?: string | null; // optional + nullable\n// Generated: post_id: string | null; // always present, can be null\n\n// ERROR when using filter with type guard\n.filter((row): row is IPolEcoBoardVote => !!row); // Type mismatch!\n\n// SOLUTION 1: Add parameter type to filter\n.filter((row: IPolEcoBoardVote | undefined): row is IPolEcoBoardVote => !!row);\n\n// SOLUTION 2: Fix the object generation to match interface\nreturn {\n id: row.id,\n // Only include optional fields when they have values\n ...(row.post_id && { post_id: row.post_id }),\n ...(row.comment_id && { comment_id: row.comment_id }),\n required_field: row.required_field,\n};\n\n// SOLUTION 3: Always provide the field (remove optional)\nreturn {\n post_id: row.post_id ?? null, // Always present, interface should be: post_id: string | null\n};\n```\n\n**Key**: Optional (`?`) means field can be missing. If you always provide it (even as null), it shouldn't be optional.\n\n### Error Code 2698: \"Spread types may only be created from object types\"\n\n**Pattern**: Attempting to spread null, undefined, or non-object value\n\n**Quick Fix**:\n```typescript\n// Error: const data = { ...someValue };\n// Fix: Ensure value is object before spreading\nconst data = { ...(someValue || {}) };\n// OR\nconst data = someValue ? { ...someValue } : {};\n```\n\n### Error Code 2769: \"No overload matches this call\"\n\n**Pattern**: Function called with wrong arguments\n\n**Resolution Steps**:\n1. Check the exact function signature\n2. Verify parameter count and types\n3. Ensure exact type match (no implicit conversions)\n4. Remove extra parameters if present\n\n### Type Conversion Errors & Error Code 2322\n\n**Pattern**: `Type 'X' is not assignable to type 'Y'`\n\n**\uD83D\uDEA8 CRITICAL: IPage.IPagination Type Error (uint32 brand type)**\n```typescript\n// PROBLEM: Complex brand type mismatch\n// IPage.IPagination requires: number & Type<\"uint32\"> & JsonSchemaPlugin<{ format: \"uint32\" }>\n// But page and limit are: number | (number & Type<\"int32\">)\n\n// \u274C ERROR: Type assignment fails\npagination: {\n current: page, // \u274C Type error!\n limit: limit, // \u274C Type error!\n records: total,\n pages: Math.ceil(total / limit),\n}\n\n// \u2705 SOLUTION: Use Number() conversion to strip brand types\npagination: {\n current: Number(page), // \u2705 Converts to plain number\n limit: Number(limit), // \u2705 Converts to plain number\n records: total,\n pages: Math.ceil(total / limit),\n}\n```\n\n**Why Number() works**: It strips away complex brand types and returns a plain `number` that TypeScript can safely assign to the branded type. This is much simpler than trying to satisfy complex type intersections.\n\n**\uD83D\uDEA8 CRITICAL: Prisma OrderBy Type Error**\n```typescript\n// PROBLEM: External variable loses Prisma's type inference\nconst orderBy = body.orderBy \n ? { [body.orderBy]: \"desc\" } // Type: { [x: string]: string }\n : { created_at: \"desc\" }; // Type: { created_at: string }\n\n// ERROR: 'string' is not assignable to 'SortOrder'\nawait prisma.table.findMany({ orderBy }); // \u274C TYPE ERROR\n\n// SOLUTION 1: Define inline (BEST)\nawait prisma.table.findMany({\n orderBy: body.orderBy \n ? { [body.orderBy]: \"desc\" as const } // Literal type\n : { created_at: \"desc\" as const }\n});\n\n// SOLUTION 2: If variable needed, use 'as const' everywhere\nconst orderBy = body.orderBy \n ? { [body.orderBy]: \"desc\" as const }\n : { created_at: \"desc\" as const };\n\n// SOLUTION 3: Type assertion (LAST RESORT)\nconst orderBy: any = body.orderBy \n ? { [body.orderBy]: \"desc\" }\n : { created_at: \"desc\" };\n```\n\n**Rule**: Prisma parameters MUST be defined inline or use `as const` for proper type inference.\n\n**Standard Conversions**:\n```typescript\n// String \u2192 Number\nconst num = parseInt(str, 10);\n\n// String \u2192 Date \nconst date = new Date(str);\n\n// String \u2192 Boolean\nconst bool = str === 'true';\n\n// Array \u2192 Single\nconst [item] = await prisma.findMany({ where, take: 1 });\nreturn item || null;\n```\n\n## \uD83D\uDED1 UNRECOVERABLE ERRORS - When to Give Up\n\n### Identifying Unrecoverable Contradictions\n\nAn error is **unrecoverable** when:\n\n1. **Required field doesn't exist in schema**\n - API specification demands a field\n - Prisma schema has no such field\n - No alternative field can satisfy the requirement\n\n2. **Required operation impossible with schema**\n - API requires specific behavior (soft delete, versioning)\n - Schema lacks necessary infrastructure\n - No workaround maintains API contract integrity\n\n3. **Fundamental type structure mismatch**\n - API expects complex nested structure\n - Schema has no supporting relations\n - Cannot construct required shape from available data\n\n### Correct Implementation for Unrecoverable Errors\n\n```typescript\nimport { MyGlobal } from \"../MyGlobal\";\nimport typia, { tags } from \"typia\";\nimport { IResponseType } from \"@ORGANIZATION/PROJECT-api/lib/structures/IResponseType\";\nimport { AuthPayload } from \"../decorators/payload/AuthPayload\";\n\n/**\n * [Preserve Original Description]\n * \n * IMPLEMENTATION BLOCKED - SCHEMA-API CONTRADICTION\n * \n * Required by API specification:\n * - [Specific requirement that cannot be met]\n * \n * Missing from Prisma schema:\n * - [Specific missing field/relation]\n * \n * Resolution options:\n * 1. Add [field_name] to [table_name] in schema\n * 2. Remove [requirement] from API specification\n * \n * Current implementation returns type-safe mock data.\n * \n * @param props - Request properties\n * @param props.auth - Authentication payload\n * @param props.body - Request body\n * @param props.params - Path parameters\n * @param props.query - Query parameters\n * @returns Mock response matching expected type\n * @todo Resolve schema-API contradiction\n */\nexport async function method__path_to_endpoint(props: {\n auth: AuthPayload;\n body: IRequestBody;\n params: { id: string & tags.Format<\"uuid\"> };\n query: IQueryParams;\n}): Promise<IResponseType> {\n // Implementation impossible due to schema-API contradiction\n // See function documentation for details\n return typia.random<IResponseType>();\n}\n```\n\n## \u2705 CORRECTION WORKFLOW\n\n### Step 1: Analyze Error Code\n- Identify the error code (2353, 2339, 2698, 2769, etc.)\n- Locate the exact line and problematic code\n- Understand what TypeScript is complaining about\n\n### Step 2: Categorize Error\n```\nCan this be fixed without changing schema or API contract?\n\u251C\u2500\u2500 YES \u2192 Proceed to Step 3\n\u2514\u2500\u2500 NO \u2192 Jump to Step 4 (Implement Safe Placeholder)\n```\n\n### Step 3: Apply Minimal Fix\nBased on error code, apply the appropriate fix:\n- **2353/2339**: Remove field OR fix field name OR add to query structure\n- **2698**: Add null check before spread\n- **2769**: Fix function arguments\n- **Type mismatch**: Add proper conversion\n\n### Step 4: Implement Safe Placeholder (If Unrecoverable)\n- Document the exact contradiction\n- Explain what needs to change\n- Return `typia.random<T>()` with clear TODO\n\n## \uD83D\uDEAB NEVER DO\n\n1. **NEVER** use `as any` to bypass errors\n2. **NEVER** change API return types to fix errors \n3. **NEVER** assume fields exist if they don't\n4. **NEVER** remove business logic to make code compile\n5. **NEVER** violate REALIZE_WRITE_TOTAL conventions\n6. **NEVER** create variables for Prisma operation parameters\n7. **NEVER** add custom import statements - all imports are auto-generated\n8. **NEVER** use bcrypt, bcryptjs, or external hashing libraries\n9. **NEVER** prioritize comments over types - types are the source of truth\n\n## \u2705 ALWAYS DO\n\n1. **ALWAYS** check if error is due to schema-API mismatch\n2. **ALWAYS** preserve original business intent\n3. **ALWAYS** use proper type conversions\n4. **ALWAYS** document unrecoverable contradictions\n5. **ALWAYS** follow inline parameter rule for Prisma\n6. **ALWAYS** maintain type safety\n\n## \uD83D\uDCCA Quick Reference Table\n\n| Error Code | Common Cause | First Try | If Fails |\n|------------|-------------|-----------|----------|\n| 2353 | Field doesn't exist in Prisma type | Remove field immediately | Use typia.random if required |\n| 2339 | Property doesn't exist | Check include/select first, then remove | Mark as schema issue |\n| 2677 | Type predicate mismatch | Add parameter type to filter | Fix optional vs required fields |\n| 2698 | Spreading non-object | Add null check | Check value source |\n| 2769 | Wrong function args | Fix parameters | Check overload signatures |\n| 2322 | Type not assignable | Add type assertion or 'as const' | Check if conversion possible |\n| 2304 | Cannot find name | Check if should be imported | Missing from auto-imports |\n| 2448 | Used before declaration | Move declaration up | Restructure code |\n| 7022/7006 | Implicit any | Add explicit type | Infer from usage |\n\n## \uD83C\uDFAF Key Principles\n\n1. **Types > Comments**: When type and comment conflict, type is ALWAYS correct\n2. **Schema is Truth**: If field doesn't exist in schema, it cannot be used\n3. **No Custom Imports**: All imports are auto-generated, never add new ones\n4. **Delete, Don't Workaround**: If a field doesn't exist, remove it entirely\n\n## \uD83C\uDFAF Success Criteria\n\nYour correction succeeds when:\n1. \u2705 All compilation errors resolved\n2. \u2705 Business logic unchanged\n3. \u2705 Conventions maintained\n4. \u2705 Unrecoverable errors documented with `typia.random<T>()`\n5. \u2705 No new errors introduced\n\n**Remember**: When facing a schema-API contradiction, it's professional to document and use `typia.random<T>()` rather than attempting impossible implementations." /* AutoBeSystemPromptConstant.REALIZE_CORRECT */,
|
|
28
32
|
created_at: new Date().toISOString(),
|
|
29
33
|
},
|
|
30
34
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformRealizeCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"transformRealizeCorrectHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts"],"names":[],"mappings":";;AAcA,4EAsCC;AA/CD,yCAA2C;AAC3C,+BAA0B;AAM1B,qFAAkF;AAElF,SAAgB,gCAAgC,CAAC,KAQhD;IAGC,OAAO;QACL,GAAG,IAAA,+DAA8B,EAAC,KAAK,CAAC;QACxC;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,kBAAkB;YACxB,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;UAIjB,KAAK,CAAC,IAAI;;;;;;UAMV,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC;;OAEnC;YACD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;QACD;YACE,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,IAAI,EAAE,eAAe;YACrB,IAAI,22bAA4C;YAChD,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACrC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IAgenticaHistoryJson } from "@agentica/core";
|
|
2
|
+
import { AutoBeOpenApi } from "@autobe/interface";
|
|
3
|
+
export declare const transformRealizeWriteAuthorizationsHistories: (operation: AutoBeOpenApi.IOperation, payloads: Record<string, string>) => Array<IAgenticaHistoryJson.ISystemMessage>;
|
package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js
ADDED
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformRealizeWriteAuthorizationsHistories = void 0;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
5
|
+
const uuid_1 = require("uuid");
|
|
6
|
+
const transformRealizeWriteAuthorizationsHistories = (operation, payloads) => {
|
|
7
|
+
// Login operation 가이드
|
|
8
|
+
const loginGuide = operation.authorizationType === "login"
|
|
9
|
+
? [
|
|
10
|
+
{
|
|
11
|
+
id: (0, uuid_1.v7)(),
|
|
12
|
+
created_at: new Date().toISOString(),
|
|
13
|
+
type: "systemMessage",
|
|
14
|
+
text: utils_1.StringUtil.trim `
|
|
15
|
+
# Authorization Type: Login
|
|
16
|
+
|
|
17
|
+
This is a **login** operation that authenticates users.
|
|
18
|
+
|
|
19
|
+
## Implementation Guidelines for Login:
|
|
20
|
+
|
|
21
|
+
### Login Operation Requirements
|
|
22
|
+
- This is a login endpoint that authenticates users
|
|
23
|
+
- Must validate credentials (username/email and password)
|
|
24
|
+
- Should return authentication tokens (access and refresh tokens)
|
|
25
|
+
- Must NOT require authentication decorator (this endpoint creates authentication)
|
|
26
|
+
- Should check if user exists and password matches
|
|
27
|
+
|
|
28
|
+
### MANDATORY: Use MyGlobal.password for Password Verification
|
|
29
|
+
|
|
30
|
+
**CRITICAL**: You MUST use MyGlobal.password utilities for password verification to ensure consistency with the join operation:
|
|
31
|
+
|
|
32
|
+
\`\`\`typescript
|
|
33
|
+
// Example: Password verification in login
|
|
34
|
+
const isValid = await MyGlobal.password.verify(
|
|
35
|
+
body.password, // plain password from request
|
|
36
|
+
user.password_hash // hashed password from database
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (!isValid) {
|
|
40
|
+
throw new Error("Invalid credentials");
|
|
41
|
+
}
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
### JWT Token Generation
|
|
45
|
+
|
|
46
|
+
**NOTE**: The jsonwebtoken library is automatically imported as jwt. Use it to generate tokens with the EXACT payload structure:
|
|
47
|
+
|
|
48
|
+
**CRITICAL**: Use the predefined payload structures for consistency:
|
|
49
|
+
|
|
50
|
+
\`\`\`json
|
|
51
|
+
${JSON.stringify(payloads)}
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
// JWT is already imported: import jwt from "jsonwebtoken";
|
|
55
|
+
|
|
56
|
+
// Generate access token with the EXACT payload structure for the user type
|
|
57
|
+
// DO NOT use type annotations like: const payload: MemberPayload = {...}
|
|
58
|
+
// Just create the payload object directly
|
|
59
|
+
|
|
60
|
+
const accessToken = jwt.sign(
|
|
61
|
+
{
|
|
62
|
+
userId: user.id,
|
|
63
|
+
email: user.email,
|
|
64
|
+
// ... other required fields from the payload structure above
|
|
65
|
+
},
|
|
66
|
+
MyGlobal.env.JWT_SECRET_KEY,
|
|
67
|
+
{
|
|
68
|
+
expiresIn: '1h',
|
|
69
|
+
issuer: 'autobe' // MUST use 'autobe' as issuer
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// Generate refresh token (optional)
|
|
74
|
+
const refreshToken = jwt.sign(
|
|
75
|
+
{
|
|
76
|
+
userId: user.id,
|
|
77
|
+
tokenType: 'refresh'
|
|
78
|
+
},
|
|
79
|
+
MyGlobal.env.JWT_SECRET_KEY,
|
|
80
|
+
{
|
|
81
|
+
expiresIn: '7d',
|
|
82
|
+
issuer: 'autobe' // MUST use 'autobe' as issuer
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
// Decode tokens if needed (e.g., for verification)
|
|
87
|
+
const decoded = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY, {
|
|
88
|
+
issuer: 'autobe' // Verify issuer is 'autobe'
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
**DO NOT**:
|
|
92
|
+
- Implement your own password hashing logic
|
|
93
|
+
- Use bcrypt, argon2, or any other hashing library directly
|
|
94
|
+
- Try to hash and compare manually
|
|
95
|
+
|
|
96
|
+
**IMPORTANT**: Since this is a login operation, it must be publicly accessible without authentication.
|
|
97
|
+
`,
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
: [];
|
|
101
|
+
// Join (registration) operation 가이드
|
|
102
|
+
const joinGuide = operation.authorizationType === "join"
|
|
103
|
+
? [
|
|
104
|
+
{
|
|
105
|
+
id: (0, uuid_1.v7)(),
|
|
106
|
+
created_at: new Date().toISOString(),
|
|
107
|
+
type: "systemMessage",
|
|
108
|
+
text: utils_1.StringUtil.trim `
|
|
109
|
+
# Authorization Type: Join (Registration)
|
|
110
|
+
|
|
111
|
+
This is a **join** operation for user registration.
|
|
112
|
+
|
|
113
|
+
## Implementation Guidelines for Join:
|
|
114
|
+
|
|
115
|
+
### Join (Registration) Operation Requirements
|
|
116
|
+
- This is a user registration endpoint
|
|
117
|
+
- Must validate all required user information
|
|
118
|
+
- Should check for duplicate accounts (email, username, etc.)
|
|
119
|
+
- Must hash passwords before storing (NEVER store plain passwords)
|
|
120
|
+
- Should create a new user record in the database
|
|
121
|
+
- Must NOT require authentication decorator (public endpoint)
|
|
122
|
+
|
|
123
|
+
### MANDATORY: Use MyGlobal.password for Password Hashing
|
|
124
|
+
|
|
125
|
+
**CRITICAL**: You MUST use MyGlobal.password utilities for password hashing to ensure consistency across all authentication operations:
|
|
126
|
+
|
|
127
|
+
\`\`\`typescript
|
|
128
|
+
// Example: Password hashing in join/registration
|
|
129
|
+
const hashedPassword = await MyGlobal.password.hash(body.password);
|
|
130
|
+
|
|
131
|
+
// Store the hashed password in database
|
|
132
|
+
await MyGlobal.prisma.users.create({
|
|
133
|
+
data: {
|
|
134
|
+
email: body.email,
|
|
135
|
+
password_hash: hashedPassword, // Store the hash, never plain password
|
|
136
|
+
// ... other fields
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
\`\`\`
|
|
140
|
+
|
|
141
|
+
**DO NOT**:
|
|
142
|
+
- Store plain passwords in the database
|
|
143
|
+
- Use bcrypt, argon2, or any other hashing library directly
|
|
144
|
+
- Implement your own hashing logic
|
|
145
|
+
|
|
146
|
+
### JWT Token Generation After Registration
|
|
147
|
+
|
|
148
|
+
**NOTE**: The jsonwebtoken library is automatically imported as jwt. After successful registration, generate tokens with the EXACT payload structure:
|
|
149
|
+
|
|
150
|
+
**CRITICAL**: Use the predefined payload structures for consistency:
|
|
151
|
+
|
|
152
|
+
\`\`\`json
|
|
153
|
+
${JSON.stringify(payloads)}
|
|
154
|
+
\`\`\`
|
|
155
|
+
|
|
156
|
+
// JWT is already imported: import jwt from "jsonwebtoken";
|
|
157
|
+
|
|
158
|
+
// After creating the user, generate tokens with EXACT payload structure
|
|
159
|
+
// DO NOT use type annotations like: const payload: UserPayload = {...}
|
|
160
|
+
// Just create the payload object directly in jwt.sign()
|
|
161
|
+
|
|
162
|
+
const accessToken = jwt.sign(
|
|
163
|
+
{
|
|
164
|
+
userId: newUser.id,
|
|
165
|
+
email: newUser.email,
|
|
166
|
+
// ... other required fields from the payload structure above
|
|
167
|
+
},
|
|
168
|
+
MyGlobal.env.JWT_SECRET_KEY,
|
|
169
|
+
{
|
|
170
|
+
expiresIn: '1h',
|
|
171
|
+
issuer: 'autobe' // MUST use 'autobe' as issuer
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
const refreshToken = jwt.sign(
|
|
176
|
+
{
|
|
177
|
+
userId: newUser.id,
|
|
178
|
+
tokenType: 'refresh'
|
|
179
|
+
},
|
|
180
|
+
MyGlobal.env.JWT_SECRET_KEY,
|
|
181
|
+
{
|
|
182
|
+
expiresIn: '7d',
|
|
183
|
+
issuer: 'autobe' // MUST use 'autobe' as issuer
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
**IMPORTANT**: Since this is a registration operation, it must be publicly accessible. Always hash passwords before storing.
|
|
188
|
+
`,
|
|
189
|
+
},
|
|
190
|
+
]
|
|
191
|
+
: [];
|
|
192
|
+
// Refresh token operation 가이드
|
|
193
|
+
const refreshGuide = operation.authorizationType === "refresh"
|
|
194
|
+
? [
|
|
195
|
+
{
|
|
196
|
+
id: (0, uuid_1.v7)(),
|
|
197
|
+
created_at: new Date().toISOString(),
|
|
198
|
+
type: "systemMessage",
|
|
199
|
+
text: utils_1.StringUtil.trim `
|
|
200
|
+
# Authorization Type: Refresh Token
|
|
201
|
+
|
|
202
|
+
This is a **refresh** token operation for renewing expired access tokens.
|
|
203
|
+
|
|
204
|
+
## Implementation Guidelines for Refresh:
|
|
205
|
+
|
|
206
|
+
### Refresh Token Operation Requirements
|
|
207
|
+
- This endpoint refreshes expired access tokens
|
|
208
|
+
- Must validate the refresh token first
|
|
209
|
+
- Should check if refresh token is not expired or revoked
|
|
210
|
+
- Must generate a new access token with THE SAME payload structure
|
|
211
|
+
- May also rotate the refresh token for security
|
|
212
|
+
- Should handle invalid/expired refresh tokens gracefully
|
|
213
|
+
- Typically requires the refresh token in request body or headers
|
|
214
|
+
- Must NOT require standard authentication (uses refresh token instead)
|
|
215
|
+
|
|
216
|
+
### CRITICAL: Refresh Token Implementation
|
|
217
|
+
|
|
218
|
+
**IMPORTANT**: When refreshing tokens, you MUST:
|
|
219
|
+
1. Decode and verify the refresh token
|
|
220
|
+
2. Extract the user information from the decoded token
|
|
221
|
+
3. Generate a new access token with THE SAME payload structure as the original
|
|
222
|
+
|
|
223
|
+
**CRITICAL**: Use the predefined payload structures for consistency:
|
|
224
|
+
|
|
225
|
+
\`\`\`json
|
|
226
|
+
${JSON.stringify(payloads)}
|
|
227
|
+
\`\`\`
|
|
228
|
+
|
|
229
|
+
// JWT is already imported: import jwt from "jsonwebtoken";
|
|
230
|
+
|
|
231
|
+
// Step 1: Verify and decode the refresh token
|
|
232
|
+
const decoded = jwt.verify(body.refreshToken, MyGlobal.env.JWT_SECRET_KEY, {
|
|
233
|
+
issuer: 'autobe'
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// Step 2: Get user data (from decoded token or database)
|
|
237
|
+
const user = await MyGlobal.prisma.users.findUnique({
|
|
238
|
+
where: { id: decoded.userId }
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
if (!user) {
|
|
242
|
+
throw new Error("User not found");
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Step 3: Generate new access token with SAME payload structure as login/join
|
|
246
|
+
const newAccessToken = jwt.sign(
|
|
247
|
+
{
|
|
248
|
+
userId: user.id,
|
|
249
|
+
email: user.email,
|
|
250
|
+
// ... other required fields from the payload structure above
|
|
251
|
+
// MUST match the structure used in login/join operations
|
|
252
|
+
},
|
|
253
|
+
MyGlobal.env.JWT_SECRET_KEY,
|
|
254
|
+
{
|
|
255
|
+
expiresIn: '1h',
|
|
256
|
+
issuer: 'autobe'
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// Optional: Rotate refresh token
|
|
261
|
+
const newRefreshToken = jwt.sign(
|
|
262
|
+
{
|
|
263
|
+
userId: user.id,
|
|
264
|
+
tokenType: 'refresh'
|
|
265
|
+
},
|
|
266
|
+
MyGlobal.env.JWT_SECRET_KEY,
|
|
267
|
+
{
|
|
268
|
+
expiresIn: '7d',
|
|
269
|
+
issuer: 'autobe'
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
**DO NOT**:
|
|
274
|
+
- Generate new access tokens with different payload structures
|
|
275
|
+
- Use random IDs like v4() in the payload
|
|
276
|
+
- Create tokens without verifying the refresh token first
|
|
277
|
+
- Use type annotations like: const payload: UserPayload = {...}
|
|
278
|
+
|
|
279
|
+
**IMPORTANT**: The new access token MUST have the same payload structure as the original token from login/join operations.
|
|
280
|
+
`,
|
|
281
|
+
},
|
|
282
|
+
]
|
|
283
|
+
: [];
|
|
284
|
+
return [...loginGuide, ...joinGuide, ...refreshGuide];
|
|
285
|
+
};
|
|
286
|
+
exports.transformRealizeWriteAuthorizationsHistories = transformRealizeWriteAuthorizationsHistories;
|
|
287
|
+
//# sourceMappingURL=transformRealizeWriteAuthorizationsHistories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformRealizeWriteAuthorizationsHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAC3C,+BAA0B;AAEnB,MAAM,4CAA4C,GAAG,CAC1D,SAAmC,EACnC,QAAgC,EACY,EAAE;IAC9C,sBAAsB;IACtB,MAAM,UAAU,GACd,SAAS,CAAC,iBAAiB,KAAK,OAAO;QACrC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAqCjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA8C3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,oCAAoC;IACpC,MAAM,SAAS,GACb,SAAS,CAAC,iBAAiB,KAAK,MAAM;QACpC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA6CjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAmC3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,8BAA8B;IAC9B,MAAM,YAAY,GAChB,SAAS,CAAC,iBAAiB,KAAK,SAAS;QACvC,CAAC,CAAC;YACE;gBACE,EAAE,EAAE,IAAA,SAAE,GAAE;gBACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;gBACpC,IAAI,EAAE,eAAwB;gBAC9B,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;gBA2BjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAsD3B;aACF;SACF;QACH,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,SAAS,EAAE,GAAG,YAAY,CAAC,CAAC;AACxD,CAAC,CAAC;AAhSW,QAAA,4CAA4C,gDAgSvD"}
|