@autobe/agent 0.19.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/agent/src/AutoBeAgent.js +3 -2
- package/lib/agent/src/AutoBeAgent.js.map +1 -1
- package/lib/agent/src/AutoBeMockAgent.js +4 -3
- package/lib/agent/src/AutoBeMockAgent.js.map +1 -1
- package/lib/agent/src/constants/AutoBeSystemPromptConstant.d.ts +12 -11
- package/lib/agent/src/constants/AutoBeSystemPromptConstant.js.map +1 -1
- package/lib/agent/src/context/AutoBeContext.d.ts +3 -2
- package/lib/agent/src/factory/consentFunctionCall.js +3 -2
- package/lib/agent/src/factory/consentFunctionCall.js.map +1 -1
- package/lib/agent/src/factory/createAutoBeContext.js +11 -6
- 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/{transformAnalyzeReviewerHistories.js → transformAnalyzeReviewHistories.js} +24 -29
- 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.js +31 -29
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js +19 -5
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyze.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +7 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js +9 -6
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeReview.js.map +1 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeScenario.js +11 -9
- 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 +5 -1
- package/lib/agent/src/orchestrate/analyze/orchestrateAnalyzeWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js +45 -46
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAssetHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js +13 -13
- 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 +23 -22
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.d.ts +4 -0
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js +33 -0
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.js.map +1 -0
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceGroupHistories.js +2 -2
- 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 +32 -31
- package/lib/agent/src/orchestrate/interface/histories/transformInterfaceSchemasReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterface.js +3 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterface.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js +28 -24
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceAuthorizations.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js +2 -0
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceComplement.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js +11 -5
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpoints.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +10 -0
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js +365 -0
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.js.map +1 -0
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js +2 -0
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceGroups.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js +80 -54
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperations.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js +1635 -1180
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceOperationsReview.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemas.js +30 -24
- 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 +178 -0
- package/lib/agent/src/orchestrate/interface/orchestrateInterfaceSchemasReview.js.map +1 -1
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.d.ts +60 -0
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.js +3 -0
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.js.map +1 -0
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +38 -0
- package/lib/agent/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +78 -0
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js +54 -54
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js +18 -29
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js +37 -34
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaReviewHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js +38 -25
- package/lib/agent/src/orchestrate/prisma/histories/transformPrismaSchemaHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js +3 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrisma.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js +2 -0
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaComponent.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js +3 -0
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js +19 -9
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaReview.js.map +1 -1
- package/lib/agent/src/orchestrate/prisma/orchestratePrismaSchemas.js +28 -21
- 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 +58 -56
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.js.map +1 -1
- 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.js +12 -3
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js +35 -30
- package/lib/agent/src/orchestrate/realize/histories/transformRealizeWriteHistories.js.map +1 -1
- package/lib/{orchestrate/realize/internal/compile.d.ts → agent/src/orchestrate/realize/internal/compileRealizeFiles.d.ts} +1 -1
- package/lib/agent/src/orchestrate/realize/internal/{compile.js → compileRealizeFiles.js} +6 -6
- package/lib/agent/src/orchestrate/realize/internal/compileRealizeFiles.js.map +1 -0
- package/lib/agent/src/orchestrate/realize/orchestrateRealize.js +26 -12
- package/lib/agent/src/orchestrate/realize/orchestrateRealize.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js +9 -3
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorization.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js +3 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.d.ts +2 -6
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeCorrect.js +12 -8
- 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 +2 -2
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.d.ts +3 -6
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js +25 -21
- package/lib/agent/src/orchestrate/realize/orchestrateRealizeWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +2 -2
- package/lib/agent/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +7 -2
- 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/compile/getTestExternalDeclarations.js +1 -1
- package/lib/agent/src/orchestrate/test/compile/getTestExternalDeclarations.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.d.ts +3 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js +44 -27
- package/lib/agent/src/orchestrate/test/histories/transformTestCorrectHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js +63 -60
- package/lib/agent/src/orchestrate/test/histories/transformTestScenarioHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.d.ts +3 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js +118 -96
- package/lib/agent/src/orchestrate/test/histories/transformTestWriteHistories.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTest.js +6 -5
- package/lib/agent/src/orchestrate/test/orchestrateTest.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js +17 -8
- package/lib/agent/src/orchestrate/test/orchestrateTestCorrect.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js +30 -18
- package/lib/agent/src/orchestrate/test/orchestrateTestScenario.js.map +1 -1
- package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js +18 -18
- package/lib/agent/src/orchestrate/test/orchestrateTestWrite.js.map +1 -1
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +2 -2
- package/lib/agent/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +28 -1
- 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/constants/AutoBeSystemPromptConstant.d.ts +12 -11
- package/lib/context/AutoBeContext.d.ts +3 -2
- package/lib/index.mjs +3265 -1702
- package/lib/index.mjs.map +1 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewHistories.d.ts +6 -0
- package/lib/orchestrate/analyze/orchestrateAnalyzeReview.d.ts +7 -1
- package/lib/orchestrate/analyze/orchestrateAnalyzeWrite.d.ts +6 -4
- package/lib/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.d.ts +4 -0
- package/lib/orchestrate/interface/orchestrateInterfaceEndpointsReview.d.ts +10 -0
- package/lib/orchestrate/interface/orchestrateInterfaceSchemasReview.d.ts +2 -5
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.d.ts +60 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.d.ts +38 -0
- package/lib/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.d.ts +78 -0
- package/lib/{agent/src/orchestrate/realize/internal/compile.d.ts → orchestrate/realize/internal/compileRealizeFiles.d.ts} +1 -1
- package/lib/orchestrate/realize/orchestrateRealizeCorrect.d.ts +2 -6
- package/lib/orchestrate/realize/orchestrateRealizeScenario.d.ts +0 -66
- package/lib/orchestrate/realize/orchestrateRealizeWrite.d.ts +3 -6
- package/lib/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.d.ts +2 -2
- package/lib/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.d.ts +7 -2
- package/lib/orchestrate/test/histories/transformTestCorrectHistories.d.ts +3 -1
- package/lib/orchestrate/test/histories/transformTestWriteHistories.d.ts +3 -1
- package/lib/orchestrate/test/structures/IAutoBeTestCorrectApplication.d.ts +2 -2
- package/lib/orchestrate/test/structures/IAutoBeTestScenarioApplication.d.ts +28 -1
- package/lib/orchestrate/test/structures/IAutoBeTestWriteApplication.d.ts +2 -2
- package/lib/utils/executeCachedBatch.d.ts +1 -0
- package/package.json +7 -7
- package/src/AutoBeAgent.ts +4 -3
- package/src/AutoBeMockAgent.ts +5 -4
- package/src/constants/AutoBeSystemPromptConstant.ts +12 -11
- package/src/context/AutoBeContext.ts +3 -0
- package/src/factory/consentFunctionCall.ts +4 -3
- package/src/factory/createAutoBeContext.ts +11 -7
- package/src/orchestrate/analyze/histories/{transformAnalyzeReviewerHistories.ts → transformAnalyzeReviewHistories.ts} +23 -30
- package/src/orchestrate/analyze/histories/transformAnalyzeScenarioHistories.ts +13 -10
- package/src/orchestrate/analyze/histories/transformAnalyzeWriteHistories.ts +60 -61
- package/src/orchestrate/analyze/orchestrateAnalyze.ts +20 -13
- package/src/orchestrate/analyze/orchestrateAnalyzeReview.ts +20 -9
- package/src/orchestrate/analyze/orchestrateAnalyzeScenario.ts +13 -11
- package/src/orchestrate/analyze/orchestrateAnalyzeWrite.ts +10 -5
- package/src/orchestrate/interface/histories/transformInterfaceAssetHistories.ts +47 -48
- 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 -19
- package/src/orchestrate/interface/histories/transformInterfaceEndpointsReviewHistories.ts +39 -0
- 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 +31 -30
- package/src/orchestrate/interface/orchestrateInterface.ts +4 -2
- package/src/orchestrate/interface/orchestrateInterfaceAuthorizations.ts +36 -29
- package/src/orchestrate/interface/orchestrateInterfaceComplement.ts +2 -0
- package/src/orchestrate/interface/orchestrateInterfaceEndpoints.ts +18 -10
- package/src/orchestrate/interface/orchestrateInterfaceEndpointsReview.ts +95 -0
- package/src/orchestrate/interface/orchestrateInterfaceGroups.ts +2 -0
- package/src/orchestrate/interface/orchestrateInterfaceOperations.ts +53 -50
- package/src/orchestrate/interface/orchestrateInterfaceOperationsReview.ts +120 -10
- package/src/orchestrate/interface/orchestrateInterfaceSchemas.ts +47 -23
- package/src/orchestrate/interface/orchestrateInterfaceSchemasReview.ts +85 -1
- package/src/orchestrate/interface/structures/IAutoBeInterfaceEndpointsReviewApplication.ts +65 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationApplication.ts +39 -0
- package/src/orchestrate/interface/structures/IAutoBeInterfaceOperationsReviewApplication.ts +82 -1
- package/src/orchestrate/prisma/histories/transformPrismaComponentsHistories.ts +57 -55
- 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 +4 -2
- package/src/orchestrate/prisma/orchestratePrismaComponent.ts +2 -0
- package/src/orchestrate/prisma/orchestratePrismaCorrect.ts +3 -0
- package/src/orchestrate/prisma/orchestratePrismaReview.ts +26 -13
- package/src/orchestrate/prisma/orchestratePrismaSchemas.ts +25 -17
- package/src/orchestrate/realize/histories/transformRealizeAuthorization.ts +24 -21
- package/src/orchestrate/realize/histories/transformRealizeAuthorizationCorrectHistories.ts +42 -40
- package/src/orchestrate/realize/histories/transformRealizeCorrectHistories.ts +17 -13
- package/src/orchestrate/realize/histories/transformRealizeWriteAuthorizationsHistories.ts +14 -5
- package/src/orchestrate/realize/histories/transformRealizeWriteHistories.ts +35 -30
- package/src/orchestrate/realize/internal/{compile.ts → compileRealizeFiles.ts} +15 -11
- package/src/orchestrate/realize/orchestrateRealize.ts +59 -40
- package/src/orchestrate/realize/orchestrateRealizeAuthorization.ts +19 -10
- package/src/orchestrate/realize/orchestrateRealizeAuthorizationCorrect.ts +3 -0
- package/src/orchestrate/realize/orchestrateRealizeCorrect.ts +10 -10
- package/src/orchestrate/realize/orchestrateRealizeScenario.ts +7 -77
- package/src/orchestrate/realize/orchestrateRealizeWrite.ts +24 -23
- package/src/orchestrate/realize/structures/IAutoBeRealizeScenarioApplication.ts +6 -2
- package/src/orchestrate/realize/structures/IAutoBeRealizeWriteApplication.ts +10 -5
- package/src/orchestrate/test/compile/completeTestCode.ts +17 -13
- package/src/orchestrate/test/compile/getTestExternalDeclarations.ts +2 -0
- package/src/orchestrate/test/experimental/transformTestCorrectHistories.ast +4 -4
- package/src/orchestrate/test/histories/transformTestCorrectHistories.ts +50 -37
- package/src/orchestrate/test/histories/transformTestScenarioHistories.ts +62 -57
- package/src/orchestrate/test/histories/transformTestWriteHistories.ts +27 -7
- package/src/orchestrate/test/orchestrateTest.ts +7 -9
- package/src/orchestrate/test/orchestrateTestCorrect.ts +39 -25
- package/src/orchestrate/test/orchestrateTestScenario.ts +28 -21
- package/src/orchestrate/test/orchestrateTestWrite.ts +17 -18
- package/src/orchestrate/test/structures/IAutoBeTestCorrectApplication.ts +3 -3
- package/src/orchestrate/test/structures/IAutoBeTestScenarioApplication.ts +28 -1
- package/src/orchestrate/test/structures/IAutoBeTestWriteApplication.ts +2 -2
- package/src/utils/executeCachedBatch.ts +15 -0
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +0 -6
- package/lib/agent/src/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.js.map +0 -1
- package/lib/agent/src/orchestrate/realize/internal/compile.js.map +0 -1
- package/lib/agent/src/orchestrate/test/histories/transformTestHistories.d.ts +0 -3
- package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js +0 -74
- package/lib/agent/src/orchestrate/test/histories/transformTestHistories.js.map +0 -1
- package/lib/orchestrate/analyze/histories/transformAnalyzeReviewerHistories.d.ts +0 -6
- package/lib/orchestrate/test/histories/transformTestHistories.d.ts +0 -3
- package/src/orchestrate/test/histories/transformTestHistories.ts +0 -77
package/lib/agent/src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformInterfaceAuthorizationsHistories = void 0;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
4
5
|
const uuid_1 = require("uuid");
|
|
5
6
|
const transformInterfaceAssetHistories_1 = require("./transformInterfaceAssetHistories");
|
|
6
7
|
const transformInterfaceAuthorizationsHistories = (state, role) => {
|
|
7
8
|
return [
|
|
8
9
|
{
|
|
9
10
|
type: "systemMessage",
|
|
10
|
-
id: (0, uuid_1.
|
|
11
|
+
id: (0, uuid_1.v7)(),
|
|
11
12
|
created_at: new Date().toISOString(),
|
|
12
13
|
text: "# Authorization API Operation Generator System Prompt\n\n## 1. Overview\n\nYou are the Authorization API Operation Generator, specializing in creating JWT-based **authentication and authorization ONLY** API operations for specific user roles. Your mission is to generate essential authentication operations plus additional operations that are clearly supported by the Prisma schema structure.\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 operations 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## 2. Your Mission\n\nGenerate JWT authentication operations in two categories:\n1. **Essential Operations**: Core authentication flows that every role needs\n2. **Schema-Driven Operations**: Additional operations based on what the Prisma schema actually supports\n\n## 2.1. Authentication Scope Definition\n\n**INCLUDE (Authentication/Authorization Operations):**\n- Core authentication flows (join, login, refresh)\n- JWT token management\n- Schema-supported additional authentication operations\n\n**EXCLUDE (User Management Operations):**\n- General profile retrieval and viewing\n- Profile information updates (except password changes)\n- User preference management\n- Non-security related account settings\n\n## 3. Essential Operations (Generate If Basic Fields Exist)\n\nThese operations should be generated for every role if the basic authentication fields exist in the schema:\n\n### 3.1. Core Authentication Flow\n\n#### Registration\n- **Condition**: Role table has identity field + authentication field\n- **Path**: `/auth/{roleName}/join`\n- **Method**: `POST`\n- **Function Name**: `\"join\"`\n- **Purpose**: Create new user account and issue initial JWT tokens\n- **Auth Required**: None (public)\n\n#### Login\n- **Condition**: Role table has authentication fields\n- **Path**: `/auth/{roleName}/login`\n- **Method**: `POST`\n- **Function Name**: `\"login\"`\n- **Purpose**: Authenticate user and issue Access tokens\n- **Auth Required**: None (public)\n\n#### Token Refresh\n- **Path**: `/auth/{roleName}/refresh`\n- **Method**: `POST`\n- **Function Name**: `\"refresh\"`\n- **Purpose**: Refresh Access tokens using a valid refresh token\n- **Auth Required**: None (Valid refresh token)\n\n## 4. Schema-Driven Operations (Generate Based on Available Fields)\n\n**Analyze the Prisma schema for the role's table and generate additional operations ONLY for features that are clearly supported by the schema fields.**\n\n**Generation Rule**: Only create operations for authentication features that have corresponding fields in the Prisma schema.\n\n## 5. Naming Convention Rules\n\n### 5.1. Endpoint Path Conventions\n- Use RESTful resource-based paths\n- Use kebab-case for multi-word segments\n- Keep paths descriptive of the resource and action\n- Example: `/auth/user/password/reset/confirm`\n\n### 5.2. Function Name Conventions \n- Use camelCase for function names\n- Start with action verbs that clearly describe the operation\n- Make function names self-explanatory and business-oriented\n- Examples for core operations:\n - `join`\n - `login`\n - `refresh`\n\n### 5.3. Path vs Function Name Relationship\n- **Path**: Describes the HTTP resource and REST endpoint\n- **Function Name**: Describes the business operation/action\n- They should be related but NOT identical\n- Function names should be more action-oriented\n- Paths should be more resource-oriented\n\n## 6. Schema Analysis Process\n\n### 6.1. Step-by-Step Analysis\n\n1. **Identify Role Table**: Find the table corresponding to the role name\n2. **Check Essential Fields**: Verify basic authentication fields exist\n3. **Scan for Additional Features**: Look for fields that indicate additional authentication capabilities\n4. **Generate Operations**: Create operations for confirmed capabilities only\n\n### 6.2. Conservative Approach\n- **If field exists in schema**: Generate corresponding operation\n- **If field missing**: Skip the operation entirely\n- **If unsure about field purpose**: Skip rather than assume\n\n## 7. Description Requirements\n\n### 7.1. Schema-Aware Descriptions\n\n**Paragraph 1**: Purpose and functionality referencing specific schema fields\n\n**Paragraph 2**: Implementation details using confirmed available fields\n\n**Paragraph 3**: Role-specific integration and business context\n\n**Paragraph 4**: Security considerations within schema constraints\n\n**Paragraph 5**: Related operations and authentication workflow integration\n\n## 8. Response Body Type Naming Rules\n\n### 8.1. Authentication Operation Response Types\n\nFor operations with function names `login`, `join` and `refresh` (where `authorizationType` is NOT null), the response body `typeName` MUST follow this specific pattern:\n\n**Pattern**: `I{Prefix}{RoleName}.IAuthorized`\n\nWhere:\n- `{RoleName}` is the capitalized role name (e.g., \"User\", \"Admin\", \"Seller\")\n- The format must be exactly `I{Prefix}{RoleName}.IAuthorized`\n\n**Examples:**\n- For role \"user\" \u2192 `typeName: \"{IPrefix}User.IAuthorized\"`\n- For role \"admin\" \u2192 `typeName: \"{IPrefix}Admin.IAuthorized\"`\n- For role \"seller\" \u2192 `typeName: \"{IPrefix}Seller.IAuthorized\"`\n- For role \"moderator\" \u2192 `typeName: \"{IPrefix}Moderator.IAuthorized\"`\n\n**Non-Authentication Operations:**\nFor operations with `authorizationType: null`, use standard response type naming conventions as defined in the general API documentation (e.g., `IEntityName`, `IEntityName.ISummary`, etc.).\n\n### 8.2. Role Name Capitalization\n\nWhen creating the `I{Prefix}{RoleName}.IAuthorized` pattern:\n1. Take the role name from the operation path or context\n2. Capitalize the first letter\n3. Keep the rest of the role name in its original case\n4. Apply the pattern: `I{PascalPrefixName}{CapitalizedRoleName}.IAuthorized`\n\n## 9. Critical Requirements\n\n- **Essential Operations MANDATORY**: ALWAYS generate ALL 3 essential operations (join, login, refresh) for every role\n- **Operation Uniqueness**: Each authentication operation MUST be unique per role. There MUST be:\n - EXACTLY ONE operation with function name `\"join\"`\n - EXACTLY ONE operation with function name `\"login\"` \n - EXACTLY ONE operation with function name `\"refresh\"`\n - Multiple operations with the same function name are NOT allowed\n- **Schema-Driven Additions**: Add operations only for schema-supported features\n- **Field Verification**: Reference actual field names from the schema for additional features\n- **Never Skip Essentials**: Even if uncertain about schema fields, ALWAYS include the 3 core operations\n- **Proper Naming**: Ensure endpoint paths and function names follow conventions and are distinct\n- **Authentication Response Types**: All authentication operations (authorizationType !== null) MUST use `I{Prefix}{RoleName}.IAuthorized` format for response body typeName\n- **Function Call Required**: Use `makeOperations()` with all generated operations\n\n## 10. Implementation Strategy\n\n1. **ALWAYS Generate Essential Operations FIRST**: Create ALL 3 core authentication operations (join, login, refresh) for every role - this is MANDATORY\n2. **Analyze Schema Fields**: Systematically scan for additional authentication capabilities\n3. **Generate Schema-Supported Operations**: Add operations for confirmed schema features\n4. **Apply Naming Conventions**: Ensure proper path and function naming\n5. **Apply Response Type Rules**: Use `I{Prefix}{RoleName}.IAuthorized` for authentication operations\n6. **Document Rationale**: Explain which schema fields enable each operation\n7. **Function Call**: Submit complete authentication API\n\n**CRITICAL RULE**: Even if you're unsure about the schema or can only confirm basic authentication, you MUST still generate all 3 essential operations. Never generate only some of them.\n\nYour implementation should provide a complete authentication system with essential operations plus all additional operations that the Prisma schema clearly supports, ensuring every operation can be fully implemented with the available database structure, with clear and consistent naming conventions that distinguish between REST endpoints and business function names, and proper response type naming for authentication operations." /* AutoBeSystemPromptConstant.INTERFACE_AUTHORIZATION */,
|
|
13
14
|
},
|
|
14
15
|
...(0, transformInterfaceAssetHistories_1.transformInterfaceAssetHistories)(state),
|
|
15
16
|
{
|
|
16
17
|
type: "assistantMessage",
|
|
17
|
-
id: (0, uuid_1.
|
|
18
|
+
id: (0, uuid_1.v7)(),
|
|
18
19
|
created_at: new Date().toISOString(),
|
|
19
|
-
text:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
].join("\n"),
|
|
20
|
+
text: utils_1.StringUtil.trim `
|
|
21
|
+
You have to make API operations for the given role:
|
|
22
|
+
|
|
23
|
+
## Role
|
|
24
|
+
|
|
25
|
+
\`\`\`json
|
|
26
|
+
${JSON.stringify(role)}
|
|
27
|
+
\`\`\`
|
|
28
|
+
|
|
29
|
+
`,
|
|
30
30
|
},
|
|
31
31
|
];
|
|
32
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformInterfaceAuthorizationsHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts"],"names":[],"mappings":";;;AAEA,+BAA0B;AAI1B,yFAAsF;AAE/E,MAAM,yCAAyC,GAAG,CACvD,KAAkB,EAClB,IAAuB,EAGvB,EAAE;IACF,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,imSAAoD;SACzD;QACD,GAAG,IAAA,mEAAgC,EAAC,KAAK,CAAC;QAC1C;YACE,IAAI,EAAE,kBAAkB;YACxB,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE
|
|
1
|
+
{"version":3,"file":"transformInterfaceAuthorizationsHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/interface/histories/transformInterfaceAuthorizationsHistories.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAC3C,+BAA0B;AAI1B,yFAAsF;AAE/E,MAAM,yCAAyC,GAAG,CACvD,KAAkB,EAClB,IAAuB,EAGvB,EAAE;IACF,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,imSAAoD;SACzD;QACD,GAAG,IAAA,mEAAgC,EAAC,KAAK,CAAC;QAC1C;YACE,IAAI,EAAE,kBAAkB;YACxB,EAAE,EAAE,IAAA,SAAE,GAAE;YACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;;;UAMjB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;;OAGvB;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AA9BW,QAAA,yCAAyC,6CA8BpD"}
|
package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js
CHANGED
|
@@ -1,61 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.transformInterfaceComplementHistories = void 0;
|
|
4
|
+
const utils_1 = require("@autobe/utils");
|
|
4
5
|
const uuid_1 = require("uuid");
|
|
5
6
|
const transformInterfaceAssetHistories_1 = require("./transformInterfaceAssetHistories");
|
|
6
7
|
const transformInterfaceComplementHistories = (state, document, missed) => [
|
|
7
8
|
{
|
|
8
9
|
type: "systemMessage",
|
|
9
|
-
id: (0, uuid_1.
|
|
10
|
+
id: (0, uuid_1.v7)(),
|
|
10
11
|
created_at: new Date().toISOString(),
|
|
11
|
-
text: "# API Operation Generator System Prompt\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- **IAutoBeInterfaceOperationApplication.IOperation.authorizationRoles**: Use camelCase notation\n- **IAutoBeInterfaceOperation.name**: Use camelCase notation (must not be TypeScript/JavaScript reserved word)\n\n## 1. Overview\n\nYou are the API Operation Generator, specializing in creating comprehensive API operations with complete specifications, detailed descriptions, parameters, and request/response bodies based on requirements documents, Prisma schema files, and API endpoint lists. You must output your results by calling the `makeOperations()` function.\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 operations 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## 2. Your Mission\n\nAnalyze the provided information and generate complete API operations that transform simple endpoint definitions (path + method) into fully detailed `AutoBeOpenApi.IOperation` objects. Each operation must include comprehensive specifications, multi-paragraph descriptions, proper parameters, and appropriate request/response body definitions.\n\n## 2.1. Critical Schema Verification Rule\n\n**IMPORTANT**: When designing operations and their data structures, you MUST:\n- Base ALL operation designs strictly on the ACTUAL fields present in the Prisma schema\n- NEVER assume common fields like `deleted_at`, `created_by`, `updated_by`, `is_deleted` exist unless explicitly defined in the schema\n- If the Prisma schema lacks soft delete fields, the DELETE operation will perform hard delete\n- Verify every field reference against the provided Prisma schema JSON\n- Ensure all type references in requestBody and responseBody correspond to actual schema entities\n\n## 2.2. Operation Design Philosophy\n\n**CRITICAL**: Focus on creating operations that serve actual user needs, not comprehensive coverage of every database table.\n\n**Role Multiplication Awareness**:\n- Remember: Each role in authorizationRoles creates a separate endpoint\n- Total generated endpoints = operations \u00D7 roles\n- Be intentional about which roles truly need separate endpoints\n\n**Design Principles**:\n- **User-Centric**: Create operations users actually need to perform\n- **Avoid Over-Engineering**: Not every table requires full CRUD operations\n- **System vs User Data**: Distinguish between what users manage vs what the system manages\n- **Business Logic Focus**: Operations should reflect business workflows, not database structure\n\n**Ask Before Creating Each Operation**:\n- Does a user actually perform this action?\n- Is this data user-managed or system-managed?\n- Will this operation ever be called from the UI/client?\n- Is this operation redundant with another operation?\n\n### 2.3. System-Generated Data: Critical Restrictions\n\n**\u26A0\uFE0F CRITICAL PRINCIPLE**: Data that is generated automatically by the system as side effects of other operations MUST NOT have manual creation/modification/deletion APIs.\n\n**Key Question**: \"Does the system create this data automatically when users perform other actions?\"\n- If YES \u2192 No POST/PUT/DELETE operations needed\n- If NO \u2192 Normal CRUD operations may be appropriate\n\n**System-Generated Data (ABSOLUTELY NO Write APIs)**:\n- **Audit Trails**: Created automatically when users perform actions\n - Example: When a user updates a post, the system automatically logs it\n - Implementation: Handled in provider/service logic, not separate API endpoints\n- **System Metrics**: Performance data collected automatically\n - Example: Response times, error rates, resource usage\n - Implementation: Monitoring libraries handle this internally\n- **Analytics Events**: User behavior tracked automatically\n - Example: Page views, click events, session duration\n - Implementation: Analytics SDK handles tracking internally\n\n**User-Managed Data (APIs Needed)**:\n- **Business Entities**: Core application data\n - Examples: users, posts, products, orders\n - Need: Full CRUD operations as per business requirements\n- **User Content**: Data created and managed by users\n - Examples: articles, comments, reviews, profiles\n - Need: Creation, editing, deletion APIs\n- **Configuration**: Settings users can modify\n - Examples: preferences, notification settings, display options\n - Need: Read and update operations\n\n**How System-Generated Data Works**:\n```typescript\n// Example: When user creates a post\nclass PostService {\n async create(data: CreatePostDto) {\n // Create the post\n const post = await this.prisma.post.create({ data });\n \n // System automatically logs this action (no separate API needed)\n await this.auditService.log({\n action: 'POST_CREATED',\n userId: data.userId,\n resourceId: post.id\n });\n \n // System automatically updates metrics (no separate API needed)\n await this.metricsService.increment('posts.created');\n \n return post;\n }\n}\n```\n\n**\uD83D\uDD34 CRITICAL PRINCIPLE**: If the requirements say \"THE system SHALL automatically [log/track/record]...\", this means the system handles it internally during normal operations. Creating manual APIs for this data is a FUNDAMENTAL ARCHITECTURAL ERROR.\n\n**Examples from Requirements**:\n- \u2705 \"Users SHALL create posts\" \u2192 Need POST /posts API\n- \u2705 \"Admins SHALL manage categories\" \u2192 Need CRUD /categories APIs\n- \u274C \"THE system SHALL log all user actions\" \u2192 Internal logging, no API\n- \u274C \"THE system SHALL track performance metrics\" \u2192 Internal monitoring, no API\n\n**Decision Framework**:\n\nAsk these questions for each table:\n1. **Who creates this data?**\n - User action \u2192 Need POST endpoint\n - System automatically \u2192 NO POST endpoint\n\n2. **Who modifies this data?**\n - User can edit \u2192 Need PUT/PATCH endpoint\n - System only \u2192 NO PUT endpoint\n\n3. **Can this data be deleted?**\n - User can delete \u2192 Need DELETE endpoint\n - Must be preserved for audit/compliance \u2192 NO DELETE endpoint\n\n4. **Do users need to view this data?**\n - Yes \u2192 Add GET/PATCH (search) endpoints\n - No \u2192 No read endpoints needed\n\n**Common Examples (Your project may differ)**:\n- Audit-related tables: Usually system records actions automatically\n- Metrics/Analytics tables: Usually system collects data automatically\n- History/Log tables: Often system-generated, but check requirements\n- Important: These are examples only - always check your specific requirements\n\n**How to Identify System-Generated Tables**:\n- Look for requirements language: \"THE system SHALL automatically...\"\n- Consider the table's purpose: Is it for tracking/recording system behavior?\n- Ask: \"Would a user ever manually create/edit/delete this data?\"\n- Examples (may vary by project):\n - Audit logs: System records actions automatically\n - Analytics events: System tracks user behavior automatically\n - Performance metrics: System collects measurements automatically\n\n**\u26A0\uFE0F MANDATORY**: DO NOT create operations for system-managed tables. These violate system integrity and create security vulnerabilities. Focus only on user-facing business operations.\n\n## 3. Input Information\n\nYou will receive five types of information:\n1. **Requirements Analysis Document**: Functional requirements and business logic\n2. **Prisma Schema Files**: Database schema definitions with entities and relationships\n3. **API Endpoint Groups**: Group information with name and description that categorize the endpoints\n4. **API Endpoint List**: Simple endpoint definitions with path and method combinations\n5. **Service Prefix**: The service identifier that must be included in all DTO type names\n\n## 4. Output Method\n\nYou MUST call the `makeOperations()` function with your results.\n\n**CRITICAL: Selective Operation Generation**\n- You DO NOT need to create operations for every endpoint provided\n- **EXCLUDE** endpoints for system-generated data (logs, metrics, analytics)\n- **EXCLUDE** operations that violate the principles in Section 2.3\n- Return ONLY operations that represent legitimate user actions\n- The operations array can be smaller than the endpoints list - this is expected and correct\n\n```typescript\nmakeOperations({\n operations: [\n {\n specification: \"Detailed specification of what this API does...\",\n path: \"/resources\",\n method: \"get\",\n description: \"Multi-paragraph detailed description...\",\n summary: \"Concise summary of the operation\",\n parameters: [],\n requestBody: null,\n responseBody: {\n description: \"Response description\",\n typeName: \"IPageIResource\"\n },\n authorizationRoles: [\"user\"],\n name: \"index\"\n },\n // ONLY include operations that pass validation\n // DO NOT include system-generated data manipulation\n ],\n});\n```\n\n## 5. Operation Design Principles\n\n### 5.1. Specification Field Requirements\n\nThe `specification` field must:\n- Clearly identify which Prisma DB table this operation is associated with\n- Explain the business purpose and functionality\n- Describe any business rules or validation logic\n- Reference relationships to other entities\n- Be detailed enough to understand implementation requirements\n\n### 5.2. Description Requirements\n\n**CRITICAL**: The `description` field MUST be extensively detailed and MUST reference the description comments from the related Prisma DB schema tables and columns. The description MUST be organized into MULTIPLE PARAGRAPHS separated by line breaks.\n\nInclude separate paragraphs for:\n- The purpose and overview of the API operation\n- Security considerations and user permissions\n- Relationship to underlying database entities\n- Validation rules and business logic\n- Related API operations that might be used together\n- Expected behavior and error handling\n\n**IMPORTANT**: All descriptions MUST be written in English. Never use other languages.\n\n### 5.3. HTTP Method Patterns\n\nFollow these patterns based on the endpoint method:\n\n#### GET Operations\n- **Simple Resource Retrieval**: `GET /entities/{id}`\n - Returns single entity\n - Response: Main entity type (e.g., `IUser`)\n - Name: `\"at\"`\n\n#### PATCH Operations\n- **Complex Collection Search**: `PATCH /entities`\n - Supports complex search, filtering, sorting, pagination\n - Request: Search parameters (e.g., `IUser.IRequest`)\n - Response: Paginated results (e.g., `IPageIUser`)\n - Name: `\"search\"`\n\n#### POST Operations\n- **Entity Creation**: `POST /entities`\n - Creates new entity\n - Request: Creation data (e.g., `IUser.ICreate`)\n - Response: Created entity (e.g., `IUser`)\n - Name: `\"create\"`\n\n#### PUT Operations\n- **Entity Update**: `PUT /entities/{id}`\n - Updates existing entity\n - Request: Update data (e.g., `IUser.IUpdate`)\n - Response: Updated entity (e.g., `IUser`)\n - Name: `\"update\"`\n\n#### DELETE Operations\n- **Entity Deletion**: `DELETE /entities/{id}`\n - Deletes entity (hard or soft based on schema)\n - No request body\n - No response body or confirmation message\n - Name: `\"erase\"`\n\n### 5.4. Parameter Definition\n\nFor each path parameter in the endpoint path:\n- Extract parameter names from curly braces `{paramName}`\n- MUST use camelCase naming convention (start with lowercase, capitalize subsequent words)\n- Define appropriate schema type (usually string with UUID format)\n- Provide clear, concise description\n- Ensure parameter names match exactly with path\n\n**Naming Convention Rules**:\n- Valid: `userId`, `orderId`, `productId`, `categoryName`\n- Invalid: `user_id` (snake_case), `user-id` (kebab-case), `UserId` (PascalCase)\n\nExample:\n```typescript\n// For path: \"/users/{userId}/posts/{postId}\"\nparameters: [\n {\n name: \"userId\", // camelCase required\n description: \"Unique identifier of the target user\",\n schema: { type: \"string\", format: \"uuid\" }\n },\n {\n name: \"postId\", // camelCase required\n description: \"Unique identifier of the target post\",\n schema: { type: \"string\", format: \"uuid\" }\n }\n]\n```\n\n### 5.5. Type Naming Conventions\n\nFollow these standardized naming patterns with the service prefix:\n\n**CRITICAL**: All DTO type names MUST include the service prefix in PascalCase format following the pattern `I{ServicePrefix}{EntityName}`.\n\nFor example, if the service prefix is \"shopping\":\n- Entity \"Sale\" becomes `IShoppingSale`\n- Entity \"Order\" becomes `IShoppingOrder`\n- Entity \"Product\" becomes `IShoppingProduct`\n\n#### Request Body Types\n- `I{ServicePrefix}{Entity}.ICreate`: For POST operations (creation)\n - Example: `IShoppingSale.ICreate`, `IShoppingOrder.ICreate`\n- `I{ServicePrefix}{Entity}.IUpdate`: For PUT operations (updates)\n - Example: `IShoppingSale.IUpdate`, `IShoppingOrder.IUpdate`\n- `I{ServicePrefix}{Entity}.IRequest`: For PATCH operations (search/filtering)\n - Example: `IShoppingSale.IRequest`, `IShoppingOrder.IRequest`\n\n#### Response Body Types\n- `I{ServicePrefix}{Entity}`: Main detailed entity type\n - Example: `IShoppingSale`, `IShoppingOrder`\n- `I{ServicePrefix}{Entity}.ISummary`: Simplified entity for lists\n - Example: `IShoppingSale.ISummary`, `IShoppingOrder.ISummary`\n- `IPageI{ServicePrefix}{Entity}`: Paginated collection of main entities\n - Example: `IPageIShoppingSale`, `IPageIShoppingOrder`\n- `IPageI{ServicePrefix}{Entity}.ISummary`: Paginated collection of summary entities\n - Example: `IPageIShoppingSale.ISummary`, `IPageIShoppingOrder.ISummary`\n\n**Service Prefix Transformation Rules**:\n- Convert the provided service prefix to PascalCase\n- Examples:\n - \"shopping\" \u2192 \"Shopping\" \u2192 `IShoppingSale`\n - \"bbs\" \u2192 \"Bbs\" \u2192 `IBbsArticle`\n - \"user-management\" \u2192 \"UserManagement\" \u2192 `IUserManagementUser`\n - \"blog_service\" \u2192 \"BlogService\" \u2192 `IBlogServicePost`\n\n### 5.6. Operation Name Requirements\n\n#### Reserved Word Restrictions\n\n**CRITICAL**: The operation `name` field MUST NOT be a TypeScript/JavaScript reserved word, as it will be used as a class method name in generated code.\n\n**Prohibited Names** (DO NOT USE):\n- `delete`, `for`, `if`, `else`, `while`, `do`, `switch`, `case`, `break`\n- `continue`, `function`, `return`, `with`, `in`, `of`, `instanceof`\n- `typeof`, `void`, `var`, `let`, `const`, `class`, `extends`, `import`\n- `export`, `default`, `try`, `catch`, `finally`, `throw`, `new`\n- `super`, `this`, `null`, `true`, `false`, `async`, `await`\n- `yield`, `static`, `private`, `protected`, `public`, `implements`\n- `interface`, `package`, `enum`, `debugger`\n\n**Alternative Names to Use**:\n- Use `erase` instead of `delete`\n- Use `iterate` instead of `for`\n- Use `when` instead of `if`\n- Use `cls` instead of `class`\n- Use `retrieve` instead of `return`\n- Use `attempt` instead of `try`\n\n#### Operation Name Uniqueness Rule\n\nEach operation must have a globally unique accessor within the API. The accessor combines the path structure with the operation name.\n\n**Accessor Formation:**\n1. Extract non-parameter segments from the path (ignore `{...}` parts)\n2. Join these segments with dots\n3. Append the operation name to create the final accessor\n\n**Examples:**\n- Path: `/shopping/sale/{saleId}/review/{reviewId}`, Name: `at`\n \u2192 Accessor: `shopping.sale.review.at`\n- Path: `/users/{userId}/posts`, Name: `index`\n \u2192 Accessor: `users.posts.index`\n- Path: `/shopping/customer/orders`, Name: `create`\n \u2192 Accessor: `shopping.customer.orders.create`\n\n**Global Uniqueness:**\nEvery accessor must be unique across the entire API. This prevents naming conflicts in generated SDKs where operations are accessed via dot notation (e.g., `api.shopping.sale.review.at()`)\n\n### 5.7. Authorization Roles\n\nThe `authorizationRoles` field must specify which user roles can access the endpoint:\n\n- **Public Endpoints**: `[]` (empty array) - No authentication required\n- **Authenticated User Endpoints**: `[\"user\"]` - Any authenticated user\n- **Role-Specific Endpoints**: `[\"admin\"]`, `[\"moderator\"]`, `[\"seller\"]`, etc.\n- **Multi-Role Endpoints**: `[\"admin\", \"moderator\"]` - Multiple roles allowed\n\n**CRITICAL Naming Convention**: All role names MUST use camelCase:\n- Valid: `user`, `admin`, `moderator`, `seller`, `buyer`, `contentCreator`\n- Invalid: `content_creator` (snake_case), `ContentCreator` (PascalCase), `content-creator` (kebab-case)\n\n**Role Assignment Guidelines**:\n- **Read Operations** (GET): Often public or require basic authentication\n- **Create Operations** (POST): Usually require authentication to track creator\n- **Update Operations** (PUT): Require ownership verification or special permissions\n- **Delete Operations** (DELETE): Require ownership verification or administrative permissions\n- **Search Operations** (PATCH): Depends on data sensitivity\n\nUse actual role names from the Prisma schema. Common patterns:\n- User's own data: `[\"user\"]` (with additional ownership checks in implementation)\n- Administrative functions: `[\"admin\"]` or `[\"administrator\"]`\n- Content moderation: `[\"moderator\"]`\n- Business-specific roles: `[\"seller\"]`, `[\"buyer\"]`, etc.\n\n**Important**: Role names must exactly match table names in the Prisma schema and must follow camelCase convention.\n\n## 6. Critical Requirements\n\n- **Function Call Required**: You MUST use the `makeOperations()` function to submit your results\n- **Selective Processing**: Evaluate EVERY endpoint but ONLY create operations for valid ones\n- **Intentional Exclusion**: MUST skip endpoints that:\n - Manipulate system-generated data (POST/PUT/DELETE on logs, metrics, etc.)\n - Violate architectural principles\n - Serve no real user need\n- **Prisma Schema Alignment**: All operations must accurately reflect the underlying database schema\n- **Detailed Descriptions**: Every operation must have comprehensive, multi-paragraph descriptions\n- **Proper Type References**: All requestBody and responseBody typeName fields must reference valid component types\n- **Accurate Parameters**: Path parameters must match exactly with the endpoint path\n- **Appropriate Authorization**: Assign realistic authorization roles based on operation type and data sensitivity\n\n## 7. Implementation Strategy\n\n1. **Analyze and Filter Input**:\n - Review the requirements analysis document for business context\n - Study the Prisma schema to understand entities, relationships, and field definitions\n - Examine the API endpoint groups for organizational context\n - **CRITICAL**: Evaluate each endpoint - exclude system-generated data manipulation\n\n2. **Categorize Endpoints**:\n - Group endpoints by entity type\n - Identify CRUD patterns and special operations\n - Understand parent-child relationships for nested resources\n\n3. **Generate Operations (Selective)**:\n - For each VALID endpoint, determine the appropriate operation pattern\n - **SKIP** endpoints that manipulate system-generated data\n - **SKIP** endpoints that serve no real user need\n - Create detailed specifications ONLY for legitimate user operations\n - Write comprehensive multi-paragraph descriptions incorporating schema comments\n - Define accurate parameters matching path structure\n - Assign appropriate request/response body types using service prefix naming\n - Set realistic authorization roles\n\n4. **Validation**:\n - Ensure all path parameters are defined\n - Verify all type references are valid\n - Check that authorization roles are realistic\n - Confirm descriptions are detailed and informative\n\n5. **Function Call**: Call the `makeOperations()` function with the filtered array (may be smaller than input endpoints)\n\n## 8. Quality Standards\n\n### 8.1. Specification Quality\n- Must clearly explain the business purpose\n- Should reference specific Prisma schema entities\n- Must describe any complex business logic\n- Should explain relationships to other operations\n\n### 8.2. Description Quality\n- Multiple paragraphs with clear structure\n- Incorporates Prisma schema comments and descriptions\n- Explains security and authorization context\n- Describes expected inputs and outputs\n- Covers error scenarios and edge cases\n\n### 8.3. Technical Accuracy\n- Path parameters match endpoint path exactly\n- Request/response types follow naming conventions\n- Authorization roles reflect realistic access patterns\n- HTTP methods align with operation semantics\n\n## 9. Example Operation\n\n```typescript\n{\n specification: \"This operation retrieves a paginated list of shopping customer accounts with advanced filtering, searching, and sorting capabilities. It operates on the Customer table from the Prisma schema and supports complex queries to find customers based on various criteria including name, email, registration date, and account status.\",\n \n path: \"/customers\",\n method: \"patch\",\n \n description: `Retrieve a filtered and paginated list of shopping customer accounts from the system. This operation provides advanced search capabilities for finding customers based on multiple criteria including partial name matching, email domain filtering, registration date ranges, and account status.\n\nThe operation supports comprehensive pagination with configurable page sizes and sorting options. Customers can sort by registration date, last login, name, or other relevant fields in ascending or descending order.\n\nSecurity considerations include rate limiting for search operations and appropriate filtering of sensitive customer information based on the requesting user's authorization level. Only users with appropriate permissions can access detailed customer information, while basic customer lists may be available to authenticated users.\n\nThis operation integrates with the Customer table as defined in the Prisma schema, incorporating all available customer fields and relationships. The response includes customer summary information optimized for list displays, with options to include additional details based on authorization level.`,\n\n summary: \"Search and retrieve a filtered, paginated list of shopping customers\",\n \n parameters: [],\n \n requestBody: {\n description: \"Search criteria and pagination parameters for customer filtering\",\n typeName: \"IShoppingCustomer.IRequest\"\n },\n \n responseBody: {\n description: \"Paginated list of customer summary information matching search criteria\",\n typeName: \"IPageIShoppingCustomer.ISummary\"\n },\n \n authorizationRoles: [\"admin\"],\n name: \"search\"\n}\n```\n\nYour implementation MUST be SELECTIVE and THOUGHTFUL, excluding inappropriate endpoints (system-generated data manipulation) while ensuring every VALID operation provides comprehensive, production-ready API documentation. The result array should contain ONLY operations that represent real user actions. Calling the `makeOperations()` function is MANDATORY." /* AutoBeSystemPromptConstant.INTERFACE_OPERATION */,
|
|
12
|
+
text: "# API Operation Generator System Prompt\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- **IAutoBeInterfaceOperationApplication.IOperation.authorizationRoles**: Use camelCase notation\n- **IAutoBeInterfaceOperation.name**: Use camelCase notation (must not be TypeScript/JavaScript reserved word)\n\n## 1. Overview\n\nYou are the API Operation Generator, specializing in creating comprehensive API operations with complete specifications, detailed descriptions, parameters, and request/response bodies based on requirements documents, Prisma schema files, and API endpoint lists. You must output your results by calling the `makeOperations()` function.\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 operations 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## 2. Your Mission\n\nAnalyze the provided information and generate complete API operations that transform simple endpoint definitions (path + method) into fully detailed `AutoBeOpenApi.IOperation` objects. Each operation must include comprehensive specifications, multi-paragraph descriptions, proper parameters, and appropriate request/response body definitions.\n\n## 2.1. Critical Schema Verification Rule\n\n**IMPORTANT**: When designing operations and their data structures, you MUST:\n- Base ALL operation designs strictly on the ACTUAL fields present in the Prisma schema\n- NEVER assume common fields like `deleted_at`, `created_by`, `updated_by`, `is_deleted` exist unless explicitly defined in the schema\n- If the Prisma schema lacks soft delete fields, the DELETE operation will perform hard delete\n- Verify every field reference against the provided Prisma schema JSON\n- Ensure all type references in requestBody and responseBody correspond to actual schema entities\n\n**Prisma Schema Source**:\n- The Prisma schema is provided in your conversation history as a JSON object: `Record<string, string>`\n- Keys are model names (e.g., \"User\", \"Post\", \"Customer\")\n- Values are the complete Prisma model definitions including all fields and relations\n- This is your AUTHORITATIVE SOURCE for all database structure information\n- When filling the `prisma_schemas` field for each operation, extract relevant models from this source\n\n## 2.2. Operation Design Philosophy\n\n**CRITICAL**: Focus on creating operations that serve actual user needs, not comprehensive coverage of every database table.\n\n**Role Multiplication Awareness**:\n- Remember: Each role in authorizationRoles creates a separate endpoint\n- Total generated endpoints = operations \u00D7 roles\n- Be intentional about which roles truly need separate endpoints\n\n**Design Principles**:\n- **User-Centric**: Create operations users actually need to perform\n- **Avoid Over-Engineering**: Not every table requires full CRUD operations\n- **System vs User Data**: Distinguish between what users manage vs what the system manages\n- **Business Logic Focus**: Operations should reflect business workflows, not database structure\n\n**Ask Before Creating Each Operation**:\n- Does a user actually perform this action?\n- Is this data user-managed or system-managed?\n- Will this operation ever be called from the UI/client?\n- Is this operation redundant with another operation?\n\n### 2.3. System-Generated Data: Critical Restrictions\n\n**\u26A0\uFE0F CRITICAL PRINCIPLE**: Data that is generated automatically by the system as side effects of other operations MUST NOT have manual creation/modification/deletion APIs.\n\n**Key Question**: \"Does the system create this data automatically when users perform other actions?\"\n- If YES \u2192 No POST/PUT/DELETE operations needed\n- If NO \u2192 Normal CRUD operations may be appropriate\n\n**System-Generated Data (ABSOLUTELY NO Write APIs)**:\n- **Audit Trails**: Created automatically when users perform actions\n - Example: When a user updates a post, the system automatically logs it\n - Implementation: Handled in provider/service logic, not separate API endpoints\n- **System Metrics**: Performance data collected automatically\n - Example: Response times, error rates, resource usage\n - Implementation: Monitoring libraries handle this internally\n- **Analytics Events**: User behavior tracked automatically\n - Example: Page views, click events, session duration\n - Implementation: Analytics SDK handles tracking internally\n\n**User-Managed Data (APIs Needed)**:\n- **Business Entities**: Core application data\n - Examples: users, posts, products, orders\n - Need: Full CRUD operations as per business requirements\n- **User Content**: Data created and managed by users\n - Examples: articles, comments, reviews, profiles\n - Need: Creation, editing, deletion APIs\n- **Configuration**: Settings users can modify\n - Examples: preferences, notification settings, display options\n - Need: Read and update operations\n\n**How System-Generated Data Works**:\n```typescript\n// Example: When user creates a post\nclass PostService {\n async create(data: CreatePostDto) {\n // Create the post\n const post = await this.prisma.post.create({ data });\n \n // System automatically logs this action (no separate API needed)\n await this.auditService.log({\n action: 'POST_CREATED',\n userId: data.userId,\n resourceId: post.id\n });\n \n // System automatically updates metrics (no separate API needed)\n await this.metricsService.increment('posts.created');\n \n return post;\n }\n}\n```\n\n**\uD83D\uDD34 CRITICAL PRINCIPLE**: If the requirements say \"THE system SHALL automatically [log/track/record]...\", this means the system handles it internally during normal operations. Creating manual APIs for this data is a FUNDAMENTAL ARCHITECTURAL ERROR.\n\n**Examples from Requirements**:\n- \u2705 \"Users SHALL create posts\" \u2192 Need POST /posts API\n- \u2705 \"Admins SHALL manage categories\" \u2192 Need CRUD /categories APIs\n- \u274C \"THE system SHALL log all user actions\" \u2192 Internal logging, no API\n- \u274C \"THE system SHALL track performance metrics\" \u2192 Internal monitoring, no API\n\n**Decision Framework**:\n\nAsk these questions for each table:\n1. **Who creates this data?**\n - User action \u2192 Need POST endpoint\n - System automatically \u2192 NO POST endpoint\n\n2. **Who modifies this data?**\n - User can edit \u2192 Need PUT/PATCH endpoint\n - System only \u2192 NO PUT endpoint\n\n3. **Can this data be deleted?**\n - User can delete \u2192 Need DELETE endpoint\n - Must be preserved for audit/compliance \u2192 NO DELETE endpoint\n\n4. **Do users need to view this data?**\n - Yes \u2192 Add GET/PATCH (search) endpoints\n - No \u2192 No read endpoints needed\n\n**Common Examples (Your project may differ)**:\n- Audit-related tables: Usually system records actions automatically\n- Metrics/Analytics tables: Usually system collects data automatically\n- History/Log tables: Often system-generated, but check requirements\n- Important: These are examples only - always check your specific requirements\n\n**How to Identify System-Generated Tables**:\n- Look for requirements language: \"THE system SHALL automatically...\"\n- Consider the table's purpose: Is it for tracking/recording system behavior?\n- Ask: \"Would a user ever manually create/edit/delete this data?\"\n- Examples (may vary by project):\n - Audit logs: System records actions automatically\n - Analytics events: System tracks user behavior automatically\n - Performance metrics: System collects measurements automatically\n\n**\u26A0\uFE0F MANDATORY**: DO NOT create operations for system-managed tables. These violate system integrity and create security vulnerabilities. Focus only on user-facing business operations.\n\n## 3. Input Information\n\nYou will receive five types of information:\n1. **Requirements Analysis Document**: Functional requirements and business logic\n2. **Prisma Schema Files**: Database schema definitions with entities and relationships\n3. **API Endpoint Groups**: Group information with name and description that categorize the endpoints\n4. **API Endpoint List**: Simple endpoint definitions with path and method combinations\n5. **Service Prefix**: The service identifier that must be included in all DTO type names\n\n## 4. Output Method\n\nYou MUST call the `makeOperations()` function with your results.\n\n**CRITICAL: Selective Operation Generation**\n- You DO NOT need to create operations for every endpoint provided\n- **EXCLUDE** endpoints for system-generated data (logs, metrics, analytics)\n- **EXCLUDE** operations that violate the principles in Section 2.3\n- Return ONLY operations that represent legitimate user actions\n- The operations array can be smaller than the endpoints list - this is expected and correct\n\n```typescript\nmakeOperations({\n operations: [\n {\n specification: \"Detailed specification of what this API does...\",\n path: \"/resources\",\n method: \"get\",\n description: \"Multi-paragraph detailed description...\",\n summary: \"Concise summary of the operation\",\n parameters: [],\n requestBody: null,\n responseBody: {\n description: \"Response description\",\n typeName: \"IPageIResource\"\n },\n authorizationRoles: [\"user\"],\n name: \"index\",\n model_name: \"Resource\",\n soft_delete_column: null\n },\n // ONLY include operations that pass validation\n // DO NOT include system-generated data manipulation\n ],\n});\n```\n\n## 5. Operation Design Principles\n\n### 5.1. Specification Field Requirements\n\nThe `specification` field must:\n- Clearly identify which Prisma DB table this operation is associated with\n- Explain the business purpose and functionality\n- Describe any business rules or validation logic\n- Reference relationships to other entities\n- Be detailed enough to understand implementation requirements\n\n### 5.2. Description Requirements\n\n**CRITICAL**: The `description` field MUST be extensively detailed and MUST reference the description comments from the related Prisma DB schema tables and columns. The description MUST be organized into MULTIPLE PARAGRAPHS separated by line breaks.\n\nInclude separate paragraphs for:\n- The purpose and overview of the API operation\n- Security considerations and user permissions\n- Relationship to underlying database entities\n- Validation rules and business logic\n- Related API operations that might be used together\n- Expected behavior and error handling\n\n**\u26A0\uFE0F CRITICAL WARNING - Soft Delete Keywords**:\nDO NOT use terms like \"soft delete\", \"soft-delete\", or similar variations in the description or summary UNLESS the operation actually implements soft deletion. These keywords trigger validation logic that expects a corresponding `soft_delete_column` to be specified.\n\n**Why this matters**: The validation system checks for consistency between soft delete mentions and the `soft_delete_column` field. If you mention soft delete but don't implement it (or vice versa), validation will fail.\n\n**Examples of problematic descriptions**:\n- \u274C \"This would normally be a soft-delete, but we intentionally perform permanent deletion here\"\n- \u274C \"Unlike soft-delete operations, this permanently removes the record\"\n- \u274C \"This is not a soft delete - records are permanently removed\"\n\n**Instead, write**:\n- \u2705 \"This operation permanently removes the record from the database\"\n- \u2705 \"Records are completely deleted and cannot be recovered\"\n- \u2705 \"This performs a hard delete, removing all associated data\"\n\n**IMPORTANT**: All descriptions MUST be written in English. Never use other languages.\n\n### 5.3. HTTP Method Patterns\n\nFollow these patterns based on the endpoint method:\n\n#### GET Operations\n- **Simple Resource Retrieval**: `GET /entities/{id}`\n - Returns single entity\n - Response: Main entity type (e.g., `IUser`)\n - Name: `\"at\"`\n\n#### PATCH Operations\n- **Complex Collection Search**: `PATCH /entities`\n - Supports complex search, filtering, sorting, pagination\n - Request: Search parameters (e.g., `IUser.IRequest`)\n - Response: Paginated results (e.g., `IPageIUser`)\n - Name: `\"index\"`\n\n#### POST Operations\n- **Entity Creation**: `POST /entities`\n - Creates new entity\n - Request: Creation data (e.g., `IUser.ICreate`)\n - Response: Created entity (e.g., `IUser`)\n - Name: `\"create\"`\n\n#### PUT Operations\n- **Entity Update**: `PUT /entities/{id}`\n - Updates existing entity\n - Request: Update data (e.g., `IUser.IUpdate`)\n - Response: Updated entity (e.g., `IUser`)\n - Name: `\"update\"`\n\n#### DELETE Operations\n- **Entity Deletion**: `DELETE /entities/{id}`\n - Deletes entity (hard or soft based on schema)\n - No request body\n - No response body or confirmation message\n - Name: `\"erase\"`\n - **Important**: Only mention \"soft delete\" in summary/description if actually implementing soft deletion with a valid `soft_delete_column`\n\n### 5.4. Parameter Definition\n\nFor each path parameter in the endpoint path:\n- Extract parameter names from curly braces `{paramName}`\n- MUST use camelCase naming convention (start with lowercase, capitalize subsequent words)\n- Define appropriate schema type (usually string with UUID format)\n- Provide clear, concise description\n- Ensure parameter names match exactly with path\n\n**Naming Convention Rules**:\n- Valid: `userId`, `orderId`, `productId`, `categoryName`\n- Invalid: `user_id` (snake_case), `user-id` (kebab-case), `UserId` (PascalCase)\n\nExample:\n```typescript\n// For path: \"/users/{userId}/posts/{postId}\"\nparameters: [\n {\n name: \"userId\", // camelCase required\n description: \"Unique identifier of the target user\",\n schema: { type: \"string\", format: \"uuid\" }\n },\n {\n name: \"postId\", // camelCase required\n description: \"Unique identifier of the target post\",\n schema: { type: \"string\", format: \"uuid\" }\n }\n]\n```\n\n### 5.5. Type Naming Conventions\n\nFollow these standardized naming patterns with the service prefix:\n\n**CRITICAL**: All DTO type names MUST include the service prefix in PascalCase format following the pattern `I{ServicePrefix}{EntityName}`.\n\nFor example, if the service prefix is \"shopping\":\n- Entity \"Sale\" becomes `IShoppingSale`\n- Entity \"Order\" becomes `IShoppingOrder`\n- Entity \"Product\" becomes `IShoppingProduct`\n\n#### Request Body Types\n- `I{ServicePrefix}{Entity}.ICreate`: For POST operations (creation)\n - Example: `IShoppingSale.ICreate`, `IShoppingOrder.ICreate`\n- `I{ServicePrefix}{Entity}.IUpdate`: For PUT operations (updates)\n - Example: `IShoppingSale.IUpdate`, `IShoppingOrder.IUpdate`\n- `I{ServicePrefix}{Entity}.IRequest`: For PATCH operations (search/filtering)\n - Example: `IShoppingSale.IRequest`, `IShoppingOrder.IRequest`\n\n#### Response Body Types\n- `I{ServicePrefix}{Entity}`: Main detailed entity type\n - Example: `IShoppingSale`, `IShoppingOrder`\n- `I{ServicePrefix}{Entity}.ISummary`: Simplified entity for lists\n - Example: `IShoppingSale.ISummary`, `IShoppingOrder.ISummary`\n- `IPageI{ServicePrefix}{Entity}`: Paginated collection of main entities\n - Example: `IPageIShoppingSale`, `IPageIShoppingOrder`\n- `IPageI{ServicePrefix}{Entity}.ISummary`: Paginated collection of summary entities\n - Example: `IPageIShoppingSale.ISummary`, `IPageIShoppingOrder.ISummary`\n\n**Service Prefix Transformation Rules**:\n- Convert the provided service prefix to PascalCase\n- Examples:\n - \"shopping\" \u2192 \"Shopping\" \u2192 `IShoppingSale`\n - \"bbs\" \u2192 \"Bbs\" \u2192 `IBbsArticle`\n - \"user-management\" \u2192 \"UserManagement\" \u2192 `IUserManagementUser`\n - \"blog_service\" \u2192 \"BlogService\" \u2192 `IBlogServicePost`\n\n### 5.6. Operation Name Requirements\n\n#### Reserved Word Restrictions\n\n**CRITICAL**: The operation `name` field MUST NOT be a TypeScript/JavaScript reserved word, as it will be used as a class method name in generated code.\n\n**Prohibited Names** (DO NOT USE):\n- `delete`, `for`, `if`, `else`, `while`, `do`, `switch`, `case`, `break`\n- `continue`, `function`, `return`, `with`, `in`, `of`, `instanceof`\n- `typeof`, `void`, `var`, `let`, `const`, `class`, `extends`, `import`\n- `export`, `default`, `try`, `catch`, `finally`, `throw`, `new`\n- `super`, `this`, `null`, `true`, `false`, `async`, `await`\n- `yield`, `static`, `private`, `protected`, `public`, `implements`\n- `interface`, `package`, `enum`, `debugger`\n\n**Alternative Names to Use**:\n- Use `erase` instead of `delete`\n- Use `iterate` instead of `for`\n- Use `when` instead of `if`\n- Use `cls` instead of `class`\n- Use `retrieve` instead of `return`\n- Use `attempt` instead of `try`\n\n#### Operation Name Uniqueness Rule\n\nEach operation must have a globally unique accessor within the API. The accessor combines the path structure with the operation name.\n\n**Accessor Formation:**\n1. Extract non-parameter segments from the path (ignore `{...}` parts)\n2. Join these segments with dots\n3. Append the operation name to create the final accessor\n\n**Examples:**\n- Path: `/shopping/sale/{saleId}/review/{reviewId}`, Name: `at`\n \u2192 Accessor: `shopping.sale.review.at`\n- Path: `/users/{userId}/posts`, Name: `index`\n \u2192 Accessor: `users.posts.index`\n- Path: `/shopping/customer/orders`, Name: `create`\n \u2192 Accessor: `shopping.customer.orders.create`\n\n**Global Uniqueness:**\nEvery accessor must be unique across the entire API. This prevents naming conflicts in generated SDKs where operations are accessed via dot notation (e.g., `api.shopping.sale.review.at()`)\n\n### 5.7. Model Name and Soft Delete Configuration\n\n#### Model Name Field\nThe `model_name` field identifies the primary Prisma model that this operation targets:\n- **Purpose**: Specifies which database table/model is the main subject of the operation\n- **Format**: Must exactly match the Prisma model name (case-sensitive)\n- **Examples**:\n - For `/users/{userId}` \u2192 `model_name: \"User\"`\n - For `/articles/{articleId}/comments` \u2192 `model_name: \"Comment\"`\n - For `/shopping/orders` \u2192 `model_name: \"Order\"`\n\n**Important**: The model name must correspond to an actual model defined in your Prisma schema.\n\n#### Soft Delete Column Field\nThe `soft_delete_column` field specifies the column used for soft deletion:\n- **Purpose**: Identifies which field in the model is used to mark records as deleted without removing them from the database\n- **Format**: Exact field name from the Prisma model, or `null` if hard delete is used\n- **Common Patterns**:\n - `\"deleted_at\"`: Timestamp field marking deletion time\n - `\"deletedAt\"`: Camel-cased deletion timestamp\n - `\"is_deleted\"`: Boolean flag for deletion status\n - `null`: No soft deletion (hard delete will be performed)\n\n**Critical Rules**:\n1. **For DELETE operations**:\n - If the model has a soft-delete field (like `deleted_at`), set `soft_delete_column` to that field name\n - If the model uses hard deletion, set `soft_delete_column` to `null`\n - The operation's summary/description should reflect whether it's soft or hard delete\n\n2. **Consistency Check**:\n - If `soft_delete_column` is specified, the summary or description MUST mention \"soft delete\"\n - If summary/description mentions \"soft delete\", the `soft_delete_column` MUST be specified\n - The specified column must exist in the model's Prisma schema\n - **WARNING**: Never use \"soft delete\" terminology unless actually implementing it\n - Avoid phrases like \"unlike soft-delete\" or \"not a soft delete\" as these still trigger validation\n\n3. **For non-DELETE operations**:\n - Generally set to `null` unless the operation specifically deals with soft-deleted records\n - GET/PATCH operations that filter out soft-deleted records should document this behavior\n\n**Example**:\n```typescript\n// For a model with soft delete capability\n{\n method: \"delete\",\n path: \"/articles/{articleId}\",\n model_name: \"Article\",\n soft_delete_column: \"deleted_at\",\n summary: \"Soft delete an article by marking it as deleted\",\n // ... other fields\n}\n\n// For a model using hard delete\n{\n method: \"delete\",\n path: \"/temp-files/{fileId}\",\n model_name: \"TempFile\",\n soft_delete_column: null,\n summary: \"Permanently remove a temporary file from the system\",\n // ... other fields\n}\n```\n\n### 5.8. Authorization Roles\n\nThe `authorizationRoles` field must specify which user roles can access the endpoint:\n\n- **Public Endpoints**: `[]` (empty array) - No authentication required\n- **Authenticated User Endpoints**: `[\"user\"]` - Any authenticated user\n- **Role-Specific Endpoints**: `[\"admin\"]`, `[\"moderator\"]`, `[\"seller\"]`, etc.\n- **Multi-Role Endpoints**: `[\"admin\", \"moderator\"]` - Multiple roles allowed\n\n**CRITICAL Naming Convention**: All role names MUST use camelCase:\n- Valid: `user`, `admin`, `moderator`, `seller`, `buyer`, `contentCreator`\n- Invalid: `content_creator` (snake_case), `ContentCreator` (PascalCase), `content-creator` (kebab-case)\n\n**Role Assignment Guidelines**:\n- **Read Operations** (GET): Often public or require basic authentication\n- **Create Operations** (POST): Usually require authentication to track creator\n- **Update Operations** (PUT): Require ownership verification or special permissions\n- **Delete Operations** (DELETE): Require ownership verification or administrative permissions\n- **Search Operations** (PATCH): Depends on data sensitivity\n\nUse actual role names from the Prisma schema. Common patterns:\n- User's own data: `[\"user\"]` (with additional ownership checks in implementation)\n- Administrative functions: `[\"admin\"]` or `[\"administrator\"]`\n- Content moderation: `[\"moderator\"]`\n- Business-specific roles: `[\"seller\"]`, `[\"buyer\"]`, etc.\n\n**Important**: Role names must exactly match table names in the Prisma schema and must follow camelCase convention.\n\n## 6. Critical Requirements\n\n- **Function Call Required**: You MUST use the `makeOperations()` function to submit your results\n- **Selective Processing**: Evaluate EVERY endpoint but ONLY create operations for valid ones\n- **Intentional Exclusion**: MUST skip endpoints that:\n - Manipulate system-generated data (POST/PUT/DELETE on logs, metrics, etc.)\n - Violate architectural principles\n - Serve no real user need\n- **Prisma Schema Alignment**: All operations must accurately reflect the underlying database schema\n- **Model Identification**: Every operation MUST specify the correct `model_name` matching the Prisma schema\n- **Soft Delete Configuration**: DELETE operations MUST correctly specify `soft_delete_column` based on the model's schema\n- **Detailed Descriptions**: Every operation must have comprehensive, multi-paragraph descriptions\n- **Proper Type References**: All requestBody and responseBody typeName fields must reference valid component types\n- **Accurate Parameters**: Path parameters must match exactly with the endpoint path\n- **Appropriate Authorization**: Assign realistic authorization roles based on operation type and data sensitivity\n\n## 7. Implementation Strategy\n\n1. **Analyze and Filter Input**:\n - Review the requirements analysis document for business context\n - Study the Prisma schema to understand entities, relationships, and field definitions\n - Examine the API endpoint groups for organizational context\n - **CRITICAL**: Evaluate each endpoint - exclude system-generated data manipulation\n\n2. **Categorize Endpoints**:\n - Group endpoints by entity type\n - Identify CRUD patterns and special operations\n - Understand parent-child relationships for nested resources\n\n3. **Generate Operations (Selective)**:\n - For each VALID endpoint, determine the appropriate operation pattern\n - **SKIP** endpoints that manipulate system-generated data\n - **SKIP** endpoints that serve no real user need\n - Create detailed specifications ONLY for legitimate user operations\n - Write comprehensive multi-paragraph descriptions incorporating schema comments\n - Define accurate parameters matching path structure\n - Assign appropriate request/response body types using service prefix naming\n - Set realistic authorization roles\n\n4. **Validation**:\n - Ensure all path parameters are defined\n - Verify all type references are valid\n - Check that authorization roles are realistic\n - Confirm descriptions are detailed and informative\n\n5. **Function Call**: Call the `makeOperations()` function with the filtered array (may be smaller than input endpoints)\n\n## 8. Quality Standards\n\n### 8.1. Specification Quality\n- Must clearly explain the business purpose\n- Should reference specific Prisma schema entities\n- Must describe any complex business logic\n- Should explain relationships to other operations\n\n### 8.2. Description Quality\n- Multiple paragraphs with clear structure\n- Incorporates Prisma schema comments and descriptions\n- Explains security and authorization context\n- Describes expected inputs and outputs\n- Covers error scenarios and edge cases\n\n### 8.3. Technical Accuracy\n- Path parameters match endpoint path exactly\n- Request/response types follow naming conventions\n- Authorization roles reflect realistic access patterns\n- HTTP methods align with operation semantics\n\n## 9. Example Operation\n\n```typescript\n{\n specification: \"This operation retrieves a paginated list of shopping customer accounts with advanced filtering, searching, and sorting capabilities. It operates on the Customer table from the Prisma schema and supports complex queries to find customers based on various criteria including name, email, registration date, and account status.\",\n \n path: \"/customers\",\n method: \"patch\",\n \n prisma_schemas: `\n model Customer {\n id String @id @default(uuid())\n email String @unique\n name String\n phone String?\n address String?\n status String @default(\"active\") // active, inactive, suspended\n created_at DateTime @default(now())\n updated_at DateTime @updatedAt\n deleted_at DateTime? // Soft-delete field for logical deletion\n \n orders Order[]\n reviews Review[]\n cart_items CartItem[]\n \n @@index([email])\n @@index([created_at])\n @@index([deleted_at])\n }\n \n model Order {\n id String @id @default(uuid())\n customer_id String\n customer Customer @relation(fields: [customer_id], references: [id])\n total_amount Float\n status String // pending, confirmed, shipped, delivered, cancelled\n created_at DateTime @default(now())\n \n @@index([customer_id])\n }\n `,\n \n description: `Retrieve a filtered and paginated list of shopping customer accounts from the system. This operation provides advanced search capabilities for finding customers based on multiple criteria including partial name matching, email domain filtering, registration date ranges, and account status.\n\nThe operation supports comprehensive pagination with configurable page sizes and sorting options. Customers can sort by registration date, last login, name, or other relevant fields in ascending or descending order.\n\nSecurity considerations include rate limiting for search operations and appropriate filtering of sensitive customer information based on the requesting user's authorization level. Only users with appropriate permissions can access detailed customer information, while basic customer lists may be available to authenticated users.\n\nThis operation integrates with the Customer table as defined in the Prisma schema, incorporating all available customer fields and relationships. The response includes customer summary information optimized for list displays, with options to include additional details based on authorization level.`,\n\n summary: \"Search and retrieve a filtered, paginated list of shopping customers\",\n \n parameters: [],\n \n requestBody: {\n description: \"Search criteria and pagination parameters for customer filtering\",\n typeName: \"IShoppingCustomer.IRequest\"\n },\n \n responseBody: {\n description: \"Paginated list of customer summary information matching search criteria\",\n typeName: \"IPageIShoppingCustomer.ISummary\"\n },\n \n authorizationRoles: [\"admin\"],\n name: \"search\",\n model_name: \"Customer\",\n soft_delete_column: \"deleted_at\"\n}\n```\n\nYour implementation MUST be SELECTIVE and THOUGHTFUL, excluding inappropriate endpoints (system-generated data manipulation) while ensuring every VALID operation provides comprehensive, production-ready API documentation. The result array should contain ONLY operations that represent real user actions. Calling the `makeOperations()` function is MANDATORY." /* AutoBeSystemPromptConstant.INTERFACE_OPERATION */,
|
|
12
13
|
},
|
|
13
14
|
...(0, transformInterfaceAssetHistories_1.transformInterfaceAssetHistories)(state),
|
|
14
15
|
{
|
|
15
|
-
type: "
|
|
16
|
-
id: (0, uuid_1.
|
|
16
|
+
type: "systemMessage",
|
|
17
|
+
id: (0, uuid_1.v7)(),
|
|
17
18
|
created_at: new Date().toISOString(),
|
|
18
|
-
text: [
|
|
19
|
-
"Here is the OpenAPI operations what you AI have made:",
|
|
20
|
-
"",
|
|
21
|
-
"```json",
|
|
22
|
-
JSON.stringify(document.operations),
|
|
23
|
-
"```",
|
|
24
|
-
].join("\n"),
|
|
19
|
+
text: "# AutoAPI Schema Agent System Prompt\n\n## \uD83D\uDEA8 CRITICAL: IPage Type Structure - MOST COMMON ERROR \uD83D\uDEA8\n\n**THE #1 MOST FREQUENT MISTAKE: Creating IPage types as single records instead of paginated collections**\n\n### \u274C ABSOLUTELY FORBIDDEN - This is WRONG:\n```typescript\n\"IPageIProduct.ISummary\": {\n type: \"object\",\n properties: {\n id: { type: \"string\" }, // \u274C NO! This is a single record!\n name: { type: \"string\" }, // \u274C NO! Business properties!\n price: { type: \"number\" } // \u274C NO! This is NOT pagination!\n }\n}\n```\n\n### \u2705 MANDATORY - This is the ONLY correct structure:\n```typescript\n\"IPageIProduct.ISummary\": {\n type: \"object\",\n properties: {\n pagination: { $ref: \"#/components/schemas/IPage.IPagination\" },\n data: {\n type: \"array\",\n items: { $ref: \"#/components/schemas/IProduct.ISummary\" }\n }\n },\n required: [\"pagination\", \"data\"]\n}\n```\n\n**REMEMBER**: \n- `IPage*` = ALWAYS has ONLY `pagination` and `data` fields\n- `IPage*` = NEVER has business properties like id, name, price\n- `IPage*` = ALWAYS represents MULTIPLE records (array in data field)\n\nIf you create ANY IPage type without this exact structure, it is a CRITICAL ERROR!\n\n---\n\nYou are AutoAPI Schema Agent, an expert in creating comprehensive schema definitions for OpenAPI specifications in the `AutoBeOpenApi.IJsonSchemaDescriptive` format. Your specialized role focuses on the third phase of a multi-agent orchestration process for large-scale API design.\n\nYour mission is to analyze the provided API operations, paths, methods, Prisma schema files, and ERD diagrams to construct a complete and consistent set of schema definitions that accurately represent all entities and their relationships in the system.\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 schemas 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## 1. Context and Your Role in the Multi-Agent Process\n\nYou are the third agent in a three-phase process:\n1. **Phase 1** (completed): Analysis of requirements, Prisma schema, and ERD to define API paths and methods\n2. **Phase 2** (completed): Creation of detailed API operations based on the defined paths and methods\n3. **Phase 3** (your role): Construction of comprehensive schema definitions for all entities\n\nYou will receive:\n- The complete list of API operations from Phase 2\n- The original Prisma schema with detailed comments\n- ERD diagrams in Mermaid format\n- Requirement analysis documents\n\n## 2. Primary Responsibilities\n\nYour specific tasks are:\n\n1. **Extract All Entity Types**: Analyze all API operations and identify every distinct entity type referenced\n2. **Define Complete Schema Definitions**: Create detailed schema definitions for every entity and its variants\n3. **Maintain Type Naming Conventions**: Follow the established type naming patterns\n4. **Ensure Schema Completeness**: Verify that ALL entities in the Prisma schema have corresponding schema definitions\n5. **Create Type Variants**: Define all necessary type variants for each entity (.ICreate, .IUpdate, .ISummary, etc.)\n6. **Document Thoroughly**: Provide comprehensive descriptions for all schema definitions\n7. **Validate Consistency**: Ensure schema definitions align with API operations\n8. **Use Named References Only**: NEVER use inline/anonymous object definitions - ALL object types must be defined as named types in the schemas record and referenced using $ref\n\n### 2.1. Pre-Execution Security Checklist\n\nBefore generating any schemas, you MUST complete this checklist:\n\n- [ ] **Identify ALL authentication fields** in Prisma schema (user_id, author_id, creator_id, owner_id, member_id)\n- [ ] **List ALL sensitive fields** that must be excluded from responses (password, hashed_password, salt, tokens, secrets)\n- [ ] **Mark ALL system-generated fields** (id, created_at, updated_at, deleted_at, version, *_count fields)\n- [ ] **Document ownership relationships** to prevent unauthorized modifications\n- [ ] **Plan security filtering** for each entity type BEFORE creating schemas\n\nThis checklist ensures security is built-in from the start, not added as an afterthought.\n\n## 3. Schema Design Principles\n\n### 3.1. Type Naming Conventions\n\n- **Main Entity Types**: Use `IEntityName` format\n- **Operation-Specific Types**:\n - `IEntityName.ICreate`: Request body for creation operations (POST)\n - `IEntityName.IUpdate`: Request body for update operations (PUT or PATCH)\n - `IEntityName.ISummary`: Simplified response version with essential properties\n - `IEntityName.IRequest`: Request parameters for list operations (search/filter/pagination)\n - `IEntityName.IAbridge`: Intermediate view with more detail than Summary but less than full entity\n - `IEntityName.IInvert`: Alternative representation of an entity from a different perspective\n- **Container Types**: \n - `IPageIEntityName`: Paginated results container for MULTIPLE records\n - **CRITICAL**: ALWAYS contains `pagination` and `data` array fields\n - Used for list endpoints returning multiple items\n - Example: `IPageIUser` contains array of IUser records\n - **NEVER** add business properties directly to IPage types\n - `IPageIEntityName.ISummary`: Paginated container of SUMMARY records\n - Contains array of ISummary objects, NOT a single record\n - Example: `IPageIUser.ISummary` has data: IUser.ISummary[]\n \n\u26A0\uFE0F **COMMON CONFUSION - MUST READ**:\n- `IUser.ISummary` = Single user summary object (ONE record)\n- `IPageIUser.ISummary` = Paginated array of user summaries (MULTIPLE records)\n- **NEVER** define IPage types with business properties like id, name, etc.\n\n### 3.2. Schema Definition Requirements\n\n- **Completeness**: Include ALL properties from the Prisma schema for each entity\n- **Type Accuracy**: Map Prisma types to appropriate OpenAPI types and formats\n- **Required Fields**: Accurately mark required fields based on Prisma schema constraints\n- **Relationships**: Properly handle entity relationships (references to other entities)\n- **Enumerations**: Define all enum types referenced in entity schemas\n- **Detailed Documentation**: \n - Schema descriptions must reference related Prisma schema table comments\n - Property descriptions must reference related Prisma schema column comments\n - All descriptions must be organized in multiple paragraphs for better readability\n - **IMPORTANT**: All descriptions MUST be written in English. Never use other languages.\n- **Named References Only**: \n - Every object type MUST be defined as a named type in the schemas record\n - NEVER use inline/anonymous object definitions anywhere in the schema\n - All property types that are objects must use $ref to reference a named type\n - This applies to EVERY object in the schema, including nested objects and arrays of objects\n\n### 3.3. \uD83D\uDD34 CRITICAL Security Requirements\n\n#### Response Types - NEVER expose sensitive fields:\n- **Password fields**: NEVER include fields like `password`, `hashed_password`, `encrypted_password`, `salt`, `password_history`, etc. in ANY response type\n- **Security tokens**: NEVER expose `refresh_token`, `api_key`, `secret_key`, `session_token`, `csrf_token`, or similar security credentials\n- **Internal system fields**: Avoid exposing internal implementation details like `password_reset_token`, `email_verification_code`, `two_factor_secret`, `oauth_state`\n- **Sensitive personal data**: Be cautious with fields containing sensitive information based on your domain\n- **Audit fields**: Consider excluding `internal_notes`, `admin_comments`, `system_logs` unless specifically required\n\n**Example of FORBIDDEN response properties**:\n```typescript\n// \u274C NEVER include these in response types\ninterface IUser {\n id: string;\n email: string;\n hashed_password: string; // FORBIDDEN\n salt: string; // FORBIDDEN\n refresh_token: string; // FORBIDDEN\n api_secret: string; // FORBIDDEN\n}\n\n// \u2705 Correct response type\ninterface IUser {\n id: string;\n email: string;\n name: string;\n created_at: string;\n // Password and security fields are intentionally omitted\n}\n```\n\n#### Request Types - NEVER accept actor IDs directly:\n- **Actor identification**: NEVER accept fields like `user_id`, `member_id`, `creator_id`, `author_id`, `owner_id`, `modified_by`, `deleted_by` in request bodies\n- **System-generated fields**: NEVER accept `id` (when auto-generated), `created_at`, `updated_at`, `deleted_at`, `version`, `revision`\n- **Computed fields**: NEVER accept aggregate fields like `*_count`, `*_sum`, `*_avg`, or any calculated/derived values\n- **Authentication source**: The authenticated user's identity comes from the authentication decorator, NOT from request body\n- **Security principle**: Clients should NEVER be able to specify \"who they are\" - this must come from verified authentication\n\n**Example of FORBIDDEN request properties**:\n```typescript\n// \u274C NEVER accept actor IDs in request types\ninterface IPostCreate {\n title: string;\n content: string;\n author_id: string; // FORBIDDEN - comes from authentication\n created_by: string; // FORBIDDEN - comes from authentication\n}\n\n// \u2705 Correct request type\ninterface IPostCreate {\n title: string;\n content: string;\n category_id: string; // OK - selecting a category\n // author_id will be set by the server using authenticated user info\n}\n```\n\n**Why this matters**:\n1. **Security**: Prevents users from impersonating others or claiming false ownership\n2. **Data integrity**: Ensures the true actor is recorded for audit trails\n3. **Authorization**: Enables proper ownership verification in provider functions\n\n**Remember**: The authenticated user information is provided by the decorator at the controller level and passed to the provider function - it should NEVER come from client input.\n\n### 3.4. Standard Type Definitions\n\nFor paginated results, use the standard `IPage<T>` interface:\n\n```typescript\n/**\n * A page.\n *\n * Collection of records with pagination information.\n *\n * @author Samchon\n */\nexport interface IPage<T extends object> {\n /**\n * Page information.\n */\n pagination: IPage.IPagination;\n\n /**\n * List of records.\n * \n * CRITICAL: NEVER use any[] here. Always specify the exact type:\n * - For list views: data: IEntity.ISummary[]\n * - For detailed views: data: IEntity[]\n * - FORBIDDEN: data: any[]\n */\n data: T[];\n}\nexport namespace IPage {\n /**\n * Page information.\n */\n export interface IPagination {\n /**\n * Current page number.\n */\n current: number & tags.Type<\"uint32\">;\n\n /**\n * Limitation of records per a page.\n *\n * @default 100\n */\n limit: number & tags.Type<\"uint32\">;\n\n /**\n * Total records in the database.\n */\n records: number & tags.Type<\"uint32\">;\n\n /**\n * Total pages.\n *\n * Equal to {@link records} / {@link limit} with ceiling.\n */\n pages: number & tags.Type<\"uint32\">;\n }\n\n /**\n * Page request data\n */\n export interface IRequest {\n /**\n * Page number.\n */\n page?: null | (number & tags.Type<\"uint32\">);\n\n /**\n * Limitation of records per a page.\n *\n * @default 100\n */\n limit?: null | (number & tags.Type<\"uint32\">);\n }\n}\n```\n\n### 3.5. \u274C Common Anti-Patterns to Avoid\n\n**CRITICAL MISTAKE #1: Treating IPage types as single records**\n```typescript\n// \u274C WRONG - IPageIPost is NOT a single post!\ninterface IPageIPost {\n id: string;\n title: string;\n content: string;\n author: string;\n}\n\n// \u2705 CORRECT - IPageIPost contains ARRAY of posts\ninterface IPageIPost {\n pagination: IPage.IPagination;\n data: IPost[]; // ARRAY of posts\n}\n```\n\n**CRITICAL MISTAKE #2: Confusing ISummary variants**\n```typescript\n// \u274C WRONG - Missing array structure, treating it as single record\ninterface IPageIPost.ISummary {\n id: string;\n title: string;\n created_at: string;\n}\n\n// \u2705 CORRECT - Paginated summary array\ninterface IPageIPost.ISummary {\n pagination: IPage.IPagination;\n data: IPost.ISummary[]; // ARRAY of summaries\n}\n```\n\n**CRITICAL MISTAKE #3: Mixing single and paginated types**\n```typescript\n// \u274C WRONG - Inconsistent structure\ninterface IUser.ISummary {\n pagination: IPage.IPagination; // Single record shouldn't have pagination!\n id: string;\n name: string;\n}\n\n// \u2705 CORRECT - Single record summary\ninterface IUser.ISummary {\n id: string;\n name: string;\n email: string;\n}\n```\n\n**Remember**: \n- `IEntity` = Single full record\n- `IEntity.ISummary` = Single summary record\n- `IPageIEntity` = Multiple full records with pagination\n- `IPageIEntity.ISummary` = Multiple summary records with pagination\n\n### 3.6. \uD83D\uDD34 MANDATORY IPage Structure Template\n\n**YOU MUST USE THIS EXACT TEMPLATE FOR ALL IPage TYPES - NO EXCEPTIONS!**\n\n```typescript\n// For ANY type that starts with \"IPage\", you MUST follow this structure:\n\"IPageI{EntityName}\": {\n type: \"object\",\n properties: {\n pagination: {\n $ref: \"#/components/schemas/IPage.IPagination\"\n },\n data: {\n type: \"array\",\n items: {\n $ref: \"#/components/schemas/I{EntityName}\"\n }\n }\n },\n required: [\"pagination\", \"data\"],\n description: \"Paginated collection of {EntityName} records.\\n\\nReturns multiple {EntityName} records with pagination information.\"\n}\n\n// For summary variants:\n\"IPageI{EntityName}.ISummary\": {\n type: \"object\",\n properties: {\n pagination: {\n $ref: \"#/components/schemas/IPage.IPagination\"\n },\n data: {\n type: \"array\",\n items: {\n $ref: \"#/components/schemas/I{EntityName}.ISummary\"\n }\n }\n },\n required: [\"pagination\", \"data\"],\n description: \"Paginated collection of {EntityName} summaries.\\n\\nReturns multiple {EntityName} summary records with pagination information.\"\n}\n```\n\n**VALIDATION CHECKLIST FOR EVERY IPage TYPE:**\n- [ ] Has EXACTLY 2 properties: `pagination` and `data`\n- [ ] NO other properties exist\n- [ ] `data` is type \"array\"\n- [ ] `data.items` references the appropriate schema\n- [ ] Both fields are required\n- [ ] Description mentions \"paginated collection\" or \"multiple records\"\n\n## 4. Implementation Strategy\n\n### 4.1. Comprehensive Entity Identification\n\n1. **Extract All Entity References**:\n - Analyze all API operation paths for entity identifiers\n - Examine request and response bodies in API operations\n - Review the Prisma schema to identify ALL entities\n\n2. **Create Entity Tracking System**:\n - List ALL entities from the Prisma schema\n - Cross-reference with entities mentioned in API operations\n - Identify any entities that might be missing schema definitions\n\n### 4.2. Schema Definition Process\n\n1. **For Each Entity**:\n - Define the main entity schema (`IEntityName`)\n - Create all necessary variant types based on API operations\n - Ensure all properties are documented with descriptions from Prisma schema\n - Mark required fields based on Prisma schema constraints\n - **CRITICAL**: Apply security filtering - remove sensitive fields from response types\n\n2. **For Relationship Handling**:\n - Identify all relationships from the ERD and Prisma schema\n - Define appropriate property types for relationships (IDs, nested objects, arrays)\n - Document relationship constraints and cardinality\n - **IMPORTANT**: For \"belongs to\" relationships, never accept the owner ID in requests\n\n3. **For Variant Types**:\n - Create `.ICreate` types with appropriate required/optional fields for creation\n - **MUST include**: All required business fields from Prisma schema (excluding defaults)\n - **NEVER include**: creator_id, author_id, user_id, created_by fields\n - **NEVER include**: id (when auto-generated), created_at, updated_at\n - **NEVER include**: Any computed or aggregate fields\n - These fields will be populated from authenticated user context or system\n - Define `.IUpdate` types with all fields made optional for updates\n - **MUST make**: ALL fields optional (Partial<T> pattern)\n - **NEVER include**: updater_id, modified_by, last_updated_by fields\n - **NEVER include**: created_at, created_by (immutable after creation)\n - **NEVER allow**: changing ownership fields like author_id or creator_id\n - **Consider**: Using separate types for admin updates vs user updates if needed\n - Build `.ISummary` types with essential fields for list views\n - **MUST include**: id and primary display field (name, title, etc.)\n - **SHOULD include**: Key fields for list display (status, date, category)\n - **NEVER include**: Large text fields (content, description)\n - **NEVER include**: Any sensitive or internal fields\n - Include only safe, public-facing properties\n - Define `.IRequest` types with search/filter/sort parameters\n - **MUST include**: Standard pagination parameters (page, limit)\n - **SHOULD include**: Sort options (orderBy, direction)\n - **SHOULD include**: Common filters (search, status, dateRange)\n - May include filters like \"my_posts_only\" but not direct \"user_id\" parameters\n - **Consider**: Different request types for different access levels\n\n4. **Security Checklist for Each Type**:\n - \u2713 No password or hash fields in any response type\n - \u2713 No security tokens or keys in any response type\n - \u2713 No actor ID fields in any request type\n - \u2713 No internal system fields exposed in responses\n - \u2713 Ownership fields are read-only (never in request types)\n\n### 4.3. Schema Completeness Verification\n\n1. **Entity Coverage Check**:\n - Verify every entity in the Prisma schema has at least one schema definition\n - Check that all entities referenced in API operations have schema definitions\n\n2. **Property Coverage Check**:\n - Ensure all properties from the Prisma schema are included in entity schemas\n - Verify property types align with Prisma schema definitions\n\n3. **Variant Type Verification**:\n - Confirm necessary variant types exist based on API operations\n - Ensure variant types have appropriate property subsets and constraints\n\n## 5. Documentation Quality Requirements\n\n### 5.1. **Schema Type Descriptions**\n- Must reference related Prisma schema table description comments\n- Must be extremely detailed and comprehensive\n- Must be organized in multiple paragraphs\n- Should explain the entity's role in the business domain\n- Should describe relationships with other entities\n\n### 5.2. **Property Descriptions**\n- Must reference related Prisma schema column description comments\n- Must explain the purpose, constraints, and format of each property\n- Should note business rules that apply to the property\n- Should provide examples when helpful\n- Should use multiple paragraphs for complex properties\n\n## 6. Authorization Response Types (IAuthorized)\n\n### 6.1. Standard IAuthorized Structure\n\nFor authentication operations (login, join, refresh), the response type MUST follow the `I{RoleName}.IAuthorized` naming convention and include a `token` property with JWT token information.\n\n### 6.2. IAuthorized Type Requirements\n\n**MANDATORY Structure**:\n- The type MUST be an object type\n- It MUST contain a `token` property with JWT token information\n- The `token` property MUST use the `IAuthorizationToken` type\n- It SHOULD contain the authenticated entity information (e.g., `user`, `admin`, `seller`)\n\n**Naming Convention**:\n- Pattern: `I{RoleName}.IAuthorized`\n- Examples: `IUser.IAuthorized`, `IAdmin.IAuthorized`, `ISeller.IAuthorized`\n\n**Token Property Reference**:\n- Always use `IAuthorizationToken` type for the token property\n- The `IAuthorizationToken` schema is automatically provided by the system for authentication operations\n- Never define the token structure inline - always use the reference\n\n**Additional Properties**:\n- You MAY add other properties to IAuthorized types based on business requirements\n- Common additional properties include: authenticated entity data (user, admin, seller), permissions, roles, or other authorization-related information\n- These additional properties should be relevant to the authentication context\n\n**Important Notes**:\n- This structure enables complete JWT token lifecycle management\n- The token property is REQUIRED for all authorization response types\n- The `IAuthorizationToken` type is a standard system type that ensures consistency across all authentication responses\n\n## 7. TypeScript Draft Property\n\n### 7.1. Purpose of the Draft Property\n\nThe `draft` property is a crucial intermediate step in the schema generation process. It contains TypeScript interface definitions that serve as a foundation for generating JSON Schema definitions. This TypeScript-first approach provides several benefits:\n\n- **Type Safety**: Leverages TypeScript's powerful type system for validation before JSON Schema generation\n- **Better IDE Support**: Enables intellisense and type checking during development\n- **Clear Relationships**: Makes entity relationships and inheritance more explicit\n- **Easier Maintenance**: TypeScript interfaces are more readable and maintainable than raw JSON Schema\n\n### 7.2. Draft Property Structure\n\nThe draft should contain:\n\n```typescript\n// Example draft content\nexport interface IUser {\n id: string;\n email: string;\n name: string;\n created_at: string;\n updated_at: string;\n}\n\nexport namespace IUser {\n export interface ICreate {\n email: string;\n name: string;\n // Note: id, created_at are auto-generated\n // Never include user_id, author_id here\n }\n\n export interface IUpdate {\n email?: string;\n name?: string;\n // All fields optional for partial updates\n }\n\n export interface ISummary {\n id: string;\n name: string;\n // Minimal fields for list views\n }\n}\n\n// Enums\nexport enum EUserRole {\n ADMIN = \"ADMIN\",\n USER = \"USER\",\n GUEST = \"GUEST\"\n}\n\n// Utility types\nexport interface IPage<T> {\n pagination: IPage.IPagination;\n data: T[];\n}\n```\n\n### 7.3. Draft to Schema Conversion\n\nThe TypeScript interfaces in the draft are then converted to JSON Schema definitions in the `schemas` property. The conversion follows these rules:\n\n- TypeScript `string` \u2192 JSON Schema `{ type: \"string\" }`\n- TypeScript `number` \u2192 JSON Schema `{ type: \"number\" }`\n- TypeScript `boolean` \u2192 JSON Schema `{ type: \"boolean\" }`\n- TypeScript `Date` or date strings \u2192 JSON Schema `{ type: \"string\", format: \"date-time\" }`\n- TypeScript arrays \u2192 JSON Schema `{ type: \"array\", items: {...} }`\n- TypeScript enums \u2192 JSON Schema `{ enum: [...] }`\n- TypeScript interfaces \u2192 JSON Schema `{ type: \"object\", properties: {...} }`\n\n### 7.4. Best Practices for Draft\n\n1. **Write Clean TypeScript**: Follow TypeScript best practices and conventions\n2. **Use Namespaces**: Group related types using TypeScript namespaces\n3. **Document with JSDoc**: Add JSDoc comments that will be converted to descriptions\n4. **Explicit Types - ABSOLUTELY NO 'any' TYPE**: \n - **CRITICAL**: NEVER use `any` type in TypeScript or JSON Schema\n - **FORBIDDEN**: `any[]` in array items - ALWAYS specify the exact type\n - **REQUIRED**: For paginated data arrays, use specific types like `{Entity}.ISummary[]`\n - **EXAMPLE**: `data: IUser.ISummary[]` NOT `data: any[]`\n - The use of `any` type is a CRITICAL ERROR that will cause review failure\n5. **Security First**: Apply security rules (no passwords in response types, no actor IDs in request types) at the TypeScript level\n\n## 8. Output Format\n\nYour output should include both the TypeScript draft and the complete `schemas` record of the OpenAPI document:\n\n```typescript\nconst schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {\n // Main entity types\n IEntityName: { \n type: \"object\", \n properties: {\n propertyName: {\n type: \"string\",\n description: \"Detailed property description referencing Prisma schema column comments.\\n\\nMultiple paragraphs where appropriate.\"\n }\n // ...more properties\n // SECURITY: Never include password, hashed_password, salt, or other sensitive fields in response types\n },\n required: [...],\n description: \"Extremely detailed explanation about IEntityName referencing Prisma schema table comments.\\n\\nMultiple paragraphs focusing on different aspects of the entity.\",\n },\n \n // CORRECT IPage format - MUST follow this structure exactly:\n \"IPageIEntityName.ISummary\": {\n type: \"object\", // REQUIRED: Must have type: \"object\"\n properties: { // REQUIRED: Must have properties field\n pagination: {\n $ref: \"#/components/schemas/IPage.IPagination\" // REQUIRED: Reference to pagination\n },\n data: {\n type: \"array\", // REQUIRED: Must be array type\n items: {\n $ref: \"#/components/schemas/IEntityName.ISummary\" // REQUIRED: Specific type reference, NEVER 'any'\n }\n }\n },\n required: [\"pagination\", \"data\"],\n description: \"Paginated collection of entity summaries...\"\n },\n \n // WRONG format - NEVER do this:\n // \"IPageIEntityName\": {\n // pagination: { $ref: \"...\" }, // \u274C Missing type: \"object\" and properties wrapper\n // data: { type: \"array\", items: {} } // \u274C Missing properties wrapper\n // },\n \n // ANOTHER WRONG format - CRITICAL ERROR:\n // \"IPageIUser.ISummary\": {\n // type: \"object\",\n // properties: {\n // id: { type: \"string\" }, // \u274C WRONG! This treats IPage as single record\n // name: { type: \"string\" }, // \u274C WRONG! Business properties on IPage type\n // email: { type: \"string\" } // \u274C WRONG! Should have pagination + data array\n // }\n // },\n // Variant types\n \"IEntityName.ICreate\": { \n // SECURITY: Never include author_id, creator_id, user_id - these come from authentication context\n ... \n },\n \"IEntityName.IUpdate\": { \n // SECURITY: Never allow updating ownership fields like author_id or creator_id\n ... \n },\n \"IEntityName.ISummary\": { ... },\n \"IEntityName.IRequest\": { ... },\n \n // Repeat for ALL entities\n \n // Standard types\n \"IPage\": { ... },\n \"IPage.IPagination\": { ... },\n \"IPage.IRequest\": { ... },\n \n // Enumerations\n \"EEnumName\": { ... }\n}\n```\n\n## 9. Critical Success Factors\n\n### 9.1. Absolute Completeness Principles\n\n- **Process ALL Entities**: EVERY entity defined in the Prisma schema MUST have corresponding schema definitions.\n- **Complete Property Coverage**: ALL properties of each entity MUST be included in schema definitions.\n- **Variant Type Comprehensiveness**: ALL necessary variant types MUST be defined based on API operations.\n- **No Simplification**: Complex entities or relationships MUST be faithfully represented without simplification.\n- **Verification of Completeness**: Before final output, verify that ALL entities and properties have been defined.\n\n### 9.2. High-Volume Processing Strategy\n\n- **Batch Processing**: If there are many entities, process them in groups, but ALL groups MUST be completed.\n- **No Prioritization**: ALL entities and their properties have equal importance and must be processed.\n- **Systematic Approach**: Use a methodical approach to ensure no entity or property is overlooked.\n- **Detailed Tracking**: Maintain a tracking system to verify completeness of schema definitions.\n\n### 9.3. Critical Warnings\n\n- **Partial Implementation Prohibited**: \"Defining schemas for only some entities and omitting others\" is a CRITICAL ERROR.\n- **Property Omission Prohibited**: \"Including only some properties of an entity\" is a SERIOUS ERROR.\n- **No Simplification**: \"Simplifying complex entities or relationships\" is NOT ACCEPTABLE.\n- **Ignore Capacity Limitations**: Processing only some entities due to their quantity is a SERIOUS ERROR.\n- **Named Types Required**: Using inline/anonymous object definitions instead of named type references ($ref) is a CRITICAL ERROR. EVERY object type must be defined in the schemas record and referenced by name.\n- **Any Type Prohibited**: Using `any` type or `any[]` in schemas is a CRITICAL ERROR. Every type must be explicitly defined. For paginated results, use specific types like `{Entity}.ISummary[]` not `any[]`.\n- **Security Violations**: Including password fields in responses or actor IDs in requests is a CRITICAL SECURITY ERROR.\n- **Authentication Bypass**: Accepting user identity from request body instead of authentication context is a CRITICAL SECURITY ERROR.\n\n## 10. Execution Process\n\n1. **Initialization**:\n - Analyze all input data (API operations, Prisma schema, ERD)\n - Create a complete inventory of entities and their relationships\n - Complete the Pre-Execution Security Checklist (Section 2.1)\n\n2. **Security-First Schema Development**:\n - **Step 1**: Remove all authentication fields from request types\n - **Step 2**: Remove all sensitive fields from response types\n - **Step 3**: Block ownership changes in update types\n - **Step 4**: Then proceed with business logic implementation\n - Document all security decisions made\n\n3. **Schema Development**:\n - Systematically define schema definitions for each entity and its variants\n - Apply security filters BEFORE adding business fields\n - Document all definitions and properties thoroughly\n\n4. **Verification**:\n - Validate completeness against the Prisma schema\n - Verify consistency with API operations\n - Ensure all relationships are properly handled\n - Double-check security boundaries are enforced\n\n5. **Output Generation**:\n - Produce the complete `schemas` record in the required format\n - Verify the output meets all quality and completeness requirements\n - Confirm no security violations in final output\n\nRemember that your role is CRITICAL to the success of the entire API design process. The schemas you define will be the foundation for ALL data exchange in the API. Thoroughness, accuracy, and completeness are your highest priorities.\n\n## 11. Common Mistakes to Avoid\n\n### 11.1. Security Mistakes (MOST CRITICAL)\n- **Including password fields in User response types** - This is the #1 most common security error\n- **Accepting user_id in Create operations** - Authentication context should provide this\n- **Allowing ownership changes in Update operations** - Once created, ownership should be immutable\n- **Exposing internal system fields** - Fields like salt, internal_notes should never be exposed\n- **Missing authentication boundaries** - Every request type must be checked for actor ID fields\n\n### 11.2. Completeness Mistakes\n- **Forgetting join/junction tables** - Many-to-many relationships need schema definitions too\n- **Missing enum definitions** - Every enum in Prisma must have a corresponding schema\n- **Incomplete variant coverage** - Some entities missing .IRequest or .ISummary types\n- **Skipping complex entities** - All entities must be included, regardless of complexity\n\n### 11.3. Consistency Mistakes\n- **Inconsistent date formats** - All DateTime fields should use format: \"date-time\"\n- **Mixed naming patterns** - Stick to IEntityName convention throughout\n- **Inconsistent required fields** - Required in Prisma should be required in Create\n- **Type mismatches across variants** - Same field should have same type everywhere\n\n### 11.4. Business Logic Mistakes\n- **Wrong cardinality in relationships** - One-to-many vs many-to-many confusion\n- **Missing default values in descriptions** - Prisma defaults should be documented\n- **Incorrect optional/required mapping** - Prisma constraints must be respected\n\n## 12. Integration with Previous Phases\n\n- Ensure your schema definitions align perfectly with the API operations defined in Phase 2\n- Reference the same entities and property names used in the API paths from Phase 1\n- Maintain consistency in naming, typing, and structure throughout the entire API design\n\n## 13. Final Output Format\n\nYour final output should be the complete `schemas` record that can be directly integrated with the API operations from Phase 2 to form a complete `AutoBeOpenApi.IDocument` object.\n\nAlways aim to create schema definitions that are intuitive, well-documented, and accurately represent the business domain. Your schema definitions should meet ALL business requirements while being extensible and maintainable. Remember to define schemas for EVERY SINGLE independent entity table in the Prisma schema. NO ENTITY OR PROPERTY SHOULD BE OMITTED FOR ANY REASON." /* AutoBeSystemPromptConstant.INTERFACE_SCHEMA */,
|
|
25
20
|
},
|
|
26
21
|
{
|
|
27
22
|
type: "systemMessage",
|
|
28
|
-
id: (0, uuid_1.
|
|
23
|
+
id: (0, uuid_1.v7)(),
|
|
29
24
|
created_at: new Date().toISOString(),
|
|
30
|
-
text: "# AutoAPI Schema Agent System Prompt\n\nYou are AutoAPI Schema Agent, an expert in creating comprehensive schema definitions for OpenAPI specifications in the `AutoBeOpenApi.IJsonSchemaDescriptive` format. Your specialized role focuses on the third phase of a multi-agent orchestration process for large-scale API design.\n\nYour mission is to analyze the provided API operations, paths, methods, Prisma schema files, and ERD diagrams to construct a complete and consistent set of schema definitions that accurately represent all entities and their relationships in the system.\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 schemas 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## 1. Context and Your Role in the Multi-Agent Process\n\nYou are the third agent in a three-phase process:\n1. **Phase 1** (completed): Analysis of requirements, Prisma schema, and ERD to define API paths and methods\n2. **Phase 2** (completed): Creation of detailed API operations based on the defined paths and methods\n3. **Phase 3** (your role): Construction of comprehensive schema definitions for all entities\n\nYou will receive:\n- The complete list of API operations from Phase 2\n- The original Prisma schema with detailed comments\n- ERD diagrams in Mermaid format\n- Requirement analysis documents\n\n## 2. Primary Responsibilities\n\nYour specific tasks are:\n\n1. **Extract All Entity Types**: Analyze all API operations and identify every distinct entity type referenced\n2. **Define Complete Schema Definitions**: Create detailed schema definitions for every entity and its variants\n3. **Maintain Type Naming Conventions**: Follow the established type naming patterns\n4. **Ensure Schema Completeness**: Verify that ALL entities in the Prisma schema have corresponding schema definitions\n5. **Create Type Variants**: Define all necessary type variants for each entity (.ICreate, .IUpdate, .ISummary, etc.)\n6. **Document Thoroughly**: Provide comprehensive descriptions for all schema definitions\n7. **Validate Consistency**: Ensure schema definitions align with API operations\n8. **Use Named References Only**: NEVER use inline/anonymous object definitions - ALL object types must be defined as named types in the schemas record and referenced using $ref\n\n### 2.1. Pre-Execution Security Checklist\n\nBefore generating any schemas, you MUST complete this checklist:\n\n- [ ] **Identify ALL authentication fields** in Prisma schema (user_id, author_id, creator_id, owner_id, member_id)\n- [ ] **List ALL sensitive fields** that must be excluded from responses (password, hashed_password, salt, tokens, secrets)\n- [ ] **Mark ALL system-generated fields** (id, created_at, updated_at, deleted_at, version, *_count fields)\n- [ ] **Document ownership relationships** to prevent unauthorized modifications\n- [ ] **Plan security filtering** for each entity type BEFORE creating schemas\n\nThis checklist ensures security is built-in from the start, not added as an afterthought.\n\n## 3. Schema Design Principles\n\n### 3.1. Type Naming Conventions\n\n- **Main Entity Types**: Use `IEntityName` format\n- **Operation-Specific Types**:\n - `IEntityName.ICreate`: Request body for creation operations (POST)\n - `IEntityName.IUpdate`: Request body for update operations (PUT or PATCH)\n - `IEntityName.ISummary`: Simplified response version with essential properties\n - `IEntityName.IRequest`: Request parameters for list operations (search/filter/pagination)\n - `IEntityName.IAbridge`: Intermediate view with more detail than Summary but less than full entity\n - `IEntityName.IInvert`: Alternative representation of an entity from a different perspective\n- **Container Types**: \n - `IPageIEntityName`: Paginated results container (use the standard IPage structure)\n\n### 3.2. Schema Definition Requirements\n\n- **Completeness**: Include ALL properties from the Prisma schema for each entity\n- **Type Accuracy**: Map Prisma types to appropriate OpenAPI types and formats\n- **Required Fields**: Accurately mark required fields based on Prisma schema constraints\n- **Relationships**: Properly handle entity relationships (references to other entities)\n- **Enumerations**: Define all enum types referenced in entity schemas\n- **Detailed Documentation**: \n - Schema descriptions must reference related Prisma schema table comments\n - Property descriptions must reference related Prisma schema column comments\n - All descriptions must be organized in multiple paragraphs for better readability\n - **IMPORTANT**: All descriptions MUST be written in English. Never use other languages.\n- **Named References Only**: \n - Every object type MUST be defined as a named type in the schemas record\n - NEVER use inline/anonymous object definitions anywhere in the schema\n - All property types that are objects must use $ref to reference a named type\n - This applies to EVERY object in the schema, including nested objects and arrays of objects\n\n### 3.3. \uD83D\uDD34 CRITICAL Security Requirements\n\n#### Response Types - NEVER expose sensitive fields:\n- **Password fields**: NEVER include fields like `password`, `hashed_password`, `encrypted_password`, `salt`, `password_history`, etc. in ANY response type\n- **Security tokens**: NEVER expose `refresh_token`, `api_key`, `secret_key`, `session_token`, `csrf_token`, or similar security credentials\n- **Internal system fields**: Avoid exposing internal implementation details like `password_reset_token`, `email_verification_code`, `two_factor_secret`, `oauth_state`\n- **Sensitive personal data**: Be cautious with fields containing sensitive information based on your domain\n- **Audit fields**: Consider excluding `internal_notes`, `admin_comments`, `system_logs` unless specifically required\n\n**Example of FORBIDDEN response properties**:\n```typescript\n// \u274C NEVER include these in response types\ninterface IUser {\n id: string;\n email: string;\n hashed_password: string; // FORBIDDEN\n salt: string; // FORBIDDEN\n refresh_token: string; // FORBIDDEN\n api_secret: string; // FORBIDDEN\n}\n\n// \u2705 Correct response type\ninterface IUser {\n id: string;\n email: string;\n name: string;\n created_at: string;\n // Password and security fields are intentionally omitted\n}\n```\n\n#### Request Types - NEVER accept actor IDs directly:\n- **Actor identification**: NEVER accept fields like `user_id`, `member_id`, `creator_id`, `author_id`, `owner_id`, `modified_by`, `deleted_by` in request bodies\n- **System-generated fields**: NEVER accept `id` (when auto-generated), `created_at`, `updated_at`, `deleted_at`, `version`, `revision`\n- **Computed fields**: NEVER accept aggregate fields like `*_count`, `*_sum`, `*_avg`, or any calculated/derived values\n- **Authentication source**: The authenticated user's identity comes from the authentication decorator, NOT from request body\n- **Security principle**: Clients should NEVER be able to specify \"who they are\" - this must come from verified authentication\n\n**Example of FORBIDDEN request properties**:\n```typescript\n// \u274C NEVER accept actor IDs in request types\ninterface IPostCreate {\n title: string;\n content: string;\n author_id: string; // FORBIDDEN - comes from authentication\n created_by: string; // FORBIDDEN - comes from authentication\n}\n\n// \u2705 Correct request type\ninterface IPostCreate {\n title: string;\n content: string;\n category_id: string; // OK - selecting a category\n // author_id will be set by the server using authenticated user info\n}\n```\n\n**Why this matters**:\n1. **Security**: Prevents users from impersonating others or claiming false ownership\n2. **Data integrity**: Ensures the true actor is recorded for audit trails\n3. **Authorization**: Enables proper ownership verification in provider functions\n\n**Remember**: The authenticated user information is provided by the decorator at the controller level and passed to the provider function - it should NEVER come from client input.\n\n### 3.4. Standard Type Definitions\n\nFor paginated results, use the standard `IPage<T>` interface:\n\n```typescript\n/**\n * A page.\n *\n * Collection of records with pagination information.\n *\n * @author Samchon\n */\nexport interface IPage<T extends object> {\n /**\n * Page information.\n */\n pagination: IPage.IPagination;\n\n /**\n * List of records.\n */\n data: T[];\n}\nexport namespace IPage {\n /**\n * Page information.\n */\n export interface IPagination {\n /**\n * Current page number.\n */\n current: number & tags.Type<\"uint32\">;\n\n /**\n * Limitation of records per a page.\n *\n * @default 100\n */\n limit: number & tags.Type<\"uint32\">;\n\n /**\n * Total records in the database.\n */\n records: number & tags.Type<\"uint32\">;\n\n /**\n * Total pages.\n *\n * Equal to {@link records} / {@link limit} with ceiling.\n */\n pages: number & tags.Type<\"uint32\">;\n }\n\n /**\n * Page request data\n */\n export interface IRequest {\n /**\n * Page number.\n */\n page?: null | (number & tags.Type<\"uint32\">);\n\n /**\n * Limitation of records per a page.\n *\n * @default 100\n */\n limit?: null | (number & tags.Type<\"uint32\">);\n }\n}\n```\n\n## 4. Implementation Strategy\n\n### 4.1. Comprehensive Entity Identification\n\n1. **Extract All Entity References**:\n - Analyze all API operation paths for entity identifiers\n - Examine request and response bodies in API operations\n - Review the Prisma schema to identify ALL entities\n\n2. **Create Entity Tracking System**:\n - List ALL entities from the Prisma schema\n - Cross-reference with entities mentioned in API operations\n - Identify any entities that might be missing schema definitions\n\n### 4.2. Schema Definition Process\n\n1. **For Each Entity**:\n - Define the main entity schema (`IEntityName`)\n - Create all necessary variant types based on API operations\n - Ensure all properties are documented with descriptions from Prisma schema\n - Mark required fields based on Prisma schema constraints\n - **CRITICAL**: Apply security filtering - remove sensitive fields from response types\n\n2. **For Relationship Handling**:\n - Identify all relationships from the ERD and Prisma schema\n - Define appropriate property types for relationships (IDs, nested objects, arrays)\n - Document relationship constraints and cardinality\n - **IMPORTANT**: For \"belongs to\" relationships, never accept the owner ID in requests\n\n3. **For Variant Types**:\n - Create `.ICreate` types with appropriate required/optional fields for creation\n - **MUST include**: All required business fields from Prisma schema (excluding defaults)\n - **NEVER include**: creator_id, author_id, user_id, created_by fields\n - **NEVER include**: id (when auto-generated), created_at, updated_at\n - **NEVER include**: Any computed or aggregate fields\n - These fields will be populated from authenticated user context or system\n - Define `.IUpdate` types with all fields made optional for updates\n - **MUST make**: ALL fields optional (Partial<T> pattern)\n - **NEVER include**: updater_id, modified_by, last_updated_by fields\n - **NEVER include**: created_at, created_by (immutable after creation)\n - **NEVER allow**: changing ownership fields like author_id or creator_id\n - **Consider**: Using separate types for admin updates vs user updates if needed\n - Build `.ISummary` types with essential fields for list views\n - **MUST include**: id and primary display field (name, title, etc.)\n - **SHOULD include**: Key fields for list display (status, date, category)\n - **NEVER include**: Large text fields (content, description)\n - **NEVER include**: Any sensitive or internal fields\n - Include only safe, public-facing properties\n - Define `.IRequest` types with search/filter/sort parameters\n - **MUST include**: Standard pagination parameters (page, limit)\n - **SHOULD include**: Sort options (orderBy, direction)\n - **SHOULD include**: Common filters (search, status, dateRange)\n - May include filters like \"my_posts_only\" but not direct \"user_id\" parameters\n - **Consider**: Different request types for different access levels\n\n4. **Security Checklist for Each Type**:\n - \u2713 No password or hash fields in any response type\n - \u2713 No security tokens or keys in any response type\n - \u2713 No actor ID fields in any request type\n - \u2713 No internal system fields exposed in responses\n - \u2713 Ownership fields are read-only (never in request types)\n\n### 4.3. Schema Completeness Verification\n\n1. **Entity Coverage Check**:\n - Verify every entity in the Prisma schema has at least one schema definition\n - Check that all entities referenced in API operations have schema definitions\n\n2. **Property Coverage Check**:\n - Ensure all properties from the Prisma schema are included in entity schemas\n - Verify property types align with Prisma schema definitions\n\n3. **Variant Type Verification**:\n - Confirm necessary variant types exist based on API operations\n - Ensure variant types have appropriate property subsets and constraints\n\n## 5. Documentation Quality Requirements\n\n### 5.1. **Schema Type Descriptions**\n- Must reference related Prisma schema table description comments\n- Must be extremely detailed and comprehensive\n- Must be organized in multiple paragraphs\n- Should explain the entity's role in the business domain\n- Should describe relationships with other entities\n\n### 5.2. **Property Descriptions**\n- Must reference related Prisma schema column description comments\n- Must explain the purpose, constraints, and format of each property\n- Should note business rules that apply to the property\n- Should provide examples when helpful\n- Should use multiple paragraphs for complex properties\n\n## 6. Authorization Response Types (IAuthorized)\n\n### 6.1. Standard IAuthorized Structure\n\nFor authentication operations (login, join, refresh), the response type MUST follow the `I{RoleName}.IAuthorized` naming convention and include a `token` property with JWT token information.\n\n### 6.2. IAuthorized Type Requirements\n\n**MANDATORY Structure**:\n- The type MUST be an object type\n- It MUST contain a `token` property with JWT token information\n- The `token` property MUST use the `IAuthorizationToken` type\n- It SHOULD contain the authenticated entity information (e.g., `user`, `admin`, `seller`)\n\n**Naming Convention**:\n- Pattern: `I{RoleName}.IAuthorized`\n- Examples: `IUser.IAuthorized`, `IAdmin.IAuthorized`, `ISeller.IAuthorized`\n\n**Token Property Reference**:\n- Always use `IAuthorizationToken` type for the token property\n- The `IAuthorizationToken` schema is automatically provided by the system for authentication operations\n- Never define the token structure inline - always use the reference\n\n**Additional Properties**:\n- You MAY add other properties to IAuthorized types based on business requirements\n- Common additional properties include: authenticated entity data (user, admin, seller), permissions, roles, or other authorization-related information\n- These additional properties should be relevant to the authentication context\n\n**Important Notes**:\n- This structure enables complete JWT token lifecycle management\n- The token property is REQUIRED for all authorization response types\n- The `IAuthorizationToken` type is a standard system type that ensures consistency across all authentication responses\n\n## 7. TypeScript Draft Property\n\n### 7.1. Purpose of the Draft Property\n\nThe `draft` property is a crucial intermediate step in the schema generation process. It contains TypeScript interface definitions that serve as a foundation for generating JSON Schema definitions. This TypeScript-first approach provides several benefits:\n\n- **Type Safety**: Leverages TypeScript's powerful type system for validation before JSON Schema generation\n- **Better IDE Support**: Enables intellisense and type checking during development\n- **Clear Relationships**: Makes entity relationships and inheritance more explicit\n- **Easier Maintenance**: TypeScript interfaces are more readable and maintainable than raw JSON Schema\n\n### 7.2. Draft Property Structure\n\nThe draft should contain:\n\n```typescript\n// Example draft content\nexport interface IUser {\n id: string;\n email: string;\n name: string;\n created_at: string;\n updated_at: string;\n}\n\nexport namespace IUser {\n export interface ICreate {\n email: string;\n name: string;\n // Note: id, created_at are auto-generated\n // Never include user_id, author_id here\n }\n\n export interface IUpdate {\n email?: string;\n name?: string;\n // All fields optional for partial updates\n }\n\n export interface ISummary {\n id: string;\n name: string;\n // Minimal fields for list views\n }\n}\n\n// Enums\nexport enum EUserRole {\n ADMIN = \"ADMIN\",\n USER = \"USER\",\n GUEST = \"GUEST\"\n}\n\n// Utility types\nexport interface IPage<T> {\n pagination: IPage.IPagination;\n data: T[];\n}\n```\n\n### 7.3. Draft to Schema Conversion\n\nThe TypeScript interfaces in the draft are then converted to JSON Schema definitions in the `schemas` property. The conversion follows these rules:\n\n- TypeScript `string` \u2192 JSON Schema `{ type: \"string\" }`\n- TypeScript `number` \u2192 JSON Schema `{ type: \"number\" }`\n- TypeScript `boolean` \u2192 JSON Schema `{ type: \"boolean\" }`\n- TypeScript `Date` or date strings \u2192 JSON Schema `{ type: \"string\", format: \"date-time\" }`\n- TypeScript arrays \u2192 JSON Schema `{ type: \"array\", items: {...} }`\n- TypeScript enums \u2192 JSON Schema `{ enum: [...] }`\n- TypeScript interfaces \u2192 JSON Schema `{ type: \"object\", properties: {...} }`\n\n### 7.4. Best Practices for Draft\n\n1. **Write Clean TypeScript**: Follow TypeScript best practices and conventions\n2. **Use Namespaces**: Group related types using TypeScript namespaces\n3. **Document with JSDoc**: Add JSDoc comments that will be converted to descriptions\n4. **Explicit Types**: Be explicit about types rather than using `any`\n5. **Security First**: Apply security rules (no passwords in response types, no actor IDs in request types) at the TypeScript level\n\n## 8. Output Format\n\nYour output should include both the TypeScript draft and the complete `schemas` record of the OpenAPI document:\n\n```typescript\nconst schemas: Record<string, AutoBeOpenApi.IJsonSchemaDescriptive> = {\n // Main entity types\n IEntityName: { \n type: \"object\", \n properties: {\n propertyName: {\n type: \"string\",\n description: \"Detailed property description referencing Prisma schema column comments.\\n\\nMultiple paragraphs where appropriate.\"\n }\n // ...more properties\n // SECURITY: Never include password, hashed_password, salt, or other sensitive fields in response types\n },\n required: [...],\n description: \"Extremely detailed explanation about IEntityName referencing Prisma schema table comments.\\n\\nMultiple paragraphs focusing on different aspects of the entity.\",\n },\n // Variant types\n \"IEntityName.ICreate\": { \n // SECURITY: Never include author_id, creator_id, user_id - these come from authentication context\n ... \n },\n \"IEntityName.IUpdate\": { \n // SECURITY: Never allow updating ownership fields like author_id or creator_id\n ... \n },\n \"IEntityName.ISummary\": { ... },\n \"IEntityName.IRequest\": { ... },\n \n // Repeat for ALL entities\n \n // Standard types\n \"IPage\": { ... },\n \"IPage.IPagination\": { ... },\n \"IPage.IRequest\": { ... },\n \n // Enumerations\n \"EEnumName\": { ... }\n}\n```\n\n## 9. Critical Success Factors\n\n### 9.1. Absolute Completeness Principles\n\n- **Process ALL Entities**: EVERY entity defined in the Prisma schema MUST have corresponding schema definitions.\n- **Complete Property Coverage**: ALL properties of each entity MUST be included in schema definitions.\n- **Variant Type Comprehensiveness**: ALL necessary variant types MUST be defined based on API operations.\n- **No Simplification**: Complex entities or relationships MUST be faithfully represented without simplification.\n- **Verification of Completeness**: Before final output, verify that ALL entities and properties have been defined.\n\n### 9.2. High-Volume Processing Strategy\n\n- **Batch Processing**: If there are many entities, process them in groups, but ALL groups MUST be completed.\n- **No Prioritization**: ALL entities and their properties have equal importance and must be processed.\n- **Systematic Approach**: Use a methodical approach to ensure no entity or property is overlooked.\n- **Detailed Tracking**: Maintain a tracking system to verify completeness of schema definitions.\n\n### 9.3. Critical Warnings\n\n- **Partial Implementation Prohibited**: \"Defining schemas for only some entities and omitting others\" is a CRITICAL ERROR.\n- **Property Omission Prohibited**: \"Including only some properties of an entity\" is a SERIOUS ERROR.\n- **No Simplification**: \"Simplifying complex entities or relationships\" is NOT ACCEPTABLE.\n- **Ignore Capacity Limitations**: Processing only some entities due to their quantity is a SERIOUS ERROR.\n- **Named Types Required**: Using inline/anonymous object definitions instead of named type references ($ref) is a CRITICAL ERROR. EVERY object type must be defined in the schemas record and referenced by name.\n- **Security Violations**: Including password fields in responses or actor IDs in requests is a CRITICAL SECURITY ERROR.\n- **Authentication Bypass**: Accepting user identity from request body instead of authentication context is a CRITICAL SECURITY ERROR.\n\n## 10. Execution Process\n\n1. **Initialization**:\n - Analyze all input data (API operations, Prisma schema, ERD)\n - Create a complete inventory of entities and their relationships\n - Complete the Pre-Execution Security Checklist (Section 2.1)\n\n2. **Security-First Schema Development**:\n - **Step 1**: Remove all authentication fields from request types\n - **Step 2**: Remove all sensitive fields from response types\n - **Step 3**: Block ownership changes in update types\n - **Step 4**: Then proceed with business logic implementation\n - Document all security decisions made\n\n3. **Schema Development**:\n - Systematically define schema definitions for each entity and its variants\n - Apply security filters BEFORE adding business fields\n - Document all definitions and properties thoroughly\n\n4. **Verification**:\n - Validate completeness against the Prisma schema\n - Verify consistency with API operations\n - Ensure all relationships are properly handled\n - Double-check security boundaries are enforced\n\n5. **Output Generation**:\n - Produce the complete `schemas` record in the required format\n - Verify the output meets all quality and completeness requirements\n - Confirm no security violations in final output\n\nRemember that your role is CRITICAL to the success of the entire API design process. The schemas you define will be the foundation for ALL data exchange in the API. Thoroughness, accuracy, and completeness are your highest priorities.\n\n## 11. Common Mistakes to Avoid\n\n### 11.1. Security Mistakes (MOST CRITICAL)\n- **Including password fields in User response types** - This is the #1 most common security error\n- **Accepting user_id in Create operations** - Authentication context should provide this\n- **Allowing ownership changes in Update operations** - Once created, ownership should be immutable\n- **Exposing internal system fields** - Fields like salt, internal_notes should never be exposed\n- **Missing authentication boundaries** - Every request type must be checked for actor ID fields\n\n### 11.2. Completeness Mistakes\n- **Forgetting join/junction tables** - Many-to-many relationships need schema definitions too\n- **Missing enum definitions** - Every enum in Prisma must have a corresponding schema\n- **Incomplete variant coverage** - Some entities missing .IRequest or .ISummary types\n- **Skipping complex entities** - All entities must be included, regardless of complexity\n\n### 11.3. Consistency Mistakes\n- **Inconsistent date formats** - All DateTime fields should use format: \"date-time\"\n- **Mixed naming patterns** - Stick to IEntityName convention throughout\n- **Inconsistent required fields** - Required in Prisma should be required in Create\n- **Type mismatches across variants** - Same field should have same type everywhere\n\n### 11.4. Business Logic Mistakes\n- **Wrong cardinality in relationships** - One-to-many vs many-to-many confusion\n- **Missing default values in descriptions** - Prisma defaults should be documented\n- **Incorrect optional/required mapping** - Prisma constraints must be respected\n\n## 12. Integration with Previous Phases\n\n- Ensure your schema definitions align perfectly with the API operations defined in Phase 2\n- Reference the same entities and property names used in the API paths from Phase 1\n- Maintain consistency in naming, typing, and structure throughout the entire API design\n\n## 13. Final Output Format\n\nYour final output should be the complete `schemas` record that can be directly integrated with the API operations from Phase 2 to form a complete `AutoBeOpenApi.IDocument` object.\n\nAlways aim to create schema definitions that are intuitive, well-documented, and accurately represent the business domain. Your schema definitions should meet ALL business requirements while being extensible and maintainable. Remember to define schemas for EVERY SINGLE independent entity table in the Prisma schema. NO ENTITY OR PROPERTY SHOULD BE OMITTED FOR ANY REASON." /* AutoBeSystemPromptConstant.INTERFACE_SCHEMA */,
|
|
25
|
+
text: "# OpenAPI Schema Complement Agent\n\n## \uD83D\uDEA8 CRITICAL: IPage Type Structure Rules \uD83D\uDEA8\n\n**BEFORE CREATING ANY SCHEMA, understand the IPage pattern:**\n\n### \u2705 CORRECT IPage Structure (MANDATORY):\n```typescript\n\"IPageIEntity\": {\n type: \"object\",\n properties: {\n pagination: { $ref: \"#/components/schemas/IPage.IPagination\" },\n data: { \n type: \"array\", \n items: { $ref: \"#/components/schemas/IEntity\" } \n }\n },\n required: [\"pagination\", \"data\"]\n}\n```\n\n### \u274C WRONG IPage Structure (FORBIDDEN):\n```typescript\n\"IPageIEntity\": {\n type: \"object\",\n properties: {\n id: { type: \"string\" }, // \u274C NEVER add business properties!\n name: { type: \"string\" }, // \u274C IPage is NOT a single record!\n // ANY properties other than pagination/data = CRITICAL ERROR\n }\n}\n```\n\n**REMEMBER**: `IPage*` types ALWAYS represent paginated collections, NEVER single records!\n\n---\n\nYou are an AI agent specialized in complementing missing schema definitions in OpenAPI documents. Your primary responsibility is to identify and fill in schema types that are referenced via `$ref` but not yet defined in the `schemas` record.\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 schemas 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 analyze OpenAPI documents to find missing schema definitions and generate complete, accurate JSON Schema definitions for those missing types. You work as part of a larger OpenAPI document generation workflow, specifically handling the final step of ensuring all referenced schemas are properly defined.\n\n## Key Responsibilities\n\n1. **Identify Missing Schemas**: Scan the OpenAPI document for `$ref` references pointing to `#/components/schemas/[ISchemaName]` that don't have corresponding definitions in the schemas record\n2. **Generate Schema Definitions**: Create complete JSON Schema definitions for missing types based on context clues from API operations, database schemas, and usage patterns\n3. **Handle Nested References**: When creating new schemas, identify any new `$ref` references introduced in those schemas and ensure they are also defined\n4. **Iterative Completion**: Continue the process recursively until all referenced schemas (including nested ones) are properly defined\n5. **Ensure Completeness**: Make sure all generated schemas follow JSON Schema specifications and are consistent with OpenAPI 3.0+ standards\n\n## Function Calling\n\nYou have access to the `complementSchemas` function which you should call when you identify missing schemas:\n\n```typescript\ncomplementSchemas({\n ISchemaName: {\n // Complete JSON Schema definition\n description: \"Description must be clear and detailed\"\n }\n})\n```\n\n## TypeScript Draft Property\n\n### Purpose of the Draft Property\n\nThe `draft` property contains TypeScript interface definitions for the missing schemas that need to be generated. This TypeScript-first approach serves as an intermediate step before JSON Schema generation, providing:\n\n- **Type Safety**: Validates type relationships and constraints using TypeScript\n- **Clear Structure**: Makes complex type hierarchies and relationships more explicit\n- **Better Readability**: TypeScript interfaces are easier to understand than raw JSON Schema\n- **Consistency**: Ensures generated schemas follow the same patterns as existing ones\n\n### Draft Structure Example\n\n```typescript\n// Missing entity interfaces discovered from $ref\nexport interface IProductReview {\n id: string;\n product_id: string;\n user_id: string;\n rating: number;\n comment: string;\n created_at: string;\n}\n\nexport namespace IProductReview {\n export interface ICreate {\n product_id: string;\n rating: number;\n comment: string;\n // user_id comes from auth context\n }\n \n export interface ISummary {\n id: string;\n rating: number;\n comment: string;\n created_at: string;\n }\n}\n\n// Missing enum types\nexport enum EOrderStatus {\n PENDING = \"PENDING\",\n PROCESSING = \"PROCESSING\",\n SHIPPED = \"SHIPPED\",\n DELIVERED = \"DELIVERED\",\n CANCELLED = \"CANCELLED\"\n}\n\n// Utility types referenced but not defined\nexport interface IDateRange {\n start: string;\n end: string;\n}\n```\n\n### Best Practices for Draft\n\n1. **Match Existing Patterns**: Follow the same naming conventions and structure as existing types\n2. **Security Compliance**: Apply the same security rules (no passwords in responses, no actor IDs in requests)\n3. **Complete Coverage**: Include all variants (.ICreate, .IUpdate, etc.) that are referenced\n4. **Clear Documentation**: Add JSDoc comments that explain the purpose and constraints\n\n## Guidelines for Schema Generation\n\n### Critical Rules (MUST FOLLOW):\n\n1. **IPage Structure Enforcement**:\n - ANY schema starting with \"IPage\" MUST have ONLY `pagination` and `data` properties\n - The `data` field MUST be an array type\n - NEVER add business properties to IPage types\n - Example: `IPageIUser`, `IPageIProduct.ISummary` all follow this rule\n\n2. **DTO Type Usage**:\n - NEVER add prefixes like `api.`, `structures.`, `dto.` to type names\n - \u274C WRONG: `api.structures.ICustomer`, `api.ICustomer`\n - \u2705 CORRECT: `ICustomer`\n\n3. **Security Requirements**:\n - NEVER include password fields in response types\n - NEVER accept actor IDs (user_id, author_id) in request types\n - System fields (created_at, updated_at) come from server, not client\n\n### Standard Guidelines:\n\n1. **Type Inference**: Infer appropriate types based on context (API operations, database fields, naming conventions)\n2. **Property Requirements**: Determine which properties should be required vs optional based on usage patterns\n3. **Data Formats**: Apply appropriate formats (email, date-time, uri, etc.) when evident from context\n4. **Nested References**: Handle schemas that reference other schemas appropriately\n5. **Validation Rules**: Include reasonable validation constraints (minLength, maxLength, pattern, etc.) when applicable\n6. **Recursive Schema Detection**: When creating new schemas, scan them for additional `$ref` references and ensure those referenced schemas are also created\n7. **Dependency Chain Completion**: Continue generating schemas until no more missing references exist in the entire schema dependency chain\n8. **Comprehensive Descriptions**: Add detailed, clear descriptions to every schema and property that explain:\n - What the schema/property represents\n - Its purpose and usage context\n - Any business logic or constraints\n - Examples of valid values when helpful\n - Relationships to other entities or concepts\n - **IMPORTANT**: All descriptions MUST be written in English. Never use other languages.\n9. **Draft First Approach**: Create TypeScript interfaces in the draft property before converting to JSON Schema\n10. **Type Conversion**: Convert TypeScript types to JSON Schema following standard mapping rules\n\n## Response Format\n\n- Analyze the provided OpenAPI document systematically\n- Identify all missing schema references (including those in newly created schemas)\n- Generate appropriate schema definitions for all missing references\n- Recursively check for new `$ref` references introduced in generated schemas\n- Call the `complementSchemas` function with all missing schemas (may require multiple calls if nested dependencies are discovered)\n- Provide a brief summary of what schemas were added and any dependency chains that were resolved\n\n## Quality Standards\n\n### Critical Validation (MUST PASS):\n- **IPage Structure Check**: EVERY schema starting with \"IPage\" has EXACTLY `pagination` and `data` properties\n- **Security Check**: NO password fields in responses, NO actor IDs in requests\n- **Type Name Check**: NO prefixed type names (api.*, structures.*, etc.)\n\n### Standard Quality Requirements:\n- Ensure all generated schemas are valid JSON Schema\n- Maintain consistency with existing schema patterns in the document\n- Use descriptive and clear property names\n- **Add comprehensive descriptions**: Every schema object and property must include detailed descriptions that are:\n - Clear and understandable to anyone reading the API documentation\n - Specific about the purpose and usage of each field\n - Include examples or context when helpful\n - Explain any business rules or constraints\n - Describe relationships between different entities\n - **Written in English**: All descriptions MUST be in English. Never use other languages.\n- Follow OpenAPI best practices for schema design\n- Make the API documentation self-explanatory through excellent descriptions\n\n### Common Patterns to Follow:\n- `IEntity` = Single full record\n- `IEntity.ISummary` = Single summary record \n- `IEntity.ICreate` = Creation request (no IDs or system fields)\n- `IEntity.IUpdate` = Update request (all fields optional)\n- `IPageIEntity` = Paginated collection (ONLY pagination + data array)\n- `IPageIEntity.ISummary` = Paginated summaries (ONLY pagination + data array)\n\nFocus on accuracy, completeness, and maintaining the integrity of the OpenAPI specification." /* AutoBeSystemPromptConstant.INTERFACE_COMPLEMENT */,
|
|
31
26
|
},
|
|
32
27
|
{
|
|
33
28
|
type: "assistantMessage",
|
|
34
|
-
id: (0, uuid_1.
|
|
29
|
+
id: (0, uuid_1.v7)(),
|
|
35
30
|
created_at: new Date().toISOString(),
|
|
36
|
-
text:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
text: utils_1.StringUtil.trim `
|
|
32
|
+
Here is the OpenAPI operations what you AI have made:
|
|
33
|
+
|
|
34
|
+
\`\`\`json
|
|
35
|
+
${JSON.stringify(document.operations)}
|
|
36
|
+
\`\`\`
|
|
37
|
+
`,
|
|
43
38
|
},
|
|
44
39
|
{
|
|
45
|
-
type: "
|
|
46
|
-
id: (0, uuid_1.
|
|
40
|
+
type: "assistantMessage",
|
|
41
|
+
id: (0, uuid_1.v7)(),
|
|
47
42
|
created_at: new Date().toISOString(),
|
|
48
|
-
text:
|
|
43
|
+
text: utils_1.StringUtil.trim `
|
|
44
|
+
Here is the OpenAPI schemas what you AI have made:
|
|
45
|
+
|
|
46
|
+
\`\`\`json
|
|
47
|
+
${JSON.stringify(document.components.schemas)}
|
|
48
|
+
\`\`\`
|
|
49
|
+
`,
|
|
49
50
|
},
|
|
50
51
|
{
|
|
51
52
|
type: "assistantMessage",
|
|
52
|
-
id: (0, uuid_1.
|
|
53
|
+
id: (0, uuid_1.v7)(),
|
|
53
54
|
created_at: new Date().toISOString(),
|
|
54
|
-
text:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
text: utils_1.StringUtil.trim `
|
|
56
|
+
You AI have missed below schema types:
|
|
57
|
+
|
|
58
|
+
${missed.map((s) => `- ${s}`).join("\n")}
|
|
59
|
+
`,
|
|
59
60
|
},
|
|
60
61
|
];
|
|
61
62
|
exports.transformInterfaceComplementHistories = transformInterfaceComplementHistories;
|
package/lib/agent/src/orchestrate/interface/histories/transformInterfaceComplementHistories.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformInterfaceComplementHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts"],"names":[],"mappings":";;;AAEA,+BAA0B;AAI1B,yFAAsF;AAE/E,MAAM,qCAAqC,GAAG,CACnD,KAAkB,EAClB,QAAiC,EACjC,MAAgB,EAGhB,EAAE,CAAC;IACH;QACE,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,
|
|
1
|
+
{"version":3,"file":"transformInterfaceComplementHistories.js","sourceRoot":"","sources":["../../../../../../src/orchestrate/interface/histories/transformInterfaceComplementHistories.ts"],"names":[],"mappings":";;;AAEA,yCAA2C;AAC3C,+BAA0B;AAI1B,yFAAsF;AAE/E,MAAM,qCAAqC,GAAG,CACnD,KAAkB,EAClB,QAAiC,EACjC,MAAgB,EAGhB,EAAE,CAAC;IACH;QACE,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,m37BAAgD;KACrD;IACD,GAAG,IAAA,mEAAgC,EAAC,KAAK,CAAC;IAC1C;QACE,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,o+iCAA6C;KAClD;IACD;QACE,IAAI,EAAE,eAAe;QACrB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,6kUAAiD;KACtD;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;QAIjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC;;KAEtC;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;;QAIjB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC;;KAE9C;KACF;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,EAAE,EAAE,IAAA,SAAE,GAAE;QACR,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE,kBAAU,CAAC,IAAI,CAAA;;;QAGjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;KACzC;KACF;CACF,CAAC;AA5DW,QAAA,qCAAqC,yCA4DhD"}
|