From eed2da858c4b79cbe0f98f3c5cf9fd89cc891a25 Mon Sep 17 00:00:00 2001 From: DevendraPPatil Date: Wed, 12 Jun 2024 12:48:53 +0530 Subject: [PATCH] Feat: Swagger added for the content api --- package-lock.json | 2 +- package.json | 2 +- src/controllers/collection.controller.ts | 318 ++++++++++++- src/controllers/content.controller.ts | 566 ++++++++++++++++++++++- 4 files changed, 882 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index f8bcd88..d397a53 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@nestjs/mongoose": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/platform-fastify": "^10.0.5", - "@nestjs/swagger": "^7.1.17", + "@nestjs/swagger": "^7.3.1", "axios": "^1.6.2", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", diff --git a/package.json b/package.json index bbe5303..ccab5ad 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@nestjs/mongoose": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/platform-fastify": "^10.0.5", - "@nestjs/swagger": "^7.1.17", + "@nestjs/swagger": "^7.3.1", "axios": "^1.6.2", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", diff --git a/src/controllers/collection.controller.ts b/src/controllers/collection.controller.ts index 82b46d5..d8e5c1c 100644 --- a/src/controllers/collection.controller.ts +++ b/src/controllers/collection.controller.ts @@ -12,13 +12,79 @@ import { import { collection } from 'src/schemas/collection.schema'; import { CollectionService } from 'src/services/collection.service'; import { FastifyReply } from 'fastify'; -import { ApiTags } from '@nestjs/swagger'; +import { + ApiBody, + ApiExcludeEndpoint, + ApiForbiddenResponse, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags, +} from '@nestjs/swagger'; @ApiTags('collection') @Controller('collection') export class CollectionController { - constructor(private readonly CollectionService: CollectionService) {} + constructor(private readonly CollectionService: CollectionService) { } + @ApiBody({ + description: 'Request body for storing data to collection', + schema: { + type: 'object', + properties: { + name: { type: 'string', example: 'Teacher-Teacher' }, + description: { type: 'string', example: 'Teacher-Teacher' }, + category: { type: 'string', example: 'Word' }, + author: { type: 'string', example: 'Ekstep' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + }, + }, + }) + @ApiResponse({ + status: 201, + description: 'Success message when data is stored to the collection table', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'object', + properties: { + name: { type: 'string', example: 'Teacher-Teacher' }, + description: { type: 'string', example: 'Teacher-Teacher' }, + category: { type: 'string', example: 'Word' }, + author: { type: 'string', example: 'Ekstep' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + createdAt: { type: 'string', example: '2024-06-07T06:14:44.161Z' }, + updatedAt: { type: 'string', example: '2024-06-07T06:14:44.161Z' }, + _id: { type: 'string', example: '6662a5848946f51e15abb9fd' }, + collectionId: { type: 'string', example: '7b762891-8337-46a6-8eb0-abfcdc5c7f35' }, + __v: { type: 'number', example: 0 }, + }, + }, + }, + }, + }) + @ApiResponse({ + status: 500, + description: 'Error while data is being stored to the collection', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiForbiddenResponse({ description: 'Forbidden.' }) + @ApiOperation({ + summary: + 'Store collection data for adding the content with the reference of the colletion id', + }) @Post() async create(@Res() response: FastifyReply, @Body() collection: collection) { try { @@ -35,6 +101,51 @@ export class CollectionController { } } + + @ApiResponse({ + status: 200, + description: 'Successfully retrieved items', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '665ef5896e1219eb3d1a9b21' }, + name: { type: 'string', example: 'Teacher-Teacher' }, + description: { type: 'string', example: 'Teacher-Teacher' }, + category: { type: 'string', example: 'Word' }, + author: { type: 'string', example: 'Ekstep' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + createdAt: { type: 'string', example: '2024-06-04T11:07:02.300Z' }, + updatedAt: { type: 'string', example: '2024-06-04T11:07:02.300Z' }, + collectionId: { type: 'string', example: '58009c39-fd86-45a5-bc32-9638a8198521' }, + __v: { type: 'number', example: 0 }, + }, + }, + }, + }, + }, + }) + @ApiResponse({ + status: 500, + description: 'Error while retrive the data from collection', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'Get all data from the collection' + }) @Get() async fatchAll(@Res() response: FastifyReply) { try { @@ -47,7 +158,56 @@ export class CollectionController { }); } } + + @ApiParam({ + name: 'language', + example: 'tn', + }) + @ApiResponse({ + status: 200, + description: 'Successfully retrieved the collection data for the selected language', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '665ef5896e1219eb3d1a9b21' }, + name: { type: 'string', example: 'Teacher-Teacher' }, + description: { type: 'string', example: 'Teacher-Teacher' }, + category: { type: 'string', example: 'Word' }, + author: { type: 'string', example: 'Ekstep' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + createdAt: { type: 'string', example: '2024-06-04T11:07:02.300Z' }, + updatedAt: { type: 'string', example: '2024-06-04T11:07:02.300Z' }, + collectionId: { type: 'string', example: '58009c39-fd86-45a5-bc32-9638a8198521' }, + __v: { type: 'number', example: 0 }, + }, + }, + }, + }, + }, + }) + @ApiResponse({ + status: 500, + description: 'Error while retrive the data from collection', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'Get all data from the collection with the specific language' + }) @Get('/bylanguage/:language') async fatchByLanguage( @Res() response: FastifyReply, @@ -64,6 +224,51 @@ export class CollectionController { } } + + @ApiParam({ + name: 'id', + example: '65717aea18da2cbda941cee2', + }) + @ApiResponse({ + status: 200, + description: 'Successfully retrieved collection data using collection id', + schema: { + type: 'object', + properties: { + collection: { + type: 'object', + properties: { + _id: { type: 'string', example: '6662a5848946f51e15abb9fd' }, + name: { type: 'string', example: 'Teacher-Teacher' }, + description: { type: 'string', example: 'Teacher-Teacher' }, + category: { type: 'string', example: 'Word' }, + author: { type: 'string', example: 'Ekstep' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: ['ASR'] }, + createdAt: { type: 'string', example: '2024-06-07T06:14:44.161Z' }, + updatedAt: { type: 'string', example: '2024-06-07T06:14:44.161Z' }, + collectionId: { type: 'string', example: '7b762891-8337-46a6-8eb0-abfcdc5c7f35' }, + __v: { type: 'number', example: 0 }, + }, + }, + }, + }, + }) + @ApiResponse({ + status: 500, + description: 'Error while retrive the data from collection', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'Get the collection data for collection id' + }) @Get('/:id') async findById(@Res() response: FastifyReply, @Param('id') id) { const collection = await this.CollectionService.readById(id); @@ -72,6 +277,70 @@ export class CollectionController { }); } + + @ApiParam({ + name: 'id', + example: '65717aea18da2cbda941cee2', + }) + @ApiBody({ + description: 'Request body for creating a new item', + schema: { + type: 'object', + properties: { + name: { type: 'string', example: 'எழுத்துக்கள்' }, + description: { type: 'string', example: 'ASAR Set எழுத்துக்கள்' }, + category: { type: 'string', example: 'Char' }, + author: { type: 'string', example: 'ASER' }, + language: { type: 'string', example: 'ta' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: ['ASER', 'set1', 'm1'] }, + createdAt: { type: 'string', example: '2023-12-18T10:53:49.787Z' }, + updatedAt: { type: 'string', example: '2023-12-18T10:53:49.788Z' }, + collectionId: { type: 'string', example: '94312c93-5bb8-4144-8822-9a61ad1cd5a8' }, + __v: { type: 'number', example: 0 }, + }, + }, + }) + @ApiResponse({ + status: 200, + description: 'Successfully update the collection data using collection id', + schema: { + type: 'object', + properties: { + collection: { + type: 'object', + properties: { + _id: { type: 'string', example: '6662a5848946f51e15abb9fd' }, + name: { type: 'string', example: 'Teacher-Teacher' }, + description: { type: 'string', example: 'Teacher-Teacher' }, + category: { type: 'string', example: 'Word' }, + author: { type: 'string', example: 'Ekstep' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: ['ASR'] }, + createdAt: { type: 'string', example: '2024-06-07T06:14:44.161Z' }, + updatedAt: { type: 'string', example: '2024-06-07T06:14:44.161Z' }, + collectionId: { type: 'string', example: '7b762891-8337-46a6-8eb0-abfcdc5c7f35' }, + __v: { type: 'number', example: 0 }, + }, + }, + }, + }, + }) + @ApiResponse({ + status: 500, + description: 'Error while retrive the data from collection', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'update the collection data using collection id' + }) @Put('/:id') async update( @Res() response: FastifyReply, @@ -84,6 +353,51 @@ export class CollectionController { }); } + + @ApiParam({ + name: 'id', + example: '65717aea18da2cbda941cee2', + }) + @ApiResponse({ + status: 200, + description: 'The item has been successfully deleted.', + schema: { + type: 'object', + properties: { + deleted: { + type: 'object', + properties: { + _id: { type: 'string', example: '6662a5848946f51e15abb9fd' }, + name: { type: 'string', example: 'எழுத்துக்கள்' }, + description: { type: 'string', example: 'ASAR Set எழுத்துக்கள்' }, + category: { type: 'string', example: 'Char' }, + author: { type: 'string', example: 'ASER' }, + language: { type: 'string', example: 'kn' }, + status: { type: 'string', example: 'live' }, + tags: { type: 'array', items: { type: 'string' }, example: ['ASER', 'set1', 'm1'] }, + createdAt: { type: 'string', example: '2023-12-18T10:53:49.787Z' }, + updatedAt: { type: 'string', example: '2023-12-18T10:53:49.788Z' }, + collectionId: { type: 'string', example: '94312c93-5bb8-4144-8822-9a61ad1cd5a8' }, + __v: { type: 'number', example: 0 }, + }, + }, + }, + }, + }) + @ApiResponse({ + status: 500, + description: 'Error while deleting the data from collection', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'delete the collection data using collection id' + }) @Delete('/:id') async delete(@Res() response: FastifyReply, @Param('id') id) { const deleted = await this.CollectionService.delete(id); diff --git a/src/controllers/content.controller.ts b/src/controllers/content.controller.ts index e286195..0e48936 100644 --- a/src/controllers/content.controller.ts +++ b/src/controllers/content.controller.ts @@ -15,8 +15,17 @@ import { CollectionService } from '../services/collection.service'; import { FastifyReply } from 'fastify'; import { HttpService } from '@nestjs/axios'; import { lastValueFrom, map } from 'rxjs'; -import { ApiTags } from '@nestjs/swagger'; import * as splitGraphemes from 'split-graphemes'; +import { + ApiBody, + ApiExcludeEndpoint, + ApiForbiddenResponse, + ApiOperation, + ApiParam, + ApiResponse, + ApiTags, + ApiQuery, +} from '@nestjs/swagger'; @ApiTags('content') @Controller('content') @@ -27,6 +36,115 @@ export class contentController { private readonly httpService: HttpService, ) { } + @ApiBody({ + description: 'Request body for storing the data into the content', + schema: { + type: 'object', + properties: { + collectionId: { type: 'string', example: '3f0192af-0720-4248-b4d4-d99a9f731d4f' }, + name: { type: 'string', example: 'tn gr2 eng t1 ch2d' }, + contentType: { type: 'string', example: 'Sentence' }, + contentSourceData: { + type: 'array', + items: { + type: 'object', + properties: { + language: { type: 'string', example: 'en' }, + audioUrl: { type: 'string', example: '' }, + text: { type: 'string', example: 'Blue bird, blue bird, what do you see?' }, + }, + }, + }, + status: { type: 'string', example: 'live' }, + publisher: { type: 'string', example: 'ekstep' }, + language: { type: 'string', example: 'en' }, + contentIndex: { type: 'number', example: 1 }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + imagePath: { type: 'string', example: 'image_2.jpg' }, + }, + }, + }) + @ApiResponse({ + status: 201, + description: 'The content item has been successfully created.', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'object', + properties: { + collectionId: { type: 'string', example: '3f0192af-0720-4248-b4d4-d99a9f731d4f' }, + name: { type: 'string', example: 'tn gr2 eng t1 ch2d' }, + contentType: { type: 'string', example: 'Sentence' }, + imagePath: { type: 'string', example: 'image_2.jpg' }, + contentSourceData: { + type: 'array', + items: { + type: 'object', + properties: { + language: { type: 'string', example: 'en' }, + audioUrl: { type: 'string', example: '' }, + text: { type: 'string', example: 'Blue bird, blue bird, what do you see?' }, + phonemes: { type: 'array', items: { type: 'string' }, example: ['b', 'l', 'u', 'b', 'ə', 'r', 'd', ',', 'b', 'l', 'u', 'b', 'ə', 'r', 'd', ',', 'w', 'ə', 't', 'd', 'u', 'j', 'u', 's', 'i', '?'] }, + wordCount: { type: 'number', example: 8 }, + wordFrequency: { + type: 'object', + example: { + blue: 2, + bird: 2, + what: 1, + do: 1, + you: 1, + see: 1 + } + }, + syllableCount: { type: 'number', example: 28 }, + syllableCountMap: { + type: 'object', + example: { + blue: 4, + bird: 4, + what: 4, + do: 2, + you: 3, + see: 3 + } + } + } + } + }, + status: { type: 'string', example: 'live' }, + publisher: { type: 'string', example: 'ekstep' }, + language: { type: 'string', example: 'en' }, + contentIndex: { type: 'number', example: 1 }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + createdAt: { type: 'string', example: '2024-06-07T09:48:00.040Z' }, + updatedAt: { type: 'string', example: '2024-06-07T09:48:00.040Z' }, + _id: { type: 'string', example: '6662d7ff059b133df04db6e3' }, + contentId: { type: 'string', example: 'fa853c29-bf19-417a-9661-c67d2671ebc1' }, + __v: { type: 'number', example: 0 } + } + } + } + } + }) + @ApiResponse({ + status: 500, + description: 'Error while data is being stored to the content table', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiForbiddenResponse({ description: 'Forbidden.' }) + @ApiOperation({ + summary: + 'Store the data into to the content table', + }) @Post() async create(@Res() response: FastifyReply, @Body() content: any) { try { @@ -201,7 +319,7 @@ export class contentController { }); } } - + @Post('search') async searchContent(@Res() response: FastifyReply, @Body() tokenData: any) { try { @@ -248,6 +366,71 @@ export class contentController { } } + @ApiQuery({ + name: 'pagination', + description: 'Pagination parameters (page, limit, collectionId)', + required: true, + schema: { + properties: { + type:{ type: 'string', description: 'content type', example: 'word' }, + page: { type: 'number', description: 'Page number', example: 1 }, + limit: { type: 'number', description: 'Items per page', example: 10 }, + collectionId: { type: 'string', description: 'ID of the collection', example: '3f0192af-0720-4248-b4d4-d99a9f731d4f' } + } + } + }) + @ApiResponse({ + status: 200, + description: 'The content is search by using the collection id limit and page criteria', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '6662d7ff059b133df04db6e3' }, + contentType: { type: 'string', example: 'Sentence' }, + contentSourceData: { + type: 'array', + items: { + type: 'object', + properties: { + text: { type: 'string', example: 'Blue bird, blue bird, what do you see?' }, + phonemes: { + type: 'array', + items: { type: 'string', example: ['b', 'l', 'u', 'b', 'ə', 'r'] } + }, + syllableCount: { type: 'number', example: 28 } + } + } + }, + language: { type: 'string', example: 'en' }, + contentId: { type: 'string', example: 'fa853c29-bf19-417a-9661-c67d2671ebc1' } + } + } + }, + totalSyllableCount: { type: 'number', example: 26 } + } + } + }) + @ApiResponse({ + status: 500, + description: 'Error while data is being stored to the content table', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: + 'Get the content data with the collection id with pageNo and limit', + }) @Get('/pagination') async pagination( @Res() response: FastifyReply, @@ -291,6 +474,100 @@ export class contentController { } } + @ApiQuery({ + name: 'pagination', + description: 'Pagination parameters (page, limit, collectionId)', + required: true, + schema: { + properties: { + type:{ type: 'string', description: 'content type', example: 'word' }, + language: { type: 'number', description: 'Page number', example: 1 }, + limit: { type: 'number', description: 'Items per page', example: 10 } + } + } + }) + @ApiResponse({ + status: 200, + description: 'The paginated content data has been successfully retrieved.', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '6662d7ff059b133df04db6e3' }, + collectionId: { type: 'string', example: '3f0192af-0720-4248-b4d4-d99a9f731d4f' }, + name: { type: 'string', example: 'tn gr2 eng t1 ch2d' }, + contentType: { type: 'string', example: 'Sentence' }, + imagePath: { type: 'string', example: 'image_2.jpg' }, + contentSourceData: { + type: 'array', + items: { + type: 'object', + properties: { + language: { type: 'string', example: 'en' }, + audioUrl: { type: 'string', example: '' }, + text: { type: 'string', example: 'Blue bird, blue bird, what do you see?' }, + phonemes: { + type: 'array', + items: { type: 'string', example: ['b', 'l', 'u', 'b', 'ə', 'r', 'd', ',', 'b', 'l', 'u', 'b', 'ə', 'r', 'd', ',', 'w', 'ə', 't', 'd', 'u', 'j', 'u', 's', 'i', '?'] } + }, + wordCount: { type: 'number', example: 8 }, + wordFrequency: { + type: 'object', + example: { + blue: 2, + bird: 2, + what: 1, + do: 1, + you: 1, + see: 1 + } + }, + syllableCount: { type: 'number', example: 28 }, + syllableCountMap: { + type: 'object', + example: { + blue: 4, + bird: 4, + what: 4, + do: 2, + you: 3, + see: 3 + } + } + } + } + }, + status: { type: 'string', example: 'live' }, + publisher: { type: 'string', example: 'ekstep' }, + language: { type: 'string', example: 'en' }, + contentIndex: { type: 'number', example: 1 }, + tags: { type: 'array', items: { type: 'string' }, example: [] }, + createdAt: { type: 'string', example: '2024-06-07T09:48:00.040Z' }, + updatedAt: { type: 'string', example: '2024-06-07T09:48:00.040Z' }, + contentId: { type: 'string', example: 'fa853c29-bf19-417a-9661-c67d2671ebc1' }, + __v: { type: 'number', example: 0 } + } + } + } + } + } + }) + @ApiResponse({ + status: 500, + description: 'Error while data is being stored to the content table', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) @Get('/getRandomContent') async getRandomContent( @Res() response: FastifyReply, @@ -377,6 +654,231 @@ export class contentController { } } + @ApiBody({ + description: 'Request body parameters for get content', + required: true, + schema: { + type: 'object', + properties: { + tokenArr: { + type: 'array', + description: 'Array of tokens', + items: { + type: 'string', + example: 'c' + } + }, + language: { + type: 'string', + description: 'Language code', + example: 'en' + }, + contentType: { + type: 'string', + description: 'Type of content', + example: 'Word' + }, + limit: { + type: 'number', + description: 'Limit on the number of items', + example: 5 + }, + cLevel: { + type: 'string', + description: 'Content level', + example: 'L2' + }, + complexityLevel: { + type: 'array', + description: 'Array of complexity levels', + items: { + type: 'string', + example: 'C1' + } + }, + graphemesMappedObj: { + type: 'object', + description: 'Object mapping graphemes to their representations', + additionalProperties: { + type: 'array', + items: { + type: 'string', + example: 'ch' + } + }, + example: { + "c": ["ch"], + "o": ["o"], + "a": ["a"], + "v": ["v", "ve"], + "w": ["w", "wh"], + "æ": ["a", "ai", "au"], + "n": ["n"], + "i": ["i"], + "θ": ["th"] + } + } + } + } + }) + @ApiResponse({ + status: 200, + description: 'Successful response', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'success' }, + data: { + type: 'object', + properties: { + wordsArr: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '660f9545367a62b3902dd58b' }, + contentId: { type: 'string', example: 'f8dd7c97-53f7-4676-b597-4a52aaface5c' }, + collectionId: { type: 'string', example: '6a519951-8635-4d89-821a-d3eb60f6e1ec' }, + name: { type: 'string', example: 'L2_new_3' }, + contentType: { type: 'string', example: 'Word' }, + contentSourceData: { + type: 'array', + items: { + type: 'object', + properties: { + language: { type: 'string', example: 'en' }, + audioUrl: { type: 'string', example: '' }, + text: { type: 'string', example: 'five' }, + phonemes: { + type: 'array', + items: { type: 'string', example: 'f' } + }, + wordCount: { type: 'number', example: 1 }, + wordFrequency: { + type: 'object', + additionalProperties: { type: 'number', example: 1 } + }, + syllableCount: { type: 'number', example: 4 }, + syllableCountMap: { + type: 'object', + additionalProperties: { type: 'number', example: 4 } + }, + syllableCountArray: { + type: 'array', + items: { + type: 'object', + properties: { + k: { type: 'string', example: 'five' }, + v: { type: 'number', example: 4 } + } + } + } + } + } + }, + status: { type: 'string', example: 'live' }, + publisher: { type: 'string', example: 'ekstep' }, + language: { type: 'string', example: 'en' }, + contentIndex: { type: 'number', example: 141 }, + tags: { + type: 'array', + items: { type: 'string' } + }, + createdAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' }, + updatedAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' }, + __v: { type: 'number', example: 0 }, + matchedChar: { + type: 'array', + items: { type: 'string', example: 'v' } + } + } + } + }, + contentForToken: { + type: 'object', + additionalProperties: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '660f9545367a62b3902dd58b' }, + contentId: { type: 'string', example: 'f8dd7c97-53f7-4676-b597-4a52aaface5c' }, + collectionId: { type: 'string', example: '6a519951-8635-4d89-821a-d3eb60f6e1ec' }, + name: { type: 'string', example: 'L2_new_3' }, + contentType: { type: 'string', example: 'Word' }, + contentSourceData: { + type: 'array', + items: { + type: 'object', + properties: { + language: { type: 'string', example: 'en' }, + audioUrl: { type: 'string', example: '' }, + text: { type: 'string', example: 'five' }, + phonemes: { + type: 'array', + items: { type: 'string', example: 'f' } + }, + wordCount: { type: 'number', example: 1 }, + wordFrequency: { + type: 'object', + additionalProperties: { type: 'number', example: 1 } + }, + syllableCount: { type: 'number', example: 4 }, + syllableCountMap: { + type: 'object', + additionalProperties: { type: 'number', example: 4 } + }, + syllableCountArray: { + type: 'array', + items: { + type: 'object', + properties: { + k: { type: 'string', example: 'five' }, + v: { type: 'number', example: 4 } + } + } + } + } + } + }, + status: { type: 'string', example: 'live' }, + publisher: { type: 'string', example: 'ekstep' }, + language: { type: 'string', example: 'en' }, + contentIndex: { type: 'number', example: 141 }, + tags: { + type: 'array', + items: { type: 'string' } + }, + createdAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' }, + updatedAt: { type: 'string', example: '2024-04-05T05:45:55.335Z' }, + __v: { type: 'number', example: 0 }, + matchedChar: { + type: 'array', + items: { type: 'string', example: 'v' } + } + } + } + } + } + } + } + } + } + }) + @ApiResponse({ + status: 500, + description: 'Error while fetching data from the content table', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'Get all data from the content table' + }) @Post('/getContent') async getContent(@Res() response: FastifyReply, @Body() queryData: any) { try { @@ -423,6 +925,65 @@ export class contentController { } } + + @ApiBody({ + description: 'Request body parameters', + required: true, + schema: { + type: 'object', + properties: { + tags: { + type: 'array', + description: 'Array of tags', + items: { + type: 'string', + example: 'ASER' + } + }, + language: { + type: 'string', + description: 'Language code', + example: 'ta' + } + } + } + }) + @ApiResponse({ + status: 200, + description: 'Successful response', + schema: { + type: 'object', + properties: { + data: { + type: 'array', + items: { + type: 'object', + properties: { + _id: { type: 'string', example: '65e88b6cdee499a6209e739e' }, + name: { type: 'string', example: '(மாதிறி -4)எழுத்து' }, + category: { type: 'string', example: 'Char' }, + collectionId: { type: 'string', example: 'ed47eb63-87c8-41f4-821d-1400fef37b78' } + } + } + }, + status: { type: 'number', example: 200 } + } + } + }) + @ApiResponse({ + status: 500, + description: 'Error while get the data from the content', + schema: { + type: 'object', + properties: { + status: { type: 'string', example: 'error' }, + msg: { type: 'string', example: 'Server error - error message' }, + }, + }, + }) + @ApiOperation({ + summary: 'Get Assessments data' + }) @Post('/getAssessment') async getAssessment(@Res() response: FastifyReply, @Body() queryData: any) { try { @@ -455,6 +1016,7 @@ export class contentController { }); } } + @Post('/getContentForMileStone') async get(@Res() response: FastifyReply, @Body() queryData: any) { try {