@@ -22,7 +22,7 @@ import {
2222 CreateCollectionDto ,
2323 UpdateCollectionDto ,
2424 UpdateMockCollectionStatusDto ,
25- AuthCollection
25+ AuthCollection ,
2626} from "../payloads/collection.payload" ;
2727import { FastifyReply } from "fastify" ;
2828import { CollectionService } from "../services/collection.service" ;
@@ -32,6 +32,7 @@ import { WorkspaceService } from "../services/workspace.service";
3232import {
3333 BranchChangeDto ,
3434 CollectionAiRequestDto ,
35+ CollectionGeneratedVariableDto ,
3536 CollectionGraphQLDto ,
3637 CollectionMockRequestResponseDto ,
3738 CollectionRequestDto ,
@@ -168,7 +169,6 @@ export class collectionController {
168169 return res . status ( responseData . httpStatusCode ) . send ( responseData ) ;
169170 }
170171
171-
172172 @Put ( ":collectionId/workspace/:workspaceId" )
173173 @ApiOperation ( {
174174 summary : "Update A Collections" ,
@@ -207,24 +207,27 @@ export class collectionController {
207207 return res . status ( responseData . httpStatusCode ) . send ( responseData ) ;
208208 }
209209
210- @Get ( ' auth-profiles/:collectionId' )
210+ @Get ( " auth-profiles/:collectionId" )
211211 @ApiOperation ( {
212- summary : ' Get all auth profiles for a collection' ,
213- description : ' Fetches all auth profiles stored in the given collection.' ,
212+ summary : " Get all auth profiles for a collection" ,
213+ description : " Fetches all auth profiles stored in the given collection." ,
214214 } )
215215 @UseGuards ( JwtAuthGuard )
216- @ApiResponse ( { status : 200 , description : ' List of auth profiles returned' } )
217- @ApiResponse ( { status : 404 , description : ' Collection not found' } )
216+ @ApiResponse ( { status : 200 , description : " List of auth profiles returned" } )
217+ @ApiResponse ( { status : 404 , description : " Collection not found" } )
218218 async getAuthProfiles (
219- @Param ( ' collectionId' ) collectionId : string ,
219+ @Param ( " collectionId" ) collectionId : string ,
220220 @Res ( ) res : FastifyReply ,
221221 @Req ( ) req : ExtendedFastifyRequest ,
222222 ) {
223223 const user = req . user ;
224- const authProfiles = await this . collectionService . getAuthProfiles ( collectionId , user ) ;
224+ const authProfiles = await this . collectionService . getAuthProfiles (
225+ collectionId ,
226+ user ,
227+ ) ;
225228
226229 const responseData = new ApiResponseService (
227- ' Success' ,
230+ " Success" ,
228231 HttpStatusCode . OK ,
229232 authProfiles ,
230233 ) ;
@@ -240,9 +243,16 @@ export class collectionController {
240243 @UseGuards ( JwtAuthGuard )
241244 @ApiResponse ( { status : 200 , description : "Auth profile Added Successfully" } )
242245 @ApiResponse ( { status : 400 , description : "Adding operation Failed" } )
243- async addAuthProfiles ( @Body ( ) updateCollectionDto : Partial < UpdateCollectionDto > , @Res ( ) res : FastifyReply , @Req ( ) request : ExtendedFastifyRequest ) {
246+ async addAuthProfiles (
247+ @Body ( ) updateCollectionDto : Partial < UpdateCollectionDto > ,
248+ @Res ( ) res : FastifyReply ,
249+ @Req ( ) request : ExtendedFastifyRequest ,
250+ ) {
244251 const user = request . user ;
245- const message = await this . collectionService . addAuthProfile ( updateCollectionDto , user ) ;
252+ const message = await this . collectionService . addAuthProfile (
253+ updateCollectionDto ,
254+ user ,
255+ ) ;
246256 const responseData = new ApiResponseService (
247257 "Success" ,
248258 HttpStatusCode . OK ,
@@ -258,11 +268,21 @@ export class collectionController {
258268 description : "This will update an auth profile " ,
259269 } )
260270 @UseGuards ( JwtAuthGuard )
261- @ApiResponse ( { status : 200 , description : "Auth profile Updated Successfully" } )
271+ @ApiResponse ( {
272+ status : 200 ,
273+ description : "Auth profile Updated Successfully" ,
274+ } )
262275 @ApiResponse ( { status : 400 , description : "Update operation Failed" } )
263- async updateAuthProfiles ( @Body ( ) payload : AuthCollection , @Res ( ) res : FastifyReply , @Req ( ) request : ExtendedFastifyRequest ) {
276+ async updateAuthProfiles (
277+ @Body ( ) payload : AuthCollection ,
278+ @Res ( ) res : FastifyReply ,
279+ @Req ( ) request : ExtendedFastifyRequest ,
280+ ) {
264281 const user = request . user ;
265- const message = await this . collectionService . updateAuthProfile ( payload , user ) ;
282+ const message = await this . collectionService . updateAuthProfile (
283+ payload ,
284+ user ,
285+ ) ;
266286 const responseData = new ApiResponseService (
267287 "Success" ,
268288 HttpStatusCode . OK ,
@@ -278,11 +298,21 @@ export class collectionController {
278298 description : "This will delete an auth profile " ,
279299 } )
280300 @UseGuards ( JwtAuthGuard )
281- @ApiResponse ( { status : 200 , description : "Auth profile Updated Successfully" } )
301+ @ApiResponse ( {
302+ status : 200 ,
303+ description : "Auth profile Updated Successfully" ,
304+ } )
282305 @ApiResponse ( { status : 400 , description : "Deletion operation Failed" } )
283- async deleteAuthProfiles ( @Body ( ) payload : AuthCollection , @Res ( ) res : FastifyReply , @Req ( ) request : ExtendedFastifyRequest ) {
306+ async deleteAuthProfiles (
307+ @Body ( ) payload : AuthCollection ,
308+ @Res ( ) res : FastifyReply ,
309+ @Req ( ) request : ExtendedFastifyRequest ,
310+ ) {
284311 const user = request . user ;
285- const message = await this . collectionService . deleteAuthProfile ( payload , user ) ;
312+ const message = await this . collectionService . deleteAuthProfile (
313+ payload ,
314+ user ,
315+ ) ;
286316 const responseData = new ApiResponseService (
287317 "Success" ,
288318 HttpStatusCode . OK ,
@@ -1599,7 +1629,46 @@ export class collectionController {
15991629 const responseData = new ApiResponseService (
16001630 "Success" ,
16011631 HttpStatusCode . OK ,
1602- collectionVariables ,
1632+ collectionVariables ) ;
1633+ } ;
1634+ /**
1635+ * Endpoint to update all the New generated Variables in requests.
1636+ *
1637+ * @param collectionId The collectionId.
1638+ * @param KeyValuePairs[] The collectionId.
1639+ * @returns The response object with status and data.
1640+ */
1641+ @Post ( "generate-variables/insert" )
1642+ @ApiOperation ( {
1643+ summary : "Insert Generated Variables into Collection" ,
1644+ description :
1645+ "Updates each request in the collection by replacing the content field with its corresponding generated variable key." ,
1646+ } )
1647+ @UseGuards ( JwtAuthGuard )
1648+ @ApiResponse ( {
1649+ status : 200 ,
1650+ description : "Generated Variables Added Successfully" ,
1651+ } )
1652+ @ApiResponse ( {
1653+ status : 400 ,
1654+ description : "Failed to add a Generate Variables." ,
1655+ } )
1656+ async addGeneratedVariables (
1657+ @Body ( ) content : CollectionGeneratedVariableDto ,
1658+ @Res ( ) res : FastifyReply ,
1659+ @Req ( ) request : ExtendedFastifyRequest ,
1660+ ) {
1661+ const user = request . user ;
1662+ const response = await this . collectionService . insertGeneratedVariables (
1663+ content . collectionId ,
1664+ content . generatedeVariables ,
1665+ content . workspaceId ,
1666+ user ,
1667+ ) ;
1668+ const responseData = new ApiResponseService (
1669+ "Generated Variables Inserted Successfully" ,
1670+ HttpStatusCode . OK ,
1671+ response ,
16031672 ) ;
16041673 return res . status ( responseData . httpStatusCode ) . send ( responseData ) ;
16051674 }
0 commit comments