diff --git a/services/account/package.json b/services/account/package.json index f080fe9e..a30964a0 100644 --- a/services/account/package.json +++ b/services/account/package.json @@ -154,6 +154,7 @@ "^#lib/blockchain(|/.*)$": "/libs/common/src/blockchain/$1", "^#lib/config(|/.*)$": "/libs/common/src/config/$1", "^#lib/interfaces(|/.*)$": "/libs/common/src/interfaces/$1", + "^#lib/queues(|/.*)$": "/libs/common/src/queues/$1", "^#lib/services(|/.*)$": "/libs/common/src/services/$1", "^#lib/types(|/.*)$": "/libs/common/src/types/$1", "^#lib/utils(|/.*)$": "/libs/common/src/utils/$1" diff --git a/services/content-publishing/apps/api/src/controllers/v1/asset.controller.v1.ts b/services/content-publishing/apps/api/src/controllers/v1/asset.controller.v1.ts index 79ecc3a3..76f6e4d4 100644 --- a/services/content-publishing/apps/api/src/controllers/v1/asset.controller.v1.ts +++ b/services/content-publishing/apps/api/src/controllers/v1/asset.controller.v1.ts @@ -1,4 +1,4 @@ -import { FilesUploadDto, UploadResponseDto } from '#libs/dtos/common.dto'; +import { FilesUploadDto, UploadResponseDto } from '../../../../../libs/common/src/dtos/common.dto'; import { DSNP_VALID_MIME_TYPES } from '#libs/dtos/validation.dto'; import { Controller, @@ -11,7 +11,7 @@ import { UseInterceptors, } from '@nestjs/common'; import { FilesInterceptor } from '@nestjs/platform-express'; -import { ApiBody, ApiConsumes, ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiBody, ApiConsumes, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiService } from '../../api.service'; @Controller('v1/asset') @@ -32,6 +32,7 @@ export class AssetControllerV1 { description: 'Asset files', type: FilesUploadDto, }) + @ApiResponse({ status: '2XX', type: UploadResponseDto }) async assetUpload( @UploadedFiles( new ParseFilePipeBuilder() diff --git a/services/content-publishing/apps/api/src/controllers/v1/content.controller.v1.ts b/services/content-publishing/apps/api/src/controllers/v1/content.controller.v1.ts index a60c55e3..8f2286f7 100644 --- a/services/content-publishing/apps/api/src/controllers/v1/content.controller.v1.ts +++ b/services/content-publishing/apps/api/src/controllers/v1/content.controller.v1.ts @@ -1,5 +1,5 @@ import { Body, Controller, Delete, HttpCode, Logger, Param, Post, Put } from '@nestjs/common'; -import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiService } from '../../api.service'; import { DsnpUserIdParam, @@ -25,6 +25,7 @@ export class ContentControllerV1 { @Post(':userDsnpId/broadcast') @ApiOperation({ summary: 'Create DSNP Broadcast for User' }) @HttpCode(202) + @ApiResponse({ status: '2XX', type: AnnouncementResponseDto }) async broadcast( @Param() userDsnpId: DsnpUserIdParam, @Body() broadcastDto: BroadcastDto, @@ -36,6 +37,7 @@ export class ContentControllerV1 { @Post(':userDsnpId/reply') @ApiOperation({ summary: 'Create DSNP Reply for User' }) @HttpCode(202) + @ApiResponse({ status: '2XX', type: AnnouncementResponseDto }) async reply(@Param() userDsnpId: DsnpUserIdParam, @Body() replyDto: ReplyDto): Promise { const metadata = await this.apiService.validateAssetsAndFetchMetadata(replyDto as AssetIncludedRequestDto); return this.apiService.enqueueRequest(AnnouncementTypeDto.REPLY, userDsnpId.userDsnpId, replyDto, metadata); @@ -44,6 +46,7 @@ export class ContentControllerV1 { @Post(':userDsnpId/reaction') @ApiOperation({ summary: 'Create DSNP Reaction for User' }) @HttpCode(202) + @ApiResponse({ status: '2XX', type: AnnouncementResponseDto }) async reaction( @Param() userDsnpId: DsnpUserIdParam, @Body() reactionDto: ReactionDto, @@ -54,6 +57,7 @@ export class ContentControllerV1 { @Put(':userDsnpId') @ApiOperation({ summary: 'Update DSNP Content for User' }) @HttpCode(202) + @ApiResponse({ status: '2XX', type: AnnouncementResponseDto }) async update(@Param() userDsnpId: DsnpUserIdParam, @Body() updateDto: UpdateDto): Promise { const metadata = await this.apiService.validateAssetsAndFetchMetadata(updateDto as AssetIncludedRequestDto); return this.apiService.enqueueRequest(AnnouncementTypeDto.UPDATE, userDsnpId.userDsnpId, updateDto, metadata); @@ -62,6 +66,7 @@ export class ContentControllerV1 { @Delete(':userDsnpId') @ApiOperation({ summary: 'Delete DSNP Content for User' }) @HttpCode(202) + @ApiResponse({ status: '2XX', type: AnnouncementResponseDto }) async delete( @Param() userDsnpId: DsnpUserIdParam, @Body() tombstoneDto: TombstoneDto, diff --git a/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts b/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts index 306e6a1c..6a377e41 100644 --- a/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts +++ b/services/content-publishing/apps/api/src/controllers/v1/development.controller.v1.ts @@ -7,7 +7,7 @@ import { Controller, Get, Logger, NotFoundException, Param, Post } from '@nestjs import { InjectQueue } from '@nestjs/bullmq'; import { Queue } from 'bullmq'; import { Job } from 'bullmq/dist/esm/classes/job'; -import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { createBroadcast, createProfile, @@ -67,6 +67,7 @@ export class DevelopmentControllerV1 { @Get('/asset/:assetId') @ApiOperation({ summary: 'Get an Asset given an assetId', description: 'ONLY enabled when ENVIRONMENT="dev".' }) + @ApiResponse({ status: '2XX', type: Buffer }) // eslint-disable-next-line consistent-return async getAsset(@Param('assetId') assetId: string) { if (await this.ipfsService.isPinned(assetId)) { diff --git a/services/content-publishing/apps/api/src/controllers/v1/profile.controller.v1.ts b/services/content-publishing/apps/api/src/controllers/v1/profile.controller.v1.ts index b94e20d9..93f2e5e3 100644 --- a/services/content-publishing/apps/api/src/controllers/v1/profile.controller.v1.ts +++ b/services/content-publishing/apps/api/src/controllers/v1/profile.controller.v1.ts @@ -1,5 +1,5 @@ import { Body, Controller, HttpCode, Logger, Param, Put } from '@nestjs/common'; -import { ApiOperation, ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { ApiService } from '../../api.service'; import { DsnpUserIdParam, @@ -21,6 +21,7 @@ export class ProfileControllerV1 { @Put(':userDsnpId') @ApiOperation({ summary: "Update a user's Profile" }) @HttpCode(202) + @ApiResponse({ status: '2XX', type: AnnouncementResponseDto }) async profile( @Param() userDsnpId: DsnpUserIdParam, @Body() profileDto: ProfileDto, diff --git a/services/content-publishing/libs/common/src/dtos/activity.dto.ts b/services/content-publishing/libs/common/src/dtos/activity.dto.ts index 053cb24c..dcc4c59a 100644 --- a/services/content-publishing/libs/common/src/dtos/activity.dto.ts +++ b/services/content-publishing/libs/common/src/dtos/activity.dto.ts @@ -24,7 +24,8 @@ import { } from 'class-validator'; import { Type } from 'class-transformer'; import { DURATION_REGEX } from './validation.dto'; -import { IsDsnpUserURI } from '#libs/utils/dsnp-validation.decorator'; +import { DSNP_USER_URI_REGEX, IsDsnpUserURI } from '#libs/utils/dsnp-validation.decorator'; +import { ApiProperty } from '@nestjs/swagger'; // eslint-disable-next-line no-shadow export enum UnitTypeDto { diff --git a/services/content-publishing/libs/common/src/dtos/common.dto.ts b/services/content-publishing/libs/common/src/dtos/common.dto.ts index 1f28b83f..d60ff9ea 100644 --- a/services/content-publishing/libs/common/src/dtos/common.dto.ts +++ b/services/content-publishing/libs/common/src/dtos/common.dto.ts @@ -16,6 +16,7 @@ export class AnnouncementResponseDto { } export class UploadResponseDto { + @ApiProperty() assetIds: string[]; } diff --git a/services/content-publishing/package-lock.json b/services/content-publishing/package-lock.json index ede91932..f61de88b 100644 --- a/services/content-publishing/package-lock.json +++ b/services/content-publishing/package-lock.json @@ -26,7 +26,7 @@ "@nestjs/event-emitter": "^2.0.4", "@nestjs/platform-express": "^10.3.10", "@nestjs/schedule": "^4.0.2", - "@nestjs/swagger": "^7.3.1", + "@nestjs/swagger": "^7.4.0", "@polkadot/api": "^10.12.4", "@polkadot/api-base": "^10.12.4", "@polkadot/types": "^10.12.4", @@ -73,6 +73,7 @@ } }, "../../packages/ts-config": { + "name": "@amplica-labs/ts-config", "version": "1.0.0", "dev": true, "license": "Apache-2.0" @@ -2580,9 +2581,9 @@ } }, "node_modules/@microsoft/tsdoc": { - "version": "0.14.2", - "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.14.2.tgz", - "integrity": "sha512-9b8mPpKrfeGRuhFH5iO1iwCLeIIsV6+H1sRfxbkoGXIyQE2BTsPd9zqSqQJ+pv5sJ/hT5M1zvOFL02MnEezFug==" + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.15.0.tgz", + "integrity": "sha512-HZpPoABogPvjeJOdzCOSJsXeL/SMCBgBZMVC3X3d7YYp2gf31MfxhUoYUNwf1ERPJOnQc0wkFn9trqI6ZEdZuA==" }, "node_modules/@msgpackr-extract/msgpackr-extract-darwin-arm64": { "version": "3.0.2", @@ -2996,16 +2997,16 @@ "integrity": "sha512-AilxAyFOAcK5wA1+LeaySVBrHsGQvUFCDWXKpZjzaL0PqW+xfBOttn8GNtWKFWqneyMZj41MWF9Kl6iPWLwgOA==" }, "node_modules/@nestjs/swagger": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-7.3.1.tgz", - "integrity": "sha512-LUC4mr+5oAleEC/a2j8pNRh1S5xhKXJ1Gal5ZdRjt9XebQgbngXCdW7JTA9WOEcwGtFZN9EnKYdquzH971LZfw==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/@nestjs/swagger/-/swagger-7.4.0.tgz", + "integrity": "sha512-dCiwKkRxcR7dZs5jtrGspBAe/nqJd1AYzOBTzw9iCdbq3BGrLpwokelk6lFZPe4twpTsPQqzNKBwKzVbI6AR/g==", "dependencies": { - "@microsoft/tsdoc": "^0.14.2", + "@microsoft/tsdoc": "^0.15.0", "@nestjs/mapped-types": "2.0.5", "js-yaml": "4.1.0", "lodash": "4.17.21", "path-to-regexp": "3.2.0", - "swagger-ui-dist": "5.11.2" + "swagger-ui-dist": "5.17.14" }, "peerDependencies": { "@fastify/static": "^6.0.0 || ^7.0.0", @@ -12052,9 +12053,9 @@ } }, "node_modules/swagger-ui-dist": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.11.2.tgz", - "integrity": "sha512-jQG0cRgJNMZ7aCoiFofnoojeSaa/+KgWaDlfgs8QN+BXoGMpxeMVY5OEnjq4OlNvF3yjftO8c9GRAgcHlO+u7A==" + "version": "5.17.14", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.17.14.tgz", + "integrity": "sha512-CVbSfaLpstV65OnSjbXfVd6Sta3q3F7Cj/yYuvHMp1P90LztOLs6PfUnKEVAeiIVQt9u2SaPwv0LiH/OyMjHRw==" }, "node_modules/symbol-observable": { "version": "4.0.0", diff --git a/services/content-publishing/package.json b/services/content-publishing/package.json index f1a38609..34a05d60 100644 --- a/services/content-publishing/package.json +++ b/services/content-publishing/package.json @@ -68,7 +68,7 @@ "@nestjs/event-emitter": "^2.0.4", "@nestjs/platform-express": "^10.3.10", "@nestjs/schedule": "^4.0.2", - "@nestjs/swagger": "^7.3.1", + "@nestjs/swagger": "^7.4.0", "@polkadot/api": "^10.12.4", "@polkadot/api-base": "^10.12.4", "@polkadot/types": "^10.12.4", diff --git a/services/content-publishing/swagger.json b/services/content-publishing/swagger.json index b9e56a93..1fea1330 100644 --- a/services/content-publishing/swagger.json +++ b/services/content-publishing/swagger.json @@ -3,7 +3,7 @@ "paths": { "/v1/asset/upload": { "put": { - "operationId": "AssetController_assetUpload", + "operationId": "AssetControllerV1_assetUpload", "summary": "Upload Asset Files", "parameters": [], "requestBody": { @@ -18,7 +18,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -36,7 +36,7 @@ }, "/v1/content/{userDsnpId}/broadcast": { "post": { - "operationId": "ContentController_broadcast", + "operationId": "ContentControllerV1_broadcast", "summary": "Create DSNP Broadcast for User", "parameters": [ { @@ -59,7 +59,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -77,7 +77,7 @@ }, "/v1/content/{userDsnpId}/reply": { "post": { - "operationId": "ContentController_reply", + "operationId": "ContentControllerV1_reply", "summary": "Create DSNP Reply for User", "parameters": [ { @@ -100,7 +100,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -118,7 +118,7 @@ }, "/v1/content/{userDsnpId}/reaction": { "post": { - "operationId": "ContentController_reaction", + "operationId": "ContentControllerV1_reaction", "summary": "Create DSNP Reaction for User", "parameters": [ { @@ -141,7 +141,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -159,7 +159,7 @@ }, "/v1/content/{userDsnpId}": { "put": { - "operationId": "ContentController_update", + "operationId": "ContentControllerV1_update", "summary": "Update DSNP Content for User", "parameters": [ { @@ -182,7 +182,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -198,7 +198,7 @@ ] }, "delete": { - "operationId": "ContentController_delete", + "operationId": "ContentControllerV1_delete", "summary": "Delete DSNP Content for User", "parameters": [ { @@ -221,7 +221,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -239,7 +239,7 @@ }, "/v1/profile/{userDsnpId}": { "put": { - "operationId": "ProfileController_profile", + "operationId": "ProfileControllerV1_profile", "summary": "Update a user's Profile", "parameters": [ { @@ -262,7 +262,7 @@ } }, "responses": { - "202": { + "2XX": { "description": "", "content": { "application/json": { @@ -325,7 +325,7 @@ }, "/dev/request/{jobId}": { "get": { - "operationId": "DevelopmentController_requestJob", + "operationId": "DevelopmentControllerV1_requestJob", "summary": "Get a Job given a jobId", "description": "ONLY enabled when ENVIRONMENT=\"dev\".", "parameters": [ @@ -350,7 +350,7 @@ }, "/dev/asset/{assetId}": { "get": { - "operationId": "DevelopmentController_getAsset", + "operationId": "DevelopmentControllerV1_getAsset", "summary": "Get an Asset given an assetId", "description": "ONLY enabled when ENVIRONMENT=\"dev\".", "parameters": [ @@ -364,12 +364,12 @@ } ], "responses": { - "200": { + "2XX": { "description": "", "content": { "application/json": { "schema": { - "type": "object" + "$ref": "#/components/schemas/Buffer" } } } @@ -382,7 +382,7 @@ }, "/dev/dummy/announcement/{queueType}/{count}": { "post": { - "operationId": "DevelopmentController_populate", + "operationId": "DevelopmentControllerV1_populate", "summary": "Create dummy announcement data", "description": "ONLY enabled when ENVIRONMENT=\"dev\".", "parameters": [ @@ -536,9 +536,7 @@ "minLength": 1 }, "mentionedId": { - "type": "string", - "minLength": 1, - "pattern": "DSNP_USER_URI_REGEX" + "type": "string" } }, "required": [ @@ -594,8 +592,7 @@ "minLength": 1 }, "published": { - "type": "string", - "pattern": "ISO8601_REGEX" + "type": "string" }, "assets": { "type": "array", @@ -647,8 +644,7 @@ "type": "object", "properties": { "inReplyTo": { - "type": "string", - "pattern": "DSNP_CONTENT_URI_REGEX" + "type": "string" }, "content": { "$ref": "#/components/schemas/NoteActivityDto" @@ -673,8 +669,7 @@ "maximum": 255 }, "inReplyTo": { - "type": "string", - "pattern": "DSNP_CONTENT_URI_REGEX" + "type": "string" } }, "required": [ @@ -687,8 +682,7 @@ "type": "object", "properties": { "targetContentHash": { - "type": "string", - "pattern": "DSNP_CONTENT_HASH_REGEX" + "type": "string" }, "targetAnnouncementType": { "type": "string", @@ -711,8 +705,7 @@ "type": "object", "properties": { "targetContentHash": { - "type": "string", - "pattern": "DSNP_CONTENT_HASH_REGEX" + "type": "string" }, "targetAnnouncementType": { "type": "string", @@ -740,8 +733,7 @@ "type": "string" }, "published": { - "type": "string", - "pattern": "ISO8601_REGEX" + "type": "string" }, "name": { "type": "string" @@ -767,6 +759,10 @@ "required": [ "profile" ] + }, + "Buffer": { + "type": "object", + "properties": {} } } }