diff --git a/docsfera.external.json b/docsfera.external.json index 5823882..bb592a7 100644 --- a/docsfera.external.json +++ b/docsfera.external.json @@ -133,7 +133,32 @@ }, "get": { "operationId": "ConnectionController_getAllConnections", - "parameters": [], + "parameters": [ + { + "name": "search", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -1736,6 +1761,118 @@ ] } }, + "/customers/{id}/links": { + "get": { + "operationId": "CustomersController_getCustomerLinks", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerLinksResponse" + } + } + } + } + }, + "tags": [ + "Customers" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "put": { + "operationId": "CustomersController_setCustomerLinks", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerLinkRequest" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Customers" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/customers/token": { + "get": { + "operationId": "CustomersController_getCustomerToken", + "parameters": [ + { + "name": "exp", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + }, + "tags": [ + "Customers" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, "/health": { "get": { "operationId": "HealthController_check", @@ -1752,7 +1889,7 @@ } }, "info": { - "title": "Maestro - feat/generate-token", + "title": "Maestro - SOLENG-4628-feat/restrict-asset-options", "description": "This is the Maestro API", "version": "1.0.0", "contact": {} @@ -2033,6 +2170,9 @@ "ConnectionToCatalogDto": { "type": "object", "properties": { + "id": { + "type": "string" + }, "name": { "type": "string" }, @@ -3124,6 +3264,56 @@ "updated_at", "updated_by" ] + }, + "CustomerLink": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "iconSrc": { + "type": "string" + } + }, + "required": [ + "href", + "name", + "description" + ] + }, + "CustomerLinksResponse": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CustomerLink" + } + } + }, + "required": [ + "links" + ] + }, + "CustomerLinkRequest": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CustomerLink" + } + } + }, + "required": [ + "links" + ] } } } diff --git a/docsfera.json b/docsfera.json index d7e9b6c..d8d8575 100644 --- a/docsfera.json +++ b/docsfera.json @@ -582,7 +582,32 @@ }, "get": { "operationId": "ConnectionController_getAllConnections", - "parameters": [], + "parameters": [ + { + "name": "search", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -4962,7 +4987,16 @@ "/customers/{id}/links": { "get": { "operationId": "CustomersController_getCustomerLinks", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -4986,27 +5020,29 @@ }, "put": { "operationId": "CustomersController_setCustomerLinks", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "requestBody": { "required": true, "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CustomerDto" + "$ref": "#/components/schemas/CustomerLinkRequest" } } } }, "responses": { "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } + "description": "" } }, "tags": [ @@ -5039,7 +5075,7 @@ "200": { "description": "", "content": { - "application/json": { + "text/plain": { "schema": { "type": "string" } @@ -5076,7 +5112,7 @@ } }, "info": { - "title": "Maestro - feat/generate-token", + "title": "Maestro - fix/swagger", "description": "This is the Maestro API", "version": "1.0.0", "contact": {} @@ -5352,6 +5388,9 @@ "ConnectionToCatalogDto": { "type": "object", "properties": { + "id": { + "type": "string" + }, "name": { "type": "string" }, @@ -7811,13 +7850,35 @@ "tags" ] }, + "CustomerLink": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "iconSrc": { + "type": "string" + } + }, + "required": [ + "href", + "name", + "description" + ] + }, "CustomerLinksResponse": { "type": "object", "properties": { "links": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/CustomerLink" } } }, @@ -7825,13 +7886,13 @@ "links" ] }, - "CustomerDto": { + "CustomerLinkRequest": { "type": "object", "properties": { "links": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/CustomerLink" } } }, diff --git a/src/modules/connection/connection.controller.ts b/src/modules/connection/connection.controller.ts index d0231b5..7c4275a 100644 --- a/src/modules/connection/connection.controller.ts +++ b/src/modules/connection/connection.controller.ts @@ -24,6 +24,7 @@ import { ConnectionDetailsRes, ConnectionRes, ConnectionsRes, + GetAllConnectionsReq, UpdateConnectionDto, } from './dtos/connection'; import { CreateConnectionDto } from './dtos/connection'; @@ -138,7 +139,7 @@ export class ConnectionController { async getAllConnections( @User() user: RequestUser, @Language() language: LanguageEnum, - @Query() queries, + @Query() queries: GetAllConnectionsReq, ): Promise { this.logger.info('/connections - Get All Connection'); diff --git a/src/modules/connection/dtos/connection.ts b/src/modules/connection/dtos/connection.ts index 8eb564a..a60ca8c 100644 --- a/src/modules/connection/dtos/connection.ts +++ b/src/modules/connection/dtos/connection.ts @@ -9,6 +9,7 @@ import { ConnectionToCatalog, } from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/entities'; import { + GetAllConnectionRequest, GetAllConnectionResponse, GetConnectionDetailsResponse, GetConnectionResponse, @@ -21,7 +22,7 @@ export type ConnectionCredentialsType = | 'oauth' | 'api_key' | 'service_account' - | 'headers_authF'; + | 'headers_auth'; export interface ConnectionApiConnection { config_id: string; plugin: string; @@ -94,7 +95,6 @@ export class ConnectionDto implements Connection { export class ConnectionToCatalogDto implements ConnectionToCatalog { // ---Automatically generated information - will not be sent by the frontend--- // - id: string; customer_id: string; updated_at: string; created_at: string; @@ -104,6 +104,9 @@ export class ConnectionToCatalogDto implements ConnectionToCatalog { customer_name: string; // ---Information sent by the frontend--- // + @ApiPropertyOptional() + id: string; + @ApiProperty() name: string; @@ -147,6 +150,15 @@ export class UpdateConnectionDto extends PickType(ConnectionDto, [ 'properties', ]) {} +export class GetAllConnectionsReq implements GetAllConnectionRequest { + @ApiPropertyOptional() + search?: string; + @ApiPropertyOptional() + page?: string; + @ApiPropertyOptional() + size?: string; +} + export class ConnectionsRes implements GetAllConnectionResponse { @ApiProperty({ type: [ConnectionToCatalogDto] }) connections: ConnectionToCatalogDto[]; diff --git a/src/modules/customers/customers.controller.ts b/src/modules/customers/customers.controller.ts index f88a677..90f3c77 100644 --- a/src/modules/customers/customers.controller.ts +++ b/src/modules/customers/customers.controller.ts @@ -4,26 +4,27 @@ import { Body, Controller, Get, + HttpCode, + HttpStatus, Inject, Param, Put, Query, UseFilters, } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger'; import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; import { Authenticated, RequireAllPermissions, } from 'src/decorators/authentication.decorator'; -import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; import { CustomersService } from './customers.service'; -import { CustomerDto, CustomerLinksResponse } from './dtos/customers'; +import { CustomerLinkRequest, CustomerLinksResponse } from './dtos/customers'; import { RequestUser, User } from 'src/decorators/user.decorator'; import type { StringValue } from 'ms'; -@ApiInternalOnlyController() @ApiTags('Customers') @Controller('customers') @Authenticated() @@ -40,7 +41,8 @@ export class CustomersController { } @Get(':id/links') - async getCustomerLinks(@Param('id') id): Promise { + @ApiOkResponse({ type: CustomerLinksResponse }) + async getCustomerLinks(@Param('id') id: string) { this.logger.info('getCustomerLinks', { id }); const links = await this.customersService.getLinks(id); return { links }; @@ -48,17 +50,20 @@ export class CustomersController { @Put(':id/links') @RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN) - setCustomerLinks( - @Body() body: CustomerDto, - @Param('id') id, - ): Promise { + @ApiOkResponse() + @HttpCode(HttpStatus.OK) + async setCustomerLinks( + @Body() body: CustomerLinkRequest, + @Param('id') id: string, + ) { const { links } = body; this.logger.info('setCustomerLinks', { id, links }); - return this.customersService.setLinks(id, links); + await this.customersService.setLinks(id, links); } @Get('token') @RequireAllPermissions(PERMISSIONS_GROUPS.AUTH.permissions.GENERATE_TOKEN) + @ApiProduces('text/plain') async getCustomerToken( @Query('exp') exp: StringValue, @User() user: RequestUser, diff --git a/src/modules/customers/dtos/customers.ts b/src/modules/customers/dtos/customers.ts index 01337ad..c3b3070 100644 --- a/src/modules/customers/dtos/customers.ts +++ b/src/modules/customers/dtos/customers.ts @@ -1,12 +1,22 @@ import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities'; -import { ApiProperty } from '@nestjs/swagger'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; -export class CustomerDto { +export class CustomerLink implements Link { @ApiProperty() - links: Link[]; + href: string; + @ApiProperty() + name: string; + @ApiProperty() + description: string; + @ApiPropertyOptional() + iconSrc: string; +} +export class CustomerLinkRequest { + @ApiProperty({ type: [CustomerLink] }) + links: CustomerLink[]; } export class CustomerLinksResponse { - @ApiProperty() - links: Link[]; + @ApiProperty({ type: [CustomerLink] }) + links: CustomerLink[]; }