diff --git a/.github/workflows/deploy-manually.yml b/.github/workflows/deploy-manually.yml index 3c8b624..85ce80c 100644 --- a/.github/workflows/deploy-manually.yml +++ b/.github/workflows/deploy-manually.yml @@ -76,7 +76,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Update Pip run: | @@ -146,7 +146,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Extract Docs BlockId and PageId env: @@ -187,3 +187,20 @@ jobs: sed -i -e "s/\${DOCS_PAGE_ID}/$DOCS_PAGE_ID/g" docsfera.json sed -i -e "s/\${DOCS_BLOCK_ID}/$DOCS_BLOCK_ID/g" docsfera.json curl -X POST -H 'Content-Type: application/json' -d @docsfera.json $DOCS_URL + + - name: Generate External API docs + env: + DOCS_URL: ${{ secrets.DOCS_URL }} + DOCS_API_TOKEN: ${{ secrets.DOCS_API_TOKEN }} + DOCS_PAGE_ID: ${{secrets.EXTERNAL_DOCS_PAGE_ID}} + DOCS_BLOCK_ID: ${{secrets.EXTERNAL_DOCS_BLOCK_ID}} + EVENT: ${{ github.event_name }} + RELEASE_VERSION: ${{ needs.semantic_release.outputs.new_release_version }} + run: | + if [ ${EVENT} != "workflow_dispatch" ]; then + sed -i -E "s/(\"title\": )\"Maestro.+\"/\1\"Maestro - $RELEASE_VERSION\"/g" docsfera.external.json + fi + sed -i -e "s/\${DOCS_API_TOKEN}/$DOCS_API_TOKEN/g" docsfera.external.json + sed -i -e "s/\${DOCS_PAGE_ID}/$DOCS_PAGE_ID/g" docsfera.external.json + sed -i -e "s/\${DOCS_BLOCK_ID}/$DOCS_BLOCK_ID/g" docsfera.external.json + curl -X POST -H 'Content-Type: application/json' -d @docsfera.external.json $DOCS_URL diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4193f15..76b8c70 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: runs-on: self-hosted steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build env: diff --git a/README.md b/README.md index ccb4f5b..f5ed2ae 100644 --- a/README.md +++ b/README.md @@ -1,67 +1,98 @@

-

+

# Maestro + Maestro is the Dadosfera's gateway, it's responsible for the communication between the frontend application and Dadosfera's microservices. ## 🚀 Starting + These instructions will allow you to get a working copy of the project on your local machine for development and testing purposes. ### 📋 Requirements + - [NodeJS v18.3.0 LTS / NPM v8.11](https://nodejs.org/pt-br/download/) (you can opt to use [NVM](https://github.com/nvm-sh/nvm) to easily manage node versions) - Request access to AWS Console dev account for **all services** (avoid gradually asking for each needed service. it will slow down your development cycle) - - Create your Access Key on the "Security credentials" menu - - Set the Access Key on your local development machine + - Create your Access Key on the "Security credentials" menu + - Set the Access Key on your local development machine - Request access to the dev, stg and prd VPNs ### 🔧 Installation -- Clone the repository - - SSH - ``` - git clone git@github.com:dadosfera/maestro.git - ``` - or - - HTTPS - ``` - git clone https://github.com/dadosfera/maestro.git - ``` +- Clone the repository + + - SSH + + ``` + git clone git@github.com:dadosfera/maestro.git + ``` + + or + + - HTTPS + ``` + git clone https://github.com/dadosfera/maestro.git + ``` - Select the correct node version (optional, only if using [NVM](https://github.com/nvm-sh/nvm)): - ```sh - nvm use - ``` + + ```sh + nvm use + ``` - Install the project dependencies: - ```sh - npm i - ``` + + ```sh + npm i + ``` - Setup the following enviroment variables: - ``` - ENV= - DUC_URL= - INFACTORY_URL= - OTFACTORY_URL= - PIFACTORY_URL= - SM_OAUTH_PATH= - ``` + + ``` + ENV= + DUC_URL= + INFACTORY_URL= + OTFACTORY_URL= + PIFACTORY_URL= + SM_OAUTH_PATH= + ``` - Start the server: - ```sh - # dev mode - npm run start:dev - # or in debug mode - npm run start:debug - ``` - The service should start successfully. + ```sh + # dev mode + npm run start:dev + + # or in debug mode + npm run start:debug + ``` + + The service should start successfully. + +## 📄 Documentation + +NestJs makes it easy to document each route using decorators on all requests and responses properties. It automatically generates a swagger for given information and provides a route to access it http://localhost:3333/api. +For more info check the [official documentation](https://docs.nestjs.com/openapi/introduction). + +### - Multiple documentations + +We are currently generating **2 different** documentations: Internal and External. + +All routes that have the decorator `@ApiInternalOnly()` will not be visible on the **External** API swagger. + +- When you start the application with `npm run start` it will serve and generate the swagger JSON of the **External** API +- When you start the application with `npm run start:internal` it will serve and generate the swagger JSON of the **Internal** API +- When you run `npm run docs` it will generate the swagger JSON of both **Internal** and **External** API, and save them to `docsfera.json` and `docsfera.external.json` respectively; + +It is important to run `npm run docs` before every deploy so we can always have the most updated docs published. ## Authentication decorators + Maestro have utilities to ease the user authentication on every controller and route. The following decorators are available: ### `@Authenticated` + If the user must be authenticated to make request, we can use the `@Authenticated` decorator in the controller or route, as needed. ```ts @@ -106,6 +137,7 @@ class FooController { ``` ### `@RequireAllPermissions` + This decorator requires that **all permissions** listed are granted to the requesting user. ```ts @@ -125,6 +157,7 @@ class FooController { ``` ### `@RequireSomePermission` + In the following case, the user is required to have **at least one** listed permission. ```ts @@ -144,9 +177,11 @@ class FooController { ``` ### `@AuthenticateCondition` + If a more complicated authentication check needs to be done, we can use the `@AuthenticateCondition` decorator to define it. The custom function must return `true` to authenticate the request. In the following example: + - all routes on the `FooController` controller can only be requested from localhost - `POST /foo/bar` can only be requested from localhost **and** by users from customer id `111...eef` @@ -166,7 +201,10 @@ class FooController { @Post('bar') // allow requests only from a specific customer - @AuthenticateCondition((request: Request, user: RequestUser) => user.customer_id === '1113e943-2187-4fdd-9c2c-54338fedaeef') + @AuthenticateCondition( + (request: Request, user: RequestUser) => + user.customer_id === '1113e943-2187-4fdd-9c2c-54338fedaeef', + ) async postBar() { /* ... */ } @@ -174,51 +212,55 @@ class FooController { ``` ### Note on authentication decorators + - The old authentication method placed the user data in the `request.body.info` field, this imposes certain issues regarding the request body because this data should be from the frontend without any modification by Maestro. Now this usage is ⚠️ **DEPRECATED** ⚠️. We are working to migrate to the `@User` parameter decorator. The old method is working while the migration is in progress. -- Authentication decorators can be used together and all of them **must** pass to the request be authenticated, but in the general case you don't need to (*and wouldn't like to...*) use all of them together, as you can code all of the authentication logic in the `@AuthenticateCondition` decorator. +- Authentication decorators can be used together and all of them **must** pass to the request be authenticated, but in the general case you don't need to (_and wouldn't like to..._) use all of them together, as you can code all of the authentication logic in the `@AuthenticateCondition` decorator. - ```ts - import { - RequireAllPermissions, - RequireSomePermission, - AuthenticateCondition, - } from '../../authentication/authentication.decorator'; - import { PERMISSIONS } from '../../authentication/permissions.enum'; - import { Waa, Baz } from './authenticationFunctions' + ```ts + import { + RequireAllPermissions, + RequireSomePermission, + AuthenticateCondition, + } from '../../authentication/authentication.decorator'; + import { PERMISSIONS } from '../../authentication/permissions.enum'; + import { Waa, Baz } from './authenticationFunctions'; - @Controller('foo') - @RequireAllPermissions(Permissions.FOO.USE, Permissions.FOO.REQUEST) - @RequireSomePermission(Permissions.FOO.MANAGE, Permissions.FOO.ADMIN) - @AuthenticateCondition(Waa) - @AuthenticateCondition(Baz) - class FooController { + @Controller('foo') + @RequireAllPermissions(Permissions.FOO.USE, Permissions.FOO.REQUEST) + @RequireSomePermission(Permissions.FOO.MANAGE, Permissions.FOO.ADMIN) + @AuthenticateCondition(Waa) + @AuthenticateCondition(Baz) + class FooController { + /* ... */ + + @Get('bar') + async getBar() { /* ... */ - - @Get('bar') - async getBar() { - /* ... */ - } - - @Post('bar') - @RequireAllPermissions(Permissions.BAR.MANAGE, Permissions.BAR.USE, Permissions.BAR.REQUEST) - async postBar() { - /* ... */ - } } - ``` + + @Post('bar') + @RequireAllPermissions( + Permissions.BAR.MANAGE, + Permissions.BAR.USE, + Permissions.BAR.REQUEST, + ) + async postBar() { + /* ... */ + } + } + ``` - If `@RequireAllPermissions` and `@RequireSomePermission` are used with **only a single permission**, they present the **exactly same behavior**. - ```ts - // same behavior - @RequireAllPermissions(Permissions.BAR.MANAGE) - @RequireSomePermission(Permissions.BAR.MANAGE) - ``` - - + ```ts + // same behavior + @RequireAllPermissions(Permissions.BAR.MANAGE) + @RequireSomePermission(Permissions.BAR.MANAGE) + ``` ## `@User` parameter decorator + The requesting user data can be obtained using the @User parameter decorator, like in the following snippet: ```ts @@ -264,12 +306,15 @@ class UserController { ``` ## 📦 Development + ### ⌨️ Coding Style + By default, we use [ESLint](https://eslint.org/) + [Prettier](https://prettier.io/) with default settings. **We recommend using Visual Studio Code and installing the recommended extensions to ease the development process.** ### Commits pattern + Our workflow pipeline follows the conventional commits specs ([cheat sheets](https://cheatography.com/albelop/cheat-sheets/conventional-commits/)) to release versions accordingly. Format: `[optional scope]: ` @@ -277,25 +322,29 @@ Format: `[optional scope]: ` Example: `FIX: ensure Range headers adhere more closely to RFC 2616` ### Branching naming convention + - **Feature**: Any code changes for a new module or use case should be done on a feature branch. This branch is created based on the `main` branch. When all changes are done, a Pull Request/Merge Request is needed to put all of these changes back to the `main` branch. Examples: `feature/integrate-swagger`, `feature/JIRA-1234`, `feature/JIRA-1234_support-dark-theme`. - **It is recommended to use all lower caps letters and hyphen (-) to separate words unless it is a specific item name or ID. Underscore (_) could be used to separate the ID and description.** + **It is recommended to use all lower caps letters and hyphen (-) to separate words unless it is a specific item name or ID. Underscore (\_) could be used to separate the ID and description.** -- **Bug Fix**: If the code changes made from the feature branch were rejected after a release, sprint or demo, any necessary fixes after that should be done on the bugfix branch. Examples: `bugfix/more-gray-shades`, `bugfix/JIRA-1444_gray-on-blur-fix`. +- **Bug Fix**: If the code changes made from the feature branch were rejected after a release, sprint or demo, any necessary fixes after that should be done on the bugfix branch. Examples: `bugfix/more-gray-shades`, `bugfix/JIRA-1444_gray-on-blur-fix`. - **Hot Fix**: If there is a need to fix a blocker, do a temporary patch, apply a critical framework or configuration change that should be handled immediately, it should be created as a Hotfix. Examples: `hotfix/disable-endpoint-zero-day-exploit`, `hotfix/increase-scaling-threshold`. - **Experimental**: A branch for playing around. Any new feature or idea that is not part of a release or a sprint. Example: `experimental/dark-theme-support`. ### Making a Pull Request + 1. Commit your changes 2. Open the Pull Request on GitHub 3. Send Pull Request link in Microsfera Google Chat Group for review and possible approval ## 🛠️ Built with + Some technologies used in this project: - [NestJS](https://docs.nestjs.com) - Framework for building efficient and scalable NodeJS server-side applications ## ⚙️ Back-end Architecture + The architecture can be found at [this link](https://sites.google.com/dadosfera.ai/wikidoproduto/time/back-end). diff --git a/docsfera.external.json b/docsfera.external.json new file mode 100644 index 0000000..d850da3 --- /dev/null +++ b/docsfera.external.json @@ -0,0 +1,2809 @@ +{ + "service": "${DOCS_API_TOKEN}", + "pageId": "${DOCS_PAGE_ID}", + "blockId": "${DOCS_BLOCK_ID}", + "schema": { + "openapi": "3.0.0", + "paths": { + "/auth/sign-in": { + "post": { + "operationId": "AuthController_signIn", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthSignInReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthSignInRes" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/refresh-access-token": { + "post": { + "operationId": "AuthController_refreshAccessToken", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthRefreshAccessTokenReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthRefreshAccessTokenRes" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/connections": { + "post": { + "operationId": "ConnectionController_createConnection", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateConnectionDto" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionRes" + } + } + } + } + }, + "tags": [ + "connections" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "get": { + "operationId": "ConnectionController_getAllConnections", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionsRes" + } + } + } + } + }, + "tags": [ + "connections" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/connections/{id}": { + "put": { + "operationId": "ConnectionController_updateConnection", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UpdateConnectionDto" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionRes" + } + } + } + } + }, + "tags": [ + "connections" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "delete": { + "operationId": "ConnectionController_deleteConnection", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionRes" + } + } + } + } + }, + "tags": [ + "connections" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "get": { + "operationId": "ConnectionController_getConnectionDetails", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionDetailsRes" + } + } + } + } + }, + "tags": [ + "connections" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/network-config": { + "get": { + "operationId": "NetworkConfigController_findAllNetworkConfigs", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FindAllNetworkConfigsRes" + } + } + } + } + }, + "tags": [ + "Network Config" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "post": { + "operationId": "NetworkConfigController_createNetworkConfigs", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateNetworkConfigReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateNetworkConfigRes" + } + } + } + }, + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateNetworkConfigRes" + } + } + } + } + }, + "tags": [ + "Network Config" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/network-config/{id}": { + "get": { + "operationId": "NetworkConfigController_findNetworkConfigById", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FindAllNetworkConfigsRes" + } + } + } + } + }, + "tags": [ + "Network Config" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/network-config/{id}/details": { + "get": { + "operationId": "NetworkConfigController_findNetworkConfigByIdDetails", + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FindAllNetworkConfigsRes" + } + } + } + } + }, + "tags": [ + "Network Config" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/inputs": { + "post": { + "operationId": "InputsController_create", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateInputReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Input" + } + } + } + }, + "201": { + "description": "" + } + }, + "tags": [ + "Inputs" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/inputs/{id}": { + "get": { + "operationId": "InputsController_findOne", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Inputs" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2": { + "post": { + "operationId": "PipelinesController_create", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ICreatePipelineV2Req" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IPipelineV2" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "get": { + "operationId": "PipelinesController_findAll", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/download-logs": { + "get": { + "operationId": "PipelinesController_downloadLogs", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "pipeline_run_id", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}/config": { + "get": { + "operationId": "PipelinesController_getPipelineproperties", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}/objects": { + "get": { + "operationId": "PipelinesController_getPipelineObjects", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}/status": { + "get": { + "operationId": "PipelinesController_getPipelineStatus", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}": { + "get": { + "operationId": "PipelinesController_findOne", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "patch": { + "operationId": "PipelinesController_update", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "delete": { + "operationId": "PipelinesController_delete", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/catalog": { + "get": { + "operationId": "CatalogController_searchCatalog", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "Número de registros a ser retornado", + "schema": { + "minimum": 1, + "maximum": 10000, + "type": "number" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "Usado para paginação, em conjunto com `size`", + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "sort_by", + "required": false, + "in": "query", + "description": "Campo do data asset para usar na ordenação. Padrão: `created_at` ", + "schema": { + "type": "string" + } + }, + { + "name": "order", + "required": false, + "in": "query", + "description": "Tipo de ordenação - `asc`: crescente; `desc`: decrescente ", + "schema": { + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ICatalogAllResponse" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "post": { + "operationId": "CatalogController_createDataAsset", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ICreateDataAsset" + } + } + } + }, + "responses": { + "201": { + "description": "" + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/catalog/data-asset/{id}": { + "get": { + "operationId": "CatalogController_getDataAsset", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "shared", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "put": { + "operationId": "CatalogController_updateDataAsset", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IUpdateDataRequest" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IOneDataAsset" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "delete": { + "operationId": "CatalogController_deleteDataAsset", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/catalog/data-asset/{id}/columns-metadata": { + "get": { + "operationId": "CatalogController_getDataAssetColumnsMetadata", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IColumnsMetadataResponse" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/catalog/data-asset/{id}/preview": { + "get": { + "operationId": "CatalogController_getDataAssetPreview", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IPreviewResponse" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/catalog/data-asset/{id}/docs": { + "get": { + "operationId": "CatalogController_getDataAssetDocs", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IDocsResponse" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "post": { + "operationId": "CatalogController_manageDataAssetDocs", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/catalog/data-asset/{id}/comment": { + "post": { + "operationId": "CatalogController_commentOnDataAsset", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IMakeAComment" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "delete": { + "operationId": "CatalogController_deleteComment", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IDeleteComment" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/oauth/hubspot": { + "get": { + "operationId": "OauthController_oauthHubspot", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + }, + "tags": [ + "oauth" + ] + } + }, + "/oauth/googleads": { + "get": { + "operationId": "OauthController_oauthGoogleAds", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + }, + "tags": [ + "oauth" + ] + } + }, + "/oauth/google-sheets": { + "get": { + "operationId": "OauthController_oauthGoogleSheets", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + }, + "tags": [ + "oauth" + ] + } + }, + "/oauth/facebook": { + "get": { + "operationId": "OauthController_oauthFacebook", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + }, + "tags": [ + "oauth" + ] + } + }, + "/oauth/mailchimp": { + "get": { + "operationId": "OauthController_oauthMailchimp", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + }, + "tags": [ + "oauth" + ] + } + }, + "/oauth/salesforce": { + "get": { + "operationId": "OauthController_oauthSalesforce", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "boolean" + } + } + } + } + }, + "tags": [ + "oauth" + ] + } + }, + "/health": { + "get": { + "operationId": "HealthController_check", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Health" + ] + } + } + }, + "info": { + "title": "Maestro - feat/docs-refactor", + "description": "This is the Maestro API", + "version": "1.0.0", + "contact": {} + }, + "tags": [], + "servers": [ + { + "url": "https://maestro.stg.dadosfera.ai", + "description": "Ambiente STG" + }, + { + "url": "https://maestro-2.stg.dadosfera.ai", + "description": "Ambiente STG2" + }, + { + "url": "https://maestro.dadosfera.ai", + "description": "Ambiente PRD" + } + ], + "components": { + "securitySchemes": { + "access-token": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } + }, + "schemas": { + "AuthSignInReq": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "totp": { + "type": "string", + "description": "TOTP code used to login when Multi-Factor Authentication is enabled" + } + }, + "required": [ + "username", + "password" + ] + }, + "AuthCustomer": { + "type": "object", + "properties": { + "modules": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "tier": { + "type": "string" + }, + "scheduleLimit": { + "type": "string" + } + }, + "required": [ + "modules", + "id", + "name", + "tier", + "scheduleLimit" + ] + }, + "AuthUser": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "username": { + "type": "string" + }, + "createdAt": { + "type": "string" + } + }, + "required": [ + "id", + "name", + "username", + "createdAt" + ] + }, + "AuthTokens": { + "type": "object", + "properties": { + "accessToken": { + "type": "string" + }, + "refreshToken": { + "type": "string" + }, + "termsOfUseToken": { + "type": "string" + }, + "idToken": { + "type": "string", + "deprecated": true + } + }, + "required": [ + "accessToken", + "refreshToken", + "idToken" + ] + }, + "TermsOfUse": { + "type": "object", + "properties": { + "version": { + "type": "number" + }, + "publicUrl": { + "type": "string" + }, + "enforceDate": { + "type": "string" + }, + "createdAt": { + "type": "string" + } + }, + "required": [ + "version", + "publicUrl", + "enforceDate", + "createdAt" + ] + }, + "TermsOfUseStatus": { + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "pending", + "required", + "ok" + ] + }, + "lastSigned": { + "$ref": "#/components/schemas/TermsOfUse" + }, + "next": { + "$ref": "#/components/schemas/TermsOfUse" + } + }, + "required": [ + "status" + ] + }, + "AuthSignInRes": { + "type": "object", + "properties": { + "permissions": { + "type": "array", + "items": { + "type": "string" + } + }, + "mfaStatus": { + "type": "string", + "enum": [ + "pending", + "none", + "totp" + ] + }, + "customer": { + "$ref": "#/components/schemas/AuthCustomer" + }, + "user": { + "$ref": "#/components/schemas/AuthUser" + }, + "tokens": { + "$ref": "#/components/schemas/AuthTokens" + }, + "termsOfUse": { + "$ref": "#/components/schemas/TermsOfUseStatus" + } + }, + "required": [ + "permissions", + "mfaStatus" + ] + }, + "AuthRefreshAccessTokenReq": { + "type": "object", + "properties": { + "refreshToken": { + "type": "string" + }, + "customerName": { + "type": "string" + } + }, + "required": [ + "refreshToken", + "customerName" + ] + }, + "AuthRefreshAccessTokenRes": { + "type": "object", + "properties": { + "permissions": { + "type": "array", + "items": { + "type": "string" + } + }, + "accessToken": { + "type": "string" + } + }, + "required": [ + "permissions", + "accessToken" + ] + }, + "CreateConnectionDto": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string" + }, + "network_config_id": { + "type": "string" + }, + "properties": { + "type": "object" + }, + "connector_id": { + "type": "string" + }, + "connector_name": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "image_url": { + "type": "string" + } + }, + "required": [ + "name", + "description", + "type", + "properties", + "connector_id", + "connector_name", + "plugin", + "image_url" + ] + }, + "ConnectionToCatalogDto": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string" + }, + "network_config_id": { + "type": "string" + }, + "connector_id": { + "type": "string" + }, + "connector_name": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "image_url": { + "type": "string" + } + }, + "required": [ + "name", + "description", + "type", + "connector_id", + "connector_name", + "plugin", + "image_url" + ] + }, + "ConnectionRes": { + "type": "object", + "properties": { + "connection": { + "$ref": "#/components/schemas/ConnectionToCatalogDto" + }, + "message": { + "type": "string" + } + }, + "required": [ + "connection", + "message" + ] + }, + "UpdateConnectionDto": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "network_config_id": { + "type": "string" + }, + "properties": { + "type": "object" + } + }, + "required": [ + "name", + "description", + "properties" + ] + }, + "ConnectionsRes": { + "type": "object", + "properties": { + "connections": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConnectionToCatalogDto" + } + }, + "message": { + "type": "string" + } + }, + "required": [ + "connections", + "message" + ] + }, + "ConnectionDto": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "customer_id": { + "type": "string" + }, + "customer_name": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "pipelines": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string" + }, + "network_config_id": { + "type": "string" + }, + "properties": { + "type": "object" + }, + "connector_id": { + "type": "string" + }, + "connector_name": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "image_url": { + "type": "string" + } + }, + "required": [ + "id", + "customer_id", + "customer_name", + "user_id", + "updated_at", + "created_at", + "pipelines", + "name", + "description", + "type", + "properties", + "connector_id", + "connector_name", + "plugin", + "image_url" + ] + }, + "ConnectionDetailsRes": { + "type": "object", + "properties": { + "connection": { + "$ref": "#/components/schemas/ConnectionDto" + }, + "message": { + "type": "string" + } + }, + "required": [ + "connection", + "message" + ] + }, + "NetworkConfigToCatalogDto": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "customer_id": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "type": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "network_type_id": { + "type": "string" + }, + "network_type_name": { + "type": "string" + } + }, + "required": [ + "id", + "customer_id", + "plugin", + "type", + "name", + "description", + "created_at", + "updated_at", + "network_type_id", + "network_type_name" + ] + }, + "FindAllNetworkConfigsRes": { + "type": "object", + "properties": { + "network_configs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NetworkConfigToCatalogDto" + } + }, + "message": { + "type": "string" + } + }, + "required": [ + "network_configs", + "message" + ] + }, + "CreateNetworkConfigReq": { + "type": "object", + "properties": { + "network_type_id": { + "type": "string" + }, + "network_type_name": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "ovpn_file": { + "type": "string", + "format": "binary" + } + }, + "required": [ + "network_type_id", + "network_type_name", + "name", + "description", + "ovpn_file" + ] + }, + "CreateNetworkConfigRes": { + "type": "object", + "properties": { + "network_config": { + "$ref": "#/components/schemas/NetworkConfigToCatalogDto" + } + }, + "required": [ + "network_config" + ] + }, + "TableColumns": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { + "type": "string" + } + }, + "references": { + "type": "array", + "items": { + "type": "string" + } + }, + "type": { + "type": "string" + } + }, + "required": [ + "name", + "columns", + "references", + "type" + ] + }, + "CreateInputReq": { + "type": "object", + "properties": { + "tables": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TableColumns" + } + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "tables", + "name", + "description", + "plugin" + ] + }, + "Input": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "tables": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TableColumns" + } + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "type": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + }, + "required": [ + "id", + "tables", + "name", + "description", + "plugin", + "created_at", + "updated_at" + ] + }, + "ICreatePipelineV2Req": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "connection_id": { + "type": "string" + }, + "cron": { + "type": "string" + }, + "input_id": { + "type": "string" + }, + "transformations_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "properties": { + "type": "object" + }, + "connector_name": { + "type": "string" + }, + "connector_plugin": { + "type": "string" + }, + "connector_version": { + "type": "string" + }, + "image_url": { + "type": "string" + } + }, + "required": [ + "name", + "description", + "connection_id", + "cron", + "connector_name", + "connector_plugin", + "connector_version", + "image_url" + ] + }, + "IPipelineV2": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "connection_id": { + "type": "string" + }, + "cron": { + "type": "string" + }, + "input_id": { + "type": "string" + }, + "transformations_ids": { + "type": "array", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "properties": { + "type": "object" + }, + "connector_name": { + "type": "string" + }, + "connector_plugin": { + "type": "string" + }, + "connector_version": { + "type": "string" + }, + "image_url": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "updated_at": { + "type": "string" + } + }, + "required": [ + "id", + "name", + "description", + "connection_id", + "cron", + "connector_name", + "connector_plugin", + "connector_version", + "image_url", + "created_at", + "updated_at" + ] + }, + "IRole": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "name", + "id" + ] + }, + "IUser": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "id": { + "type": "string" + } + }, + "required": [ + "username", + "id" + ] + }, + "IComment": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "message": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "username": { + "type": "string" + } + }, + "required": [ + "id", + "message", + "created_at", + "username" + ] + }, + "EmbedObject": { + "type": "object", + "properties": { + "url": { + "type": "string" + } + }, + "required": [ + "url" + ] + }, + "IDataAsset": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "database_name": { + "type": "string" + }, + "table_name": { + "type": "string" + }, + "num_columns": { + "type": "number" + }, + "location": { + "type": "string" + }, + "created_time": { + "type": "string" + }, + "table_type": { + "type": "string" + }, + "size_in_bytes": { + "type": "number" + }, + "num_files": { + "type": "number" + }, + "data_encrypted": { + "type": "string" + }, + "num_rows": { + "type": "number" + }, + "display_name": { + "type": "string" + }, + "pipeline_id": { + "type": "string" + }, + "user_id": { + "type": "string" + }, + "description": { + "type": "string" + }, + "data_asset_type": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "owner": { + "type": "string" + }, + "roles": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IRole" + } + }, + "users": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IUser" + } + }, + "dashboard_id": { + "type": "number" + }, + "name": { + "type": "string" + }, + "parameters": { + "type": "array", + "items": { + "type": "string" + } + }, + "embedding_params": { + "type": "object" + }, + "created_at": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "comments": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IComment" + } + }, + "embed": { + "$ref": "#/components/schemas/EmbedObject" + }, + "share_type": { + "type": "string", + "enum": [ + "none", + "public", + "private" + ] + } + }, + "required": [ + "id", + "display_name", + "pipeline_id", + "user_id", + "description", + "data_asset_type", + "tags", + "owner", + "roles", + "users", + "created_at", + "comments" + ] + }, + "ICatalogAllResponse": { + "type": "object", + "properties": { + "data_assets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IDataAsset" + } + }, + "total": { + "type": "number" + } + }, + "required": [ + "data_assets", + "total" + ] + }, + "IColumnMetadata": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "table_name": { + "type": "string" + }, + "column_name": { + "type": "string" + }, + "data_type": { + "type": "string" + }, + "missing_count": { + "type": "string" + }, + "min": { + "type": "string" + }, + "max": { + "type": "string" + }, + "count": { + "type": "string" + }, + "histogram": { + "type": "string" + }, + "mean": { + "type": "string" + }, + "median": { + "type": "string" + }, + "missing_rate": { + "type": "string" + }, + "stddev": { + "type": "string" + }, + "unique_count": { + "type": "string" + }, + "unique_rate": { + "type": "string" + }, + "analyzer_rules": { + "type": "array", + "items": { + "type": "string" + } + }, + "version": { + "type": "string" + } + }, + "required": [ + "id", + "table_name", + "column_name", + "data_type", + "missing_count", + "min", + "max", + "count", + "histogram", + "mean", + "median", + "missing_rate", + "stddev", + "unique_count", + "unique_rate", + "analyzer_rules", + "version" + ] + }, + "IColumnsMetadataResponse": { + "type": "object", + "properties": { + "columns_metadata": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IColumnMetadata" + } + } + }, + "required": [ + "columns_metadata" + ] + }, + "IData": { + "type": "object", + "properties": { + "var": { + "type": "number" + }, + "date": { + "type": "string" + }, + "last": { + "type": "number" + }, + "maximum": { + "type": "number" + }, + "minimum": { + "type": "number" + }, + "day_opening": { + "type": "number" + } + }, + "required": [ + "var", + "date", + "last", + "maximum", + "minimum", + "day_opening" + ] + }, + "IPreview": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "database_name": { + "type": "string" + }, + "table_name": { + "type": "string" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/IData" + } + } + }, + "required": [ + "id", + "database_name", + "table_name", + "data" + ] + }, + "IPreviewResponse": { + "type": "object", + "properties": { + "preview": { + "$ref": "#/components/schemas/IPreview" + } + }, + "required": [ + "preview" + ] + }, + "IDocs": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "docs": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "table_id": { + "type": "string" + } + }, + "required": [ + "id", + "docs", + "updated_at", + "table_id" + ] + }, + "IDocsResponse": { + "type": "object", + "properties": { + "docs": { + "$ref": "#/components/schemas/IDocs" + } + }, + "required": [ + "docs" + ] + }, + "IUpdateDataRequest": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "tags": { + "type": "array", + "items": { + "type": "string" + } + }, + "embed": { + "$ref": "#/components/schemas/EmbedObject" + }, + "share_type": { + "type": "string", + "enum": [ + "none", + "public", + "private" + ] + } + }, + "required": [ + "name", + "description", + "tags" + ] + }, + "IOneDataAsset": { + "type": "object", + "properties": { + "data_asset": { + "$ref": "#/components/schemas/IDataAsset" + } + }, + "required": [ + "data_asset" + ] + }, + "ICreateDataAsset": { + "type": "object", + "properties": { + "display_name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "data_asset_type": { + "type": "string" + }, + "external_url": { + "type": "string" + }, + "location": { + "type": "string" + }, + "embed": { + "$ref": "#/components/schemas/EmbedObject" + } + }, + "required": [ + "display_name", + "description", + "data_asset_type", + "external_url", + "location" + ] + }, + "IMakeAComment": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + }, + "required": [ + "message" + ] + }, + "CommentToDelete": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "username": { + "type": "string" + } + }, + "required": [ + "id", + "username" + ] + }, + "IDeleteComment": { + "type": "object", + "properties": { + "comment": { + "$ref": "#/components/schemas/CommentToDelete" + } + }, + "required": [ + "comment" + ] + } + } + } + } +} \ No newline at end of file diff --git a/docsfera.json b/docsfera.json index 0864d1a..dee5148 100644 --- a/docsfera.json +++ b/docsfera.json @@ -10,10 +10,14 @@ "operationId": "AuthController_signIn", "parameters": [ { - "name": "Dadosfera-Lang", - "required": true, + "name": "dadosfera-lang", "in": "header", + "required": false, "schema": { + "enum": [ + "pt-br", + "en-us" + ], "type": "string" } } @@ -45,36 +49,19 @@ ] } }, - "/auth/sso/snowflake": { - "post": { - "operationId": "AuthController_snowflakeSignIn", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, "/auth/refresh-access-token": { "post": { "operationId": "AuthController_refreshAccessToken", "parameters": [ { - "name": "Dadosfera-Lang", - "required": true, + "name": "dadosfera-lang", "in": "header", + "required": false, "schema": { + "enum": [ + "pt-br", + "en-us" + ], "type": "string" } } @@ -95,7 +82,7 @@ "content": { "application/json": { "schema": { - "type": "object" + "$ref": "#/components/schemas/AuthRefreshAccessTokenRes" } } } @@ -106,10 +93,62 @@ ] } }, + "/auth/sso/snowflake": { + "post": { + "operationId": "AuthController_snowflakeSignIn", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, "/auth/change-password": { "post": { "operationId": "AuthController_changePassword", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -130,7 +169,20 @@ "/auth/reset-password": { "post": { "operationId": "AuthController_resetPassword", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -151,7 +203,20 @@ "/auth/verify-reset-password-code": { "post": { "operationId": "AuthController_verifyResetPasswordCode", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -172,7 +237,20 @@ "/auth/confirm-reset-password": { "post": { "operationId": "AuthController_confirmResetPassword", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -193,7 +271,20 @@ "/auth/enable-totp": { "post": { "operationId": "AuthController_enableTotpMFA", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -214,7 +305,20 @@ "/auth/disable-totp": { "post": { "operationId": "AuthController_disableTotpMFA", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -235,7 +339,20 @@ "/auth/dismiss-totp": { "post": { "operationId": "AuthController_dismissTotpMFA", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -256,7 +373,20 @@ "/auth/verify-totp": { "post": { "operationId": "AuthController_verifyTotp", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -277,7 +407,20 @@ "/auth/verify-access-token": { "get": { "operationId": "AuthController_verifyAccessToken", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "" @@ -285,6 +428,14 @@ }, "tags": [ "Auth" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -292,6 +443,18 @@ "get": { "operationId": "AuthController_getSession", "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, { "name": "session", "required": true, @@ -321,7 +484,20 @@ "/auth/oauth/google": { "get": { "operationId": "AuthController_googleOauth", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -342,403 +518,10 @@ "/auth/oauth/google/callback": { "get": { "operationId": "AuthController_googleOauthCallback", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "Auth" - ] - } - }, - "/connectors": { - "post": { - "operationId": "ConnectorController_uploadConnector", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/CreateConnectorDto" - } - } - } - }, - "responses": { - "201": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - }, - "get": { - "operationId": "ConnectorController_getAllConnectors", - "parameters": [ - { - "name": "search", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "language", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "size", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - }, - { - "name": "page", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/uploads": { - "post": { - "operationId": "ConnectorController_uploadFile", - "parameters": [], - "responses": { - "201": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "type": "object" - } - } - } - } - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/multiple-connectors-upload": { - "post": { - "operationId": "ConnectorController_uploadConnectorsFile", - "parameters": [], - "responses": { - "201": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/tags": { - "get": { - "operationId": "ConnectorController_getConnectorsTags", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/{plugin}": { - "get": { - "operationId": "ConnectorController_getConnector", - "parameters": [ - { - "name": "plugin", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - }, - { - "name": "version", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - }, - "put": { - "operationId": "ConnectorController_updateConnector", - "parameters": [ - { - "name": "plugin", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "multipart/form-data": { - "schema": { - "$ref": "#/components/schemas/UpdateDto" - } - } - } - }, - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - }, - "delete": { - "operationId": "ConnectorController_deleteConnector", - "parameters": [ - { - "name": "plugin", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - }, - { - "name": "version", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/{plugin}/details": { - "get": { - "operationId": "ConnectorController_getConnectorDetails", - "parameters": [ - { - "name": "plugin", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - }, - { - "name": "version", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/{plugin}/add-tag": { - "put": { - "operationId": "ConnectorController_addTagOnConnector", - "parameters": [ - { - "name": "plugin", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AddTagDto" - } - } - } - }, - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/connectors/{plugin}/remove-tag": { - "put": { - "operationId": "ConnectorController_removeTagOnConnector", - "parameters": [ - { - "name": "plugin", - "required": true, - "in": "path", - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RemoveTagDto" - } - } - } - }, - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "connectors" - ], - "security": [ - { - "bearer": [] - } - ] - } - }, - "/permissions": { - "get": { - "operationId": "PermissionsController_getPublicPermissions", "parameters": [ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -749,99 +532,13 @@ } } ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetPublicPermissionsRes" - } - } - } - } - }, - "tags": [ - "Permissions" - ] - } - }, - "/terms-of-use/token": { - "get": { - "operationId": "TermsOfUseController_getToken", - "parameters": [ - { - "name": "Dadosfera-Lang", - "required": true, - "in": "header", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "TermsOfUse" - ] - } - }, - "/terms-of-use/accept": { - "post": { - "operationId": "TermsOfUseController_accept", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "TermsOfUse" - ] - } - }, - "/connections/connections-migration": { - "get": { - "operationId": "ConnectionController_synchronizeConnections", - "parameters": [ - { - "name": "apply", - "required": true, - "in": "query", - "schema": { - "type": "string" - } - } - ], "responses": { "200": { "description": "" } }, "tags": [ - "connections" - ], - "security": [ - { - "bearer": [] - } + "Auth" ] } }, @@ -876,7 +573,10 @@ ], "security": [ { - "bearer": [] + "access-token": [] + }, + { + "access-token": [] } ] }, @@ -900,7 +600,7 @@ ], "security": [ { - "bearer": [] + "access-token": [] } ] } @@ -909,14 +609,6 @@ "put": { "operationId": "ConnectionController_updateConnection", "parameters": [ - { - "name": "Dadosfera-Lang", - "required": true, - "in": "header", - "schema": { - "type": "string" - } - }, { "name": "id", "required": true, @@ -953,7 +645,10 @@ ], "security": [ { - "bearer": [] + "access-token": [] + }, + { + "access-token": [] } ] }, @@ -986,7 +681,10 @@ ], "security": [ { - "bearer": [] + "access-token": [] + }, + { + "access-token": [] } ] }, @@ -1010,7 +708,7 @@ ], "security": [ { - "bearer": [] + "access-token": [] } ] } @@ -1022,7 +720,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1047,6 +744,11 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + } ] }, "post": { @@ -1055,7 +757,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1090,6 +791,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1100,7 +809,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1125,6 +833,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1135,7 +851,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1160,6 +875,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1170,7 +893,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1195,6 +917,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1205,7 +935,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1238,6 +967,11 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + } ] }, "delete": { @@ -1246,7 +980,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1279,6 +1012,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "patch": { @@ -1287,7 +1028,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1330,6 +1070,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1340,7 +1088,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1375,6 +1122,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1385,7 +1140,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1418,6 +1172,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1428,7 +1190,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1469,6 +1230,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "put": { @@ -1477,7 +1246,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1512,6 +1280,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1522,7 +1298,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1557,6 +1332,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1567,7 +1350,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1610,6 +1392,14 @@ }, "tags": [ "Users" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1620,7 +1410,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1679,6 +1468,11 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + } ] }, "post": { @@ -1687,7 +1481,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1722,6 +1515,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1732,7 +1533,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1767,6 +1567,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "delete": { @@ -1775,7 +1583,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1810,6 +1617,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "patch": { @@ -1818,7 +1633,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1853,6 +1667,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1863,7 +1685,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1898,6 +1719,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -1908,7 +1737,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1941,6 +1769,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "delete": { @@ -1949,7 +1785,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -1982,6 +1817,14 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "patch": { @@ -1990,7 +1833,6 @@ { "name": "dadosfera-lang", "in": "header", - "description": "Defaults to pt-br", "required": false, "schema": { "enum": [ @@ -2033,6 +1875,465 @@ }, "tags": [ "Roles" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/permissions": { + "get": { + "operationId": "PermissionsController_getPublicPermissions", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "description": "Defaults to pt-br", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetPublicPermissionsRes" + } + } + } + } + }, + "tags": [ + "Permissions" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/connectors": { + "post": { + "operationId": "ConnectorController_uploadConnector", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/CreateConnectorDto" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "get": { + "operationId": "ConnectorController_getAllConnectors", + "parameters": [ + { + "name": "search", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "language", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "size", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "page", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/uploads": { + "post": { + "operationId": "ConnectorController_uploadFile", + "parameters": [], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/multiple-connectors-upload": { + "post": { + "operationId": "ConnectorController_uploadConnectorsFile", + "parameters": [], + "responses": { + "201": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/tags": { + "get": { + "operationId": "ConnectorController_getConnectorsTags", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/{plugin}": { + "get": { + "operationId": "ConnectorController_getConnector", + "parameters": [ + { + "name": "plugin", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, + { + "name": "version", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "put": { + "operationId": "ConnectorController_updateConnector", + "parameters": [ + { + "name": "plugin", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "multipart/form-data": { + "schema": { + "$ref": "#/components/schemas/UpdateDto" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + }, + "delete": { + "operationId": "ConnectorController_deleteConnector", + "parameters": [ + { + "name": "plugin", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, + { + "name": "version", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/{plugin}/details": { + "get": { + "operationId": "ConnectorController_getConnectorDetails", + "parameters": [ + { + "name": "plugin", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, + { + "name": "version", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/{plugin}/add-tag": { + "put": { + "operationId": "ConnectorController_addTagOnConnector", + "parameters": [ + { + "name": "plugin", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AddTagDto" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/connectors/{plugin}/remove-tag": { + "put": { + "operationId": "ConnectorController_removeTagOnConnector", + "parameters": [ + { + "name": "plugin", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RemoveTagDto" + } + } + } + }, + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "connectors" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -2054,6 +2355,11 @@ }, "tags": [ "Network Config" + ], + "security": [ + { + "access-token": [] + } ] }, "post": { @@ -2093,6 +2399,14 @@ }, "tags": [ "Network Config" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -2123,6 +2437,11 @@ }, "tags": [ "Network Config" + ], + "security": [ + { + "access-token": [] + } ] } }, @@ -2153,445 +2472,11 @@ }, "tags": [ "Network Config" - ] - } - }, - "/connection-test/ping": { - "post": { - "operationId": "ConnectionTestController_connectionTestPing", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestPingReq" - } - } + ], + "security": [ + { + "access-token": [] } - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestPingRes" - } - } - } - } - }, - "tags": [ - "Connection Test" - ] - } - }, - "/connection-test/credentials": { - "post": { - "operationId": "ConnectionTestController_connectionTestCredentials", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestCredentialsReq" - } - } - } - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestCredentialsRes" - } - } - } - } - }, - "tags": [ - "Connection Test" - ] - } - }, - "/connection-test/schemas": { - "post": { - "operationId": "ConnectionTestController_connectionTestListSchemas", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestListSchemasReq" - } - } - } - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestListSchemasRes" - } - } - } - } - }, - "tags": [ - "Connection Test" - ] - } - }, - "/connection-test/tables": { - "post": { - "operationId": "ConnectionTestController_connectionTestListTables", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestListTablesReq" - } - } - } - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ConnectionTestListTablesRes" - } - } - } - } - }, - "tags": [ - "Connection Test" - ] - } - }, - "/connection-test/table-metadata": { - "post": { - "operationId": "ConnectionTestController_getTableMetadata", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetTableMetadataReq" - } - } - } - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GetTableMetadataRes" - } - } - } - } - }, - "tags": [ - "Connection Test" - ] - } - }, - "/pipelines/start/{id}": { - "post": { - "operationId": "PipelinesController_activate", - "parameters": [], - "responses": { - "201": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Pipelines" - ] - } - }, - "/pipelines/{id}/status": { - "get": { - "operationId": "PipelinesController_getPipelineStatus", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Pipelines" - ] - } - }, - "/pipelinesV2": { - "post": { - "operationId": "PipelinesController_create", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ICreatePipelineV2Req" - } - } - } - }, - "responses": { - "201": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IPipelineV2" - } - } - } - } - }, - "tags": [ - "PipelinesV2" - ] - }, - "get": { - "operationId": "PipelinesController_findAll", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/download-logs": { - "get": { - "operationId": "PipelinesController_downloadLogs", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/{id}/config": { - "get": { - "operationId": "PipelinesController_getPipelineproperties", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/{id}/objects": { - "get": { - "operationId": "PipelinesController_getPipelineObjects", - "parameters": [], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/{id}": { - "get": { - "operationId": "PipelinesController_findOne", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "PipelinesV2" - ] - }, - "put": { - "operationId": "PipelinesController_update", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "PipelinesV2" - ] - }, - "patch": { - "operationId": "PipelinesController_updateByPatch", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "PipelinesV2" - ] - }, - "delete": { - "operationId": "PipelinesController_delete", - "parameters": [], - "responses": { - "204": { - "description": "" - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/init-upload": { - "post": { - "operationId": "PipelinesController_initUploadFile", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/IInitUploadCSVFile" - } - } - } - }, - "responses": { - "201": { - "description": "" - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/complete-upload": { - "post": { - "operationId": "PipelinesController_completeUploadFile", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ICompleteUploadCSVFile" - } - } - } - }, - "responses": { - "201": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "PipelinesV2" - ] - } - }, - "/pipelinesV2/file": { - "post": { - "operationId": "PipelinesController_uploadedFile", - "parameters": [], - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ICreatePipelineCSVFile" - } - } - } - }, - "responses": { - "201": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "PipelinesV2" ] } }, @@ -2622,6 +2507,11 @@ }, "tags": [ "Inputs" + ], + "security": [ + { + "access-token": [] + } ] } }, @@ -2656,6 +2546,11 @@ }, "tags": [ "Inputs" + ], + "security": [ + { + "access-token": [] + } ] }, "get": { @@ -2668,6 +2563,11 @@ }, "tags": [ "Inputs" + ], + "security": [ + { + "access-token": [] + } ] } }, @@ -2689,6 +2589,11 @@ }, "tags": [ "Inputs" + ], + "security": [ + { + "access-token": [] + } ] }, "patch": { @@ -2708,6 +2613,11 @@ }, "tags": [ "Inputs" + ], + "security": [ + { + "access-token": [] + } ] }, "delete": { @@ -2727,6 +2637,631 @@ }, "tags": [ "Inputs" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2": { + "post": { + "operationId": "PipelinesController_create", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ICreatePipelineV2Req" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IPipelineV2" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "get": { + "operationId": "PipelinesController_findAll", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/download-logs": { + "get": { + "operationId": "PipelinesController_downloadLogs", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "pipeline_run_id", + "required": true, + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}/config": { + "get": { + "operationId": "PipelinesController_getPipelineproperties", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}/objects": { + "get": { + "operationId": "PipelinesController_getPipelineObjects", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}/status": { + "get": { + "operationId": "PipelinesController_getPipelineStatus", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/{id}": { + "get": { + "operationId": "PipelinesController_findOne", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "patch": { + "operationId": "PipelinesController_update", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "put": { + "operationId": "PipelinesController_updateDeprecated", + "summary": "", + "deprecated": true, + "description": "This method is deprecated. Please use PATCH instead", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + }, + "delete": { + "operationId": "PipelinesController_delete", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/init-upload": { + "post": { + "operationId": "PipelinesController_initUploadFile", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/IInitUploadCSVFile" + } + } + } + }, + "responses": { + "201": { + "description": "" + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/complete-upload": { + "post": { + "operationId": "PipelinesController_completeUploadFile", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ICompleteUploadCSVFile" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/file": { + "post": { + "operationId": "PipelinesController_uploadedFile", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ICreatePipelineCSVFile" + } + } + } + }, + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/pipelinesV2/start/{id}": { + "post": { + "operationId": "PipelinesController_activate", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "PipelinesV2" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/pipelines/start/{id}": { + "post": { + "operationId": "PipelinesController_activate", + "summary": "", + "deprecated": true, + "description": "This method is deprecated. Please use route /pipelinesV2/start/:id instead", + "parameters": [], + "responses": { + "201": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Pipelines" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/pipelines/{id}/status": { + "get": { + "operationId": "PipelinesController_getPipelineStatus", + "summary": "", + "deprecated": true, + "description": "This method is deprecated. Please use route /pipelinesV2/:id/status instead", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Pipelines" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -2741,6 +3276,14 @@ }, "tags": [ "Transformations" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "get": { @@ -2753,6 +3296,14 @@ }, "tags": [ "Transformations" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -2774,6 +3325,14 @@ }, "tags": [ "Transformations" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "put": { @@ -2802,6 +3361,14 @@ }, "tags": [ "Transformations" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "delete": { @@ -2821,27 +3388,78 @@ }, "tags": [ "Transformations" - ] - } - }, - "/health": { - "get": { - "operationId": "HealthController_check", - "parameters": [], - "responses": { - "200": { - "description": "" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] } - }, - "tags": [ - "Health" ] } }, "/catalog": { "get": { "operationId": "CatalogController_searchCatalog", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "size", + "required": false, + "in": "query", + "description": "Número de registros a ser retornado", + "schema": { + "minimum": 1, + "maximum": 10000, + "type": "number" + } + }, + { + "name": "page", + "required": false, + "in": "query", + "description": "Usado para paginação, em conjunto com `size`", + "schema": { + "minimum": 1, + "type": "number" + } + }, + { + "name": "sort_by", + "required": false, + "in": "query", + "description": "Campo do data asset para usar na ordenação. Padrão: `created_at` ", + "schema": { + "type": "string" + } + }, + { + "name": "order", + "required": false, + "in": "query", + "description": "Tipo de ordenação - `asc`: crescente; `desc`: decrescente ", + "schema": { + "default": "asc", + "enum": [ + "asc", + "desc" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -2856,11 +3474,32 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "post": { "operationId": "CatalogController_createDataAsset", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "requestBody": { "required": true, "content": { @@ -2878,13 +3517,34 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, "/catalog/data-asset": { "get": { "operationId": "CatalogController_findByPipelineAndObject", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "" @@ -2892,13 +3552,31 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + } ] } }, "/catalog/tags": { "get": { "operationId": "CatalogController_findAllTags", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -2913,6 +3591,14 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -2920,6 +3606,18 @@ "get": { "operationId": "CatalogController_getDataAsset", "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, { "name": "shared", "required": true, @@ -2936,11 +3634,32 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "put": { "operationId": "CatalogController_updateDataAsset", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "requestBody": { "required": true, "content": { @@ -2965,11 +3684,31 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "delete": { "operationId": "CatalogController_deleteDataAsset", "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, { "name": "id", "required": true, @@ -2993,13 +3732,34 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, "/catalog/data-asset/rls/{id}": { "get": { "operationId": "CatalogController_getDataAssetRls", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "" @@ -3007,13 +3767,34 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, "/catalog/data-asset/{id}/columns-metadata": { "get": { "operationId": "CatalogController_getDataAssetColumnsMetadata", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -3028,13 +3809,34 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, "/catalog/data-asset/{id}/preview": { "get": { "operationId": "CatalogController_getDataAssetPreview", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -3049,13 +3851,34 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, "/catalog/data-asset/{id}/docs": { "get": { "operationId": "CatalogController_getDataAssetDocs", - "parameters": [], + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -3070,11 +3893,31 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "post": { "operationId": "CatalogController_manageDataAssetDocs", "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, { "name": "id", "required": true, @@ -3098,6 +3941,14 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] } }, @@ -3106,28 +3957,17 @@ "operationId": "CatalogController_manageDataAssetPermissions", "parameters": [ { - "name": "id", - "required": true, - "in": "path", + "name": "dadosfera-lang", + "in": "header", + "required": false, "schema": { + "enum": [ + "pt-br", + "en-us" + ], "type": "string" } - } - ], - "responses": { - "200": { - "description": "" - } - }, - "tags": [ - "Catalog" - ] - } - }, - "/catalog/data-asset/{id}/revoke-permissions": { - "put": { - "operationId": "CatalogController_revokeDataAssetPermissions", - "parameters": [ + }, { "name": "id", "required": true, @@ -3144,6 +3984,51 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/catalog/data-asset/{id}/revoke-permissions": { + "put": { + "operationId": "CatalogController_revokeDataAssetPermissions", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Catalog" + ], + "security": [ + { + "access-token": [] + } ] } }, @@ -3151,6 +4036,18 @@ "post": { "operationId": "CatalogController_commentOnDataAsset", "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, { "name": "id", "required": true, @@ -3184,11 +4081,31 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } ] }, "delete": { "operationId": "CatalogController_deleteComment", "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + }, { "name": "id", "required": true, @@ -3222,6 +4139,262 @@ }, "tags": [ "Catalog" + ], + "security": [ + { + "access-token": [] + }, + { + "access-token": [] + } + ] + } + }, + "/terms-of-use/token": { + "get": { + "operationId": "TermsOfUseController_getToken", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "TermsOfUse" + ] + } + }, + "/terms-of-use/accept": { + "post": { + "operationId": "TermsOfUseController_accept", + "parameters": [ + { + "name": "dadosfera-lang", + "in": "header", + "required": false, + "schema": { + "enum": [ + "pt-br", + "en-us" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "TermsOfUse" + ] + } + }, + "/connection-test/ping": { + "post": { + "operationId": "ConnectionTestController_connectionTestPing", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestPingReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestPingRes" + } + } + } + } + }, + "tags": [ + "Connection Test" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/connection-test/credentials": { + "post": { + "operationId": "ConnectionTestController_connectionTestCredentials", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestCredentialsReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestCredentialsRes" + } + } + } + } + }, + "tags": [ + "Connection Test" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/connection-test/schemas": { + "post": { + "operationId": "ConnectionTestController_connectionTestListSchemas", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestListSchemasReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestListSchemasRes" + } + } + } + } + }, + "tags": [ + "Connection Test" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/connection-test/tables": { + "post": { + "operationId": "ConnectionTestController_connectionTestListTables", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestListTablesReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ConnectionTestListTablesRes" + } + } + } + } + }, + "tags": [ + "Connection Test" + ], + "security": [ + { + "access-token": [] + } + ] + } + }, + "/connection-test/table-metadata": { + "post": { + "operationId": "ConnectionTestController_getTableMetadata", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetTableMetadataReq" + } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/GetTableMetadataRes" + } + } + } + } + }, + "tags": [ + "Connection Test" + ], + "security": [ + { + "access-token": [] + } ] } }, @@ -3463,6 +4636,11 @@ }, "tags": [ "Productboard" + ], + "security": [ + { + "access-token": [] + } ] } }, @@ -3474,24 +4652,56 @@ "201": { "description": "" } - } + }, + "security": [ + { + "access-token": [] + } + ] + } + }, + "/health": { + "get": { + "operationId": "HealthController_check", + "parameters": [], + "responses": { + "200": { + "description": "" + } + }, + "tags": [ + "Health" + ] } } }, "info": { - "title": "Maestro - main", - "description": "Documentation for Maestro gateway", + "title": "Maestro - feat/docs-refactor", + "description": "This is the Maestro API", "version": "1.0.0", "contact": {} }, "tags": [], - "servers": [], + "servers": [ + { + "url": "https://maestro.stg.dadosfera.ai", + "description": "Ambiente STG" + }, + { + "url": "https://maestro-2.stg.dadosfera.ai", + "description": "Ambiente STG2" + }, + { + "url": "https://maestro.dadosfera.ai", + "description": "Ambiente PRD" + } + ], "components": { "securitySchemes": { - "Authorization": { - "scheme": "bearer", - "bearerFormat": "JWT", - "type": "http" + "access-token": { + "type": "apiKey", + "name": "Authorization", + "in": "header" } }, "schemas": { @@ -3505,7 +4715,8 @@ "type": "string" }, "totp": { - "type": "string" + "type": "string", + "description": "TOTP code used to login when Multi-Factor Authentication is enabled" } }, "required": [ @@ -3684,135 +4895,22 @@ "customerName" ] }, - "CreateConnectorDto": { + "AuthRefreshAccessTokenRes": { "type": "object", "properties": { - "file": { - "type": "string", - "format": "binary" - }, - "connector": { - "type": "string" - } - }, - "required": [ - "file", - "connector" - ] - }, - "UpdateDto": { - "type": "object", - "properties": { - "file": { - "type": "string", - "format": "binary" - }, - "version": { - "type": "string" - }, - "category": { - "type": "string" - }, - "plugin": { - "type": "string" - }, - "image": { - "type": "string" - }, - "docs": { - "type": "string" - }, - "name": { - "type": "string" - }, - "options": { - "type": "object", - "description": "skip_select_entities: boolean skip_select_columns: boolean;" - }, - "connection_controls": { - "type": "array", - "items": { - "properties": {} - } - } - }, - "required": [ - "version" - ] - }, - "AddTagDto": { - "type": "object", - "properties": { - "tags": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "tags" - ] - }, - "RemoveTagDto": { - "type": "object", - "properties": { - "tags": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "tags" - ] - }, - "PermissionGroupPermission": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "id": { - "type": "number" - } - }, - "required": [ - "name", - "id" - ] - }, - "PermissionGroup": { - "type": "object", - "properties": { - "title": { - "type": "string" - }, "permissions": { "type": "array", "items": { - "$ref": "#/components/schemas/PermissionGroupPermission" + "type": "string" } + }, + "accessToken": { + "type": "string" } }, "required": [ - "title", - "permissions" - ] - }, - "GetPublicPermissionsRes": { - "type": "object", - "properties": { - "permissionGroups": { - "type": "array", - "items": { - "$ref": "#/components/schemas/PermissionGroup" - } - } - }, - "required": [ - "permissionGroups" + "permissions", + "accessToken" ] }, "CreateConnectionDto": { @@ -4873,6 +5971,137 @@ "role" ] }, + "PermissionGroupPermission": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "id": { + "type": "number" + } + }, + "required": [ + "name", + "id" + ] + }, + "PermissionGroup": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "permissions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PermissionGroupPermission" + } + } + }, + "required": [ + "title", + "permissions" + ] + }, + "GetPublicPermissionsRes": { + "type": "object", + "properties": { + "permissionGroups": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PermissionGroup" + } + } + }, + "required": [ + "permissionGroups" + ] + }, + "CreateConnectorDto": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "connector": { + "type": "string" + } + }, + "required": [ + "file", + "connector" + ] + }, + "UpdateDto": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + }, + "version": { + "type": "string" + }, + "category": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "image": { + "type": "string" + }, + "docs": { + "type": "string" + }, + "name": { + "type": "string" + }, + "options": { + "type": "object", + "description": "skip_select_entities: boolean skip_select_columns: boolean;" + }, + "connection_controls": { + "type": "array", + "items": { + "properties": {} + } + } + }, + "required": [ + "version" + ] + }, + "AddTagDto": { + "type": "object", + "properties": { + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "tags" + ] + }, + "RemoveTagDto": { + "type": "object", + "properties": { + "tags": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "tags" + ] + }, "NetworkConfigToCatalogDto": { "type": "object", "properties": { @@ -4977,276 +6206,135 @@ "network_config" ] }, - "ConnectionTestPingReq": { + "AvailableEntity": { "type": "object", "properties": { - "plugin": { + "name": { "type": "string" }, - "host": { - "type": "string" - }, - "port": { - "type": "number" - }, - "network_config_id": { - "type": "string" - }, - "connection_id": { - "type": "string" - } - } - }, - "ConnectionTestPingRes": { - "type": "object", - "properties": { - "operation_result": { - "type": "boolean" + "replication_methods": { + "type": "array", + "items": { + "type": "string" + } } }, "required": [ - "operation_result" + "name", + "replication_methods" ] }, - "ConnectionTestCredentialsProperties": { + "GetAvailableEntitiesRes": { "type": "object", "properties": { - "host": { + "entities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AvailableEntity" + } + } + }, + "required": [ + "entities" + ] + }, + "TableColumns": { + "type": "object", + "properties": { + "name": { "type": "string" }, - "port": { - "type": "string" + "columns": { + "type": "array", + "items": { + "type": "string" + } }, - "username": { - "type": "string" + "references": { + "type": "array", + "items": { + "type": "string" + } }, - "password": { - "type": "string" - }, - "database": { + "type": { "type": "string" } }, "required": [ - "host", - "port", - "username", - "password", - "database" + "name", + "columns", + "references", + "type" ] }, - "ConnectionTestCredentialsReq": { + "CreateInputReq": { "type": "object", "properties": { + "tables": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TableColumns" + } + }, "name": { "type": "string" }, "description": { "type": "string" }, + "plugin": { + "type": "string" + }, "type": { "type": "string" - }, - "network_config_id": { - "type": "string" - }, - "connector_id": { - "type": "string" - }, - "connector_name": { - "type": "string" - }, - "plugin": { - "type": "string" - }, - "image_url": { - "type": "string" - }, - "properties": { - "$ref": "#/components/schemas/ConnectionTestCredentialsProperties" - }, - "connection_id": { - "type": "string" } }, "required": [ + "tables", "name", "description", - "type", - "connector_id", - "connector_name", - "plugin", - "image_url", - "properties" + "plugin" ] }, - "ConnectionTestCredentialsRes": { + "Input": { "type": "object", "properties": { - "operation_result": { - "type": "boolean" - }, - "connection_id": { - "type": "string" - } - }, - "required": [ - "operation_result", - "connection_id" - ] - }, - "ConnectionTestListSchemasReq": { - "type": "object", - "properties": { - "plugin": { + "id": { "type": "string" }, - "connection_id": { - "type": "string" - } - }, - "required": [ - "plugin", - "connection_id" - ] - }, - "ConnectionTestListSchemasRes": { - "type": "object", - "properties": { - "operation_result": { - "type": "boolean" - }, - "schema_list": { + "tables": { "type": "array", "items": { - "type": "string" + "$ref": "#/components/schemas/TableColumns" } - } - }, - "required": [ - "operation_result", - "schema_list" - ] - }, - "ConnectionTestListTablesReq": { - "type": "object", - "properties": { - "plugin": { - "type": "string" }, - "connection_id": { - "type": "string" - }, - "schema": { - "type": "string" - } - }, - "required": [ - "plugin", - "connection_id", - "schema" - ] - }, - "ConnectionTestListTablesRes": { - "type": "object", - "properties": { - "operation_result": { - "type": "boolean" - }, - "table_list": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "operation_result", - "table_list" - ] - }, - "GetTableMetadataReq": { - "type": "object", - "properties": { - "connection_id": { - "type": "string" - }, - "plugin": { - "type": "string" - }, - "schema": { - "type": "string" - }, - "table_list": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "connection_id", - "plugin", - "schema", - "table_list" - ] - }, - "ColumnDto": { - "type": "object", - "properties": { "name": { "type": "string" }, + "description": { + "type": "string" + }, + "plugin": { + "type": "string" + }, "type": { "type": "string" - } - }, - "required": [ - "name", - "type" - ] - }, - "TableMetadataDto": { - "type": "object", - "properties": { - "table_name": { + }, + "created_at": { "type": "string" }, - "columns": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ColumnDto" - } - }, - "references": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ColumnDto" - } + "updated_at": { + "type": "string" } }, "required": [ - "table_name", - "columns", - "references" - ] - }, - "GetTableMetadataRes": { - "type": "object", - "properties": { - "operation_result": { - "type": "boolean" - }, - "tables_metadata": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TableMetadataDto" - } - } - }, - "required": [ - "operation_result", - "tables_metadata" + "id", + "tables", + "name", + "description", + "plugin", + "created_at", + "updated_at" ] }, "ICreatePipelineV2Req": { @@ -5443,137 +6531,6 @@ "header" ] }, - "AvailableEntity": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "replication_methods": { - "type": "array", - "items": { - "type": "string" - } - } - }, - "required": [ - "name", - "replication_methods" - ] - }, - "GetAvailableEntitiesRes": { - "type": "object", - "properties": { - "entities": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AvailableEntity" - } - } - }, - "required": [ - "entities" - ] - }, - "TableColumns": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "columns": { - "type": "array", - "items": { - "type": "string" - } - }, - "references": { - "type": "array", - "items": { - "type": "string" - } - }, - "type": { - "type": "string" - } - }, - "required": [ - "name", - "columns", - "references", - "type" - ] - }, - "CreateInputReq": { - "type": "object", - "properties": { - "tables": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TableColumns" - } - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "plugin": { - "type": "string" - }, - "type": { - "type": "string" - } - }, - "required": [ - "tables", - "name", - "description", - "plugin" - ] - }, - "Input": { - "type": "object", - "properties": { - "id": { - "type": "string" - }, - "tables": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TableColumns" - } - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "plugin": { - "type": "string" - }, - "type": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "updated_at": { - "type": "string" - } - }, - "required": [ - "id", - "tables", - "name", - "description", - "plugin", - "created_at", - "updated_at" - ] - }, "IRole": { "type": "object", "properties": { @@ -5739,6 +6696,14 @@ }, "embed": { "$ref": "#/components/schemas/EmbedObject" + }, + "share_type": { + "type": "string", + "enum": [ + "none", + "public", + "private" + ] } }, "required": [ @@ -6053,17 +7018,304 @@ "message" ] }, + "CommentToDelete": { + "type": "object", + "properties": { + "id": { + "type": "number" + }, + "username": { + "type": "string" + } + }, + "required": [ + "id", + "username" + ] + }, "IDeleteComment": { "type": "object", "properties": { "comment": { - "$ref": "#/components/schemas/IComment" + "$ref": "#/components/schemas/CommentToDelete" } }, "required": [ "comment" ] }, + "ConnectionTestPingReq": { + "type": "object", + "properties": { + "plugin": { + "type": "string" + }, + "host": { + "type": "string" + }, + "port": { + "type": "number" + }, + "network_config_id": { + "type": "string" + }, + "connection_id": { + "type": "string" + } + } + }, + "ConnectionTestPingRes": { + "type": "object", + "properties": { + "operation_result": { + "type": "boolean" + } + }, + "required": [ + "operation_result" + ] + }, + "ConnectionTestCredentialsProperties": { + "type": "object", + "properties": { + "host": { + "type": "string" + }, + "port": { + "type": "string" + }, + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "database": { + "type": "string" + } + }, + "required": [ + "host", + "port", + "username", + "password", + "database" + ] + }, + "ConnectionTestCredentialsReq": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string" + }, + "network_config_id": { + "type": "string" + }, + "connector_id": { + "type": "string" + }, + "connector_name": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "image_url": { + "type": "string" + }, + "properties": { + "$ref": "#/components/schemas/ConnectionTestCredentialsProperties" + }, + "connection_id": { + "type": "string" + } + }, + "required": [ + "name", + "description", + "type", + "connector_id", + "connector_name", + "plugin", + "image_url", + "properties" + ] + }, + "ConnectionTestCredentialsRes": { + "type": "object", + "properties": { + "operation_result": { + "type": "boolean" + }, + "connection_id": { + "type": "string" + } + }, + "required": [ + "operation_result", + "connection_id" + ] + }, + "ConnectionTestListSchemasReq": { + "type": "object", + "properties": { + "plugin": { + "type": "string" + }, + "connection_id": { + "type": "string" + } + }, + "required": [ + "plugin", + "connection_id" + ] + }, + "ConnectionTestListSchemasRes": { + "type": "object", + "properties": { + "operation_result": { + "type": "boolean" + }, + "schema_list": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "operation_result", + "schema_list" + ] + }, + "ConnectionTestListTablesReq": { + "type": "object", + "properties": { + "plugin": { + "type": "string" + }, + "connection_id": { + "type": "string" + }, + "schema": { + "type": "string" + } + }, + "required": [ + "plugin", + "connection_id", + "schema" + ] + }, + "ConnectionTestListTablesRes": { + "type": "object", + "properties": { + "operation_result": { + "type": "boolean" + }, + "table_list": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "operation_result", + "table_list" + ] + }, + "GetTableMetadataReq": { + "type": "object", + "properties": { + "connection_id": { + "type": "string" + }, + "plugin": { + "type": "string" + }, + "schema": { + "type": "string" + }, + "table_list": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "connection_id", + "plugin", + "schema", + "table_list" + ] + }, + "ColumnDto": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + } + }, + "required": [ + "name", + "type" + ] + }, + "TableMetadataDto": { + "type": "object", + "properties": { + "table_name": { + "type": "string" + }, + "columns": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ColumnDto" + } + }, + "references": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ColumnDto" + } + } + }, + "required": [ + "table_name", + "columns", + "references" + ] + }, + "GetTableMetadataRes": { + "type": "object", + "properties": { + "operation_result": { + "type": "boolean" + }, + "tables_metadata": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TableMetadataDto" + } + } + }, + "required": [ + "operation_result", + "tables_metadata" + ] + }, "INote": { "type": "object", "properties": { diff --git a/environment.d.ts b/environment.d.ts new file mode 100644 index 0000000..727c484 --- /dev/null +++ b/environment.d.ts @@ -0,0 +1,18 @@ +declare global { + namespace NodeJS { + interface ProcessEnv { + NODE_ENV: 'test'; + ENV: 'local' | 'stg' | 'prd' | 'test'; + LOCAL_ENV: 'stg' | 'prd'; + + DUC_URL: string; + INFACTORY_URL: string; + PIFACTORY_URL: string; + + INTERNAL_SWAGGER: 'true' | 'false'; + + AWS_REGION: string; + } + } +} +export {}; diff --git a/package.json b/package.json index 4eaa62a..b829842 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "build": "nest build", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"", "start": "nest start", - "start:dev": "nest start --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "npm run build && node dist/main", + "start:dev": "export INTERNAL_SWAGGER=true && nest start --watch", + "start:debug": "npm run start:dev", + "start:prod": "node dist/main", + "docs": "export KILL_AFTER_START=1 && nest start && export INTERNAL_SWAGGER=true && nest start", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", @@ -95,4 +96,4 @@ "tsconfig-paths": "^3.14.1", "typescript": "^4.6.3" } -} +} \ No newline at end of file diff --git a/src/app.module.ts b/src/app.module.ts index d736888..22ea09a 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -40,24 +40,24 @@ import { MixpanelModule } from './modules/mixpanel/mixpanel.module'; isGlobal: true, }), AuthModule, + ConnectionModule, + NetworkConfigModule, + InputsModule, + PipelinesV2Module, + CatalogModule, ConnectorModule, PermissionsModule, TermsOfUseModule, - ConnectionModule, - NetworkConfigModule, ConnectionTestModule, PipelinesModule, - PipelinesV2Module, TransformationsModule, - HealthModule, - CatalogModule, UsersModule, RolesModule, - InputsModule, OauthModule, - CatalogModule, ProductboardModule, MixpanelModule, + //Always leave HealthModule last, so it is on the bottom of swagger + HealthModule, ], }) export class AppModule {} diff --git a/src/authentication/authentication.decorator.ts b/src/authentication/authentication.decorator.ts deleted file mode 100644 index 5bebd81..0000000 --- a/src/authentication/authentication.decorator.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { Request } from 'express'; -import { CustomDecorator } from '@nestjs/common'; -import { PermissionsObjectPermission } from './permissions.enum'; -import { RequestUser } from './user.decorator'; - -export const AUTH_FUNCTION_KEY = '__AUTH_FUNCTION__'; - -export type AuthenticationFunction = (req: Request, user: any) => boolean; - -// implementation copied from SetMetadata, but tweaked to get existing values -// of the metadataKey and accumulate it with the new metadataValue -function SetMultipleMetadata(metadataKey, metadataValue): CustomDecorator { - const decoratorFactory = (target, key, descriptor) => { - // .start: tweak - // descriptor?.value = function decorator; target = class decorator - const accumulatedVal = - Reflect.getMetadata(metadataKey, descriptor?.value ?? target) ?? []; - accumulatedVal.push(metadataValue); - // .end: tweak - - if (descriptor) { - Reflect.defineMetadata(metadataKey, accumulatedVal, descriptor.value); - return descriptor; - } - - Reflect.defineMetadata(metadataKey, accumulatedVal, target); - return target; - }; - - decoratorFactory.KEY = metadataKey; - return decoratorFactory as any; -} - -export function RequireAllPermissions( - ...permissions: PermissionsObjectPermission[] -) { - return SetMultipleMetadata(AUTH_FUNCTION_KEY, (req, user: RequestUser) => - permissions.every(({ seqid }) => user.permissions.includes(seqid)), - ); -} - -export function RequireSomePermission( - ...permissions: PermissionsObjectPermission[] -) { - return SetMultipleMetadata(AUTH_FUNCTION_KEY, (req, user: RequestUser) => - permissions.some(({ seqid }) => user.permissions.includes(seqid)), - ); -} - -export function AuthenticateCondition(func: AuthenticationFunction) { - return SetMultipleMetadata(AUTH_FUNCTION_KEY, func); -} - -export function Authenticated() { - return SetMultipleMetadata(AUTH_FUNCTION_KEY, () => true); -} diff --git a/src/authentication/authentication.guard.spec.ts b/src/authentication/authentication.guard.spec.ts index 8edac59..0aa983e 100644 --- a/src/authentication/authentication.guard.spec.ts +++ b/src/authentication/authentication.guard.spec.ts @@ -11,7 +11,7 @@ import { Authenticated, RequireAllPermissions, RequireSomePermission, -} from './authentication.decorator'; +} from '../decorators/authentication.decorator'; import { AuthenticationGuard } from './authentication.guard'; import { PERMISSIONS_GROUPS } from './permissions.enum'; import { AuthClientService } from '../modules/auth/auth.service'; diff --git a/src/authentication/authentication.guard.ts b/src/authentication/authentication.guard.ts index 44b3a75..7e938b0 100644 --- a/src/authentication/authentication.guard.ts +++ b/src/authentication/authentication.guard.ts @@ -13,8 +13,8 @@ import { AuthClientService } from '../modules/auth/auth.service'; import { AuthenticationFunction, AUTH_FUNCTION_KEY, -} from './authentication.decorator'; -import { RequestUser } from './user.decorator'; +} from '../decorators/authentication.decorator'; +import { RequestUser } from '../decorators/user.decorator'; import ErrorBuilder from '../utils/ErrorBuilder'; import ErrorCodes from '../utils/errorCodes'; diff --git a/src/decorators/authentication.decorator.ts b/src/decorators/authentication.decorator.ts new file mode 100644 index 0000000..385ced0 --- /dev/null +++ b/src/decorators/authentication.decorator.ts @@ -0,0 +1,41 @@ +import { applyDecorators } from '@nestjs/common'; +import { ApiSecurity } from '@nestjs/swagger'; +import { type Request } from 'express'; +import { type PermissionsObjectPermission } from '../authentication/permissions.enum'; +import { type RequestUser } from './user.decorator'; +import { SetMultipleMetadata } from './shared'; + +export const AUTH_FUNCTION_KEY = '__AUTH_FUNCTION__'; + +export type AuthenticationFunction = (req: Request, user: any) => boolean; + +export function RequireAllPermissions( + ...permissions: PermissionsObjectPermission[] +) { + return createAuthenticatedDecorator((req, user: RequestUser) => + permissions.every(({ seqid }) => user.permissions.includes(seqid)), + ); +} + +export function RequireSomePermission( + ...permissions: PermissionsObjectPermission[] +) { + return createAuthenticatedDecorator((req, user: RequestUser) => + permissions.some(({ seqid }) => user.permissions.includes(seqid)), + ); +} + +export function AuthenticateCondition(func: AuthenticationFunction) { + return createAuthenticatedDecorator(func); +} + +export function Authenticated() { + return createAuthenticatedDecorator(() => true); +} + +function createAuthenticatedDecorator(metadataValue: AuthenticationFunction) { + return applyDecorators( + ApiSecurity('access-token'), + SetMultipleMetadata(AUTH_FUNCTION_KEY, metadataValue), + ); +} diff --git a/src/decorators/language.decorator.ts b/src/decorators/language.decorator.ts new file mode 100644 index 0000000..f455200 --- /dev/null +++ b/src/decorators/language.decorator.ts @@ -0,0 +1,25 @@ +import { createParamDecorator, type ExecutionContext } from '@nestjs/common'; +import { LanguageEnum } from 'src/utils/languages.enum'; + +export const Language: () => ParameterDecorator = createParamDecorator( + (options: any, ctx: ExecutionContext): LanguageEnum => { + const headers = ctx.switchToHttp()?.getRequest()?.headers; + + if (!headers) return LanguageEnum.ptbr; + + let language: LanguageEnum = + headers['dadosfera-lang'] ?? headers['accept-language']; + language = language?.toLowerCase().trim() as LanguageEnum; + + if (!language) return LanguageEnum.ptbr; + + Object.values(LanguageEnum).some((l) => { + if (language === l || l.includes(language)) { + language = l; + return true; + } + language = LanguageEnum.enus; + }); + return language; + }, +); diff --git a/src/decorators/shared.ts b/src/decorators/shared.ts new file mode 100644 index 0000000..9d4f659 --- /dev/null +++ b/src/decorators/shared.ts @@ -0,0 +1,28 @@ +import { type CustomDecorator } from '@nestjs/common'; + +// implementation copied from SetMetadata, but tweaked to get existing values +// of the metadataKey and accumulate it with the new metadataValue +export function SetMultipleMetadata( + metadataKey, + metadataValue, +): CustomDecorator { + const decoratorFactory: CustomDecorator = (target, key?, descriptor?) => { + // .start: tweak + // descriptor?.value = function decorator; target = class decorator + const accumulatedVal = + Reflect.getMetadata(metadataKey, descriptor?.value ?? target) ?? []; + accumulatedVal.push(metadataValue); + // .end: tweak + + if (descriptor) { + Reflect.defineMetadata(metadataKey, accumulatedVal, descriptor.value); + return descriptor; + } + + Reflect.defineMetadata(metadataKey, accumulatedVal, target); + return target; + }; + + decoratorFactory.KEY = metadataKey; + return decoratorFactory; +} diff --git a/src/decorators/swagger.decorator.ts b/src/decorators/swagger.decorator.ts new file mode 100644 index 0000000..342eb69 --- /dev/null +++ b/src/decorators/swagger.decorator.ts @@ -0,0 +1,13 @@ +import { applyDecorators } from '@nestjs/common'; +import { ApiExcludeController, ApiExcludeEndpoint } from '@nestjs/swagger'; + +export function ApiInternalOnlyEndpoint() { + if (process.env.INTERNAL_SWAGGER !== 'true') + return applyDecorators(ApiExcludeEndpoint()); + return () => null; +} +export function ApiInternalOnlyController() { + if (process.env.INTERNAL_SWAGGER !== 'true') + return applyDecorators(ApiExcludeController()); + return () => null; +} diff --git a/src/authentication/user.decorator.spec.ts b/src/decorators/user.decorator.spec.ts similarity index 95% rename from src/authentication/user.decorator.spec.ts rename to src/decorators/user.decorator.spec.ts index c1a041a..90488f3 100644 --- a/src/authentication/user.decorator.spec.ts +++ b/src/decorators/user.decorator.spec.ts @@ -1,17 +1,14 @@ -import request from 'supertest'; -import { Test } from '@nestjs/testing'; -import { HttpStatus, INestApplication } from '@nestjs/common'; -import { APP_GUARD } from '@nestjs/core'; -import jwt from 'jsonwebtoken'; - -import { Controller, Get } from '@nestjs/common'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; -import { AuthenticationGuard } from './authentication.guard'; +import { Controller, Get, HttpStatus, INestApplication } from '@nestjs/common'; +import { APP_GUARD } from '@nestjs/core'; +import { Test } from '@nestjs/testing'; +import jwt from 'jsonwebtoken'; +import request from 'supertest'; +import { AuthenticationGuard } from '../authentication/authentication.guard'; +import { PERMISSIONS_GROUPS } from '../authentication/permissions.enum'; import { AuthClientService } from '../modules/auth/auth.service'; - import ErrorCodes from '../utils/errorCodes'; import { User } from './user.decorator'; -import { PERMISSIONS_GROUPS } from './permissions.enum'; const logger = { info: (...args) => args, diff --git a/src/authentication/user.decorator.ts b/src/decorators/user.decorator.ts similarity index 89% rename from src/authentication/user.decorator.ts rename to src/decorators/user.decorator.ts index bdec568..94b6045 100644 --- a/src/authentication/user.decorator.ts +++ b/src/decorators/user.decorator.ts @@ -1,4 +1,4 @@ -import { createParamDecorator, ExecutionContext } from '@nestjs/common'; +import { createParamDecorator, type ExecutionContext } from '@nestjs/common'; import ErrorBuilder from '../utils/ErrorBuilder'; import ErrorCodes from '../utils/errorCodes'; diff --git a/src/main.ts b/src/main.ts index 7235e3b..728022b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,11 +24,10 @@ async function bootstrap() { optionsSuccessStatus: 204, }, }); - app.use(helmet()); configureSwagger(app); - await app.listen(3333); + if (process.env.KILL_AFTER_START) await app.close(); } function configureSwagger(app: INestApplication) { @@ -39,24 +38,35 @@ function configureSwagger(app: INestApplication) { .replace('\n', '') .trim(); } catch (error) { - console.log("Can't get branch name", error); + console.warn("Can't get branch name", error); } const swaggerTitle = branchName ? `Maestro - ${branchName}` : 'Maestro'; const config = new DocumentBuilder() .setTitle(swaggerTitle) .setDescription('Documentation for Maestro gateway') - .addBearerAuth( - { type: 'http', scheme: 'bearer', bearerFormat: 'JWT' }, - 'Authorization', - ) + .addSecurity('access-token', { + type: 'apiKey', + name: 'Authorization', + in: 'header', + }) + .setDescription('This is the Maestro API') + .addServer('https://maestro.stg.dadosfera.ai', 'Ambiente STG') + .addServer('https://maestro-2.stg.dadosfera.ai', 'Ambiente STG2') + .addServer('https://maestro.dadosfera.ai', 'Ambiente PRD') .build(); const document = SwaggerModule.createDocument(app, config); + const swaggerJsonFile = + process.env.INTERNAL_SWAGGER === 'true' + ? 'docsfera.json' + : 'docsfera.external.json'; + if (process.env.ENV === 'local') SwaggerModule.setup('api', app, document); + writeFileSync( - 'docsfera.json', + swaggerJsonFile, JSON.stringify( { service: '${DOCS_API_TOKEN}', diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index e7682ac..1097d51 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -13,7 +13,12 @@ import { Req, Param, } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +import { + ApiHeaders, + ApiOkResponse, + ApiSecurity, + ApiTags, +} from '@nestjs/swagger'; import { AuthChangePasswordRequest, AuthResetPasswordRequest, @@ -28,13 +33,14 @@ import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; import { Authenticated, RequireAllPermissions, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { AuthClientService } from './auth.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { AuthRefreshAccessTokenReq, + AuthRefreshAccessTokenRes, AuthSignInReq, AuthSignInRes, } from './dtos/login'; @@ -43,8 +49,12 @@ import { AuthGuard } from '@nestjs/passport'; import { Request } from 'express'; import ErrorCodes, { OauthErrors } from 'src/utils/errorCodes'; import jwt from 'jsonwebtoken'; +import { LanguageEnum } from 'src/utils/languages.enum'; +import { Language } from 'src/decorators/language.decorator'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; @ApiTags('Auth') +@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) @UseFilters(new GrpcToHttpExceptionFilter()) @Controller('auth') export class AuthController { @@ -74,13 +84,32 @@ export class AuthController { @HttpCode(HttpStatus.OK) async signIn( @Body() { username, password, totp }: AuthSignInReq, - @Headers('Dadosfera-Lang') language: string, + @Language() language: LanguageEnum, ): Promise { this.logger.info('/auth - SignIn'); - const metadata = PackTheMetadata({ language: language || 'pt-br' }); + const metadata = PackTheMetadata({ language }); return this.authClient.signIn({ username, password, totp }, metadata); } + @Post('refresh-access-token') + @HttpCode(HttpStatus.OK) + @ApiOkResponse({ type: AuthRefreshAccessTokenRes }) + async refreshAccessToken( + @Body() body: AuthRefreshAccessTokenReq, + @Language() language: LanguageEnum, + ) { + this.logger.info('/auth - RefreshAccessToken'); + const { refreshToken, customerName: customer_name } = body; + + const metadata = PackTheMetadata({ + customer_name, + language, + }); + + return this.authClient.refreshAccessToken({ refreshToken }, metadata); + } + + @ApiInternalOnlyEndpoint() @Post('/sso/snowflake') @RequireAllPermissions(PERMISSIONS_GROUPS.SNOWFLAKE.permissions.OPEN) @HttpCode(HttpStatus.OK) @@ -96,23 +125,7 @@ export class AuthController { }); } - @Post('refresh-access-token') - @HttpCode(HttpStatus.OK) - async refreshAccessToken( - @Body() - { refreshToken, customerName: customer_name }: AuthRefreshAccessTokenReq, - @Headers('Dadosfera-Lang') language: string, - ) { - this.logger.info('/auth - RefreshAccessToken'); - - const metadata = PackTheMetadata({ - customer_name, - language, - }); - - return this.authClient.refreshAccessToken({ refreshToken }, metadata); - } - + @ApiInternalOnlyEndpoint() @Post('change-password') @HttpCode(HttpStatus.OK) async changePassword( @@ -131,11 +144,12 @@ export class AuthController { }); } + @ApiInternalOnlyEndpoint() @Post('reset-password') @HttpCode(HttpStatus.OK) async resetPassword( @Body() body: AuthResetPasswordRequest, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('/auth - reset-password'); const metadata = PackTheMetadata({ @@ -147,6 +161,7 @@ export class AuthController { return this.authClient.resetPassword({ username }, metadata); } + @ApiInternalOnlyEndpoint() @Post('verify-reset-password-code') @HttpCode(HttpStatus.OK) async verifyResetPasswordCode( @@ -159,6 +174,7 @@ export class AuthController { return this.authClient.verifyResetPasswordCode({ username, code }); } + @ApiInternalOnlyEndpoint() @Post('confirm-reset-password') @HttpCode(HttpStatus.OK) async confirmResetPassword(@Body() body: AuthConfirmResetPasswordRequest) { @@ -173,6 +189,7 @@ export class AuthController { }); } + @ApiInternalOnlyEndpoint() @Post('enable-totp') @HttpCode(HttpStatus.OK) async enableTotpMFA( @@ -187,6 +204,7 @@ export class AuthController { return this.authClient.enableTotpMFA({ accessToken, password }); } + @ApiInternalOnlyEndpoint() @Post('disable-totp') @HttpCode(HttpStatus.OK) async disableTotpMFA( @@ -201,6 +219,7 @@ export class AuthController { return this.authClient.disableTotpMFA({ accessToken, password }); } + @ApiInternalOnlyEndpoint() @Post('dismiss-totp') @HttpCode(HttpStatus.OK) async dismissTotpMFA(@Headers() headers) { @@ -211,6 +230,7 @@ export class AuthController { return this.authClient.dismissTotpMFA({ accessToken }); } + @ApiInternalOnlyEndpoint() @Post('verify-totp') @HttpCode(HttpStatus.OK) async verifyTotp(@Body() body: AuthVerifyTotpMfaRequest, @Headers() headers) { @@ -222,17 +242,21 @@ export class AuthController { return this.authClient.verifyTotp({ accessToken, totp }); } + @ApiInternalOnlyEndpoint() @Authenticated() + @ApiSecurity('access-token') @Get('verify-access-token') verifyAccessToken() { return { access_token_status: 'valid' }; } + @ApiInternalOnlyEndpoint() @Get('session/:session') getSession(@Param('session') session: string) { return this.authClient.getSession(session); } + @ApiInternalOnlyEndpoint() @Get('oauth/google') @UseGuards(AuthGuard('google-login')) googleOauth() { @@ -240,6 +264,7 @@ export class AuthController { return true; } + @ApiInternalOnlyEndpoint() @Get('oauth/google/callback') @UseGuards(AuthGuard('google-login')) @Redirect() diff --git a/src/modules/auth/dtos/login.ts b/src/modules/auth/dtos/login.ts index a41d8f3..eae2b64 100644 --- a/src/modules/auth/dtos/login.ts +++ b/src/modules/auth/dtos/login.ts @@ -81,7 +81,10 @@ export class AuthSignInReq implements AuthSignInRequest { username: string; @ApiProperty() password: string; - @ApiPropertyOptional() + @ApiPropertyOptional({ + description: + 'TOTP code used to login when Multi-Factor Authentication is enabled', + }) totp: string; } @@ -106,3 +109,9 @@ export class AuthRefreshAccessTokenReq { @ApiProperty() customerName: string; } +export class AuthRefreshAccessTokenRes { + @ApiProperty() + permissions: string[]; + @ApiProperty() + accessToken: string; +} diff --git a/src/modules/catalog/catalog.controller.ts b/src/modules/catalog/catalog.controller.ts index 71f69f3..6583726 100644 --- a/src/modules/catalog/catalog.controller.ts +++ b/src/modules/catalog/catalog.controller.ts @@ -6,7 +6,6 @@ import { ForbiddenException, Get, Headers, - HttpException, Inject, NotFoundException, Param, @@ -15,17 +14,18 @@ import { Query, UseFilters, } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiHeaders, ApiTags } from '@nestjs/swagger'; import { Authenticated, RequireSomePermission, -} from '../../authentication/authentication.decorator'; +} from '../../decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; import { CatalogService } from './catalog.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { + ICatalogAllRequest, ICatalogAllResponse, IColumnsMetadataResponse, ICreateDataAsset, @@ -37,8 +37,12 @@ import { IUpdateDataRequest, } from './dtos'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; +import { Language } from 'src/decorators/language.decorator'; +import { LanguageEnum } from 'src/utils/languages.enum'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; @ApiTags('Catalog') +@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) @Controller('catalog') @UseFilters(new GrpcToHttpExceptionFilter()) @Authenticated() @@ -59,7 +63,7 @@ export class CatalogController { ) async searchCatalog( @User() user: RequestUser, - @Query() query, + @Query() query: ICatalogAllRequest, ): Promise { const { user_id, customer_name, customer_id, username, permissions } = user; this.logger.info(`/catalog - searchCatalog`, { @@ -91,6 +95,7 @@ export class CatalogController { return res; } + @ApiInternalOnlyEndpoint() @Get('data-asset') async findByPipelineAndObject(@User() user: RequestUser, @Query() query) { const { username, user_id, customer_id, customer_name, permissions } = user; @@ -144,6 +149,7 @@ export class CatalogController { ); } + @ApiInternalOnlyEndpoint() @Get('tags') @RequireSomePermission( PERMISSIONS_GROUPS.CATALOG.permissions.GET, @@ -222,6 +228,7 @@ export class CatalogController { return { data_asset }; } + @ApiInternalOnlyEndpoint() @Get('data-asset/rls/:id') @RequireSomePermission( PERMISSIONS_GROUPS.CATALOG.permissions.GET, @@ -284,7 +291,7 @@ export class CatalogController { ) async getDataAssetColumnsMetadata( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Param('id') id, ): Promise { const { customer_name, customer_id, user_id, username } = user; @@ -315,7 +322,7 @@ export class CatalogController { ) async getDataAssetPreview( @User() user: RequestUser, - @Headers('Dadosfera-lang') language, + @Language() language: LanguageEnum, @Param('id') id, ): Promise { const { customer_name, customer_id, user_id, username } = user; @@ -345,7 +352,7 @@ export class CatalogController { ) async getDataAssetDocs( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Param('id') id, ): Promise { const { customer_name, customer_id, user_id, username } = user; @@ -375,7 +382,7 @@ export class CatalogController { ) async updateDataAsset( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Param('id') data_asset_id, @Body() body: IUpdateDataRequest, ): Promise { @@ -430,6 +437,7 @@ export class CatalogController { return res; } + @ApiInternalOnlyEndpoint() @Put('data-asset/:id/manage-permissions') async manageDataAssetPermissions( @Param('id') id: string, @@ -451,6 +459,7 @@ export class CatalogController { return { data_asset: JSON.parse(response.data_asset) }; } + @ApiInternalOnlyEndpoint() @Put('data-asset/:id/revoke-permissions') async revokeDataAssetPermissions( @Param('id') id: string, @@ -561,7 +570,10 @@ export class CatalogController { username, }); const response = await this.catalogService.deleteComment( - { data_asset_id: id, comment: body.comment }, + { + data_asset_id: id, + comment: { ...body.comment, created_at: undefined, message: undefined }, + }, metadata, ); diff --git a/src/modules/catalog/dtos/index.ts b/src/modules/catalog/dtos/index.ts index e55872f..3d29575 100644 --- a/src/modules/catalog/dtos/index.ts +++ b/src/modules/catalog/dtos/index.ts @@ -1,4 +1,4 @@ -import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; +import { ApiProperty, ApiPropertyOptional, PickType } from '@nestjs/swagger'; import { CreateDataAssetRequest } from '@dadosfera/protospack-v2/dist/lib/Catalog/interfaces/messages'; export enum DataAssetShareType { @@ -6,6 +6,10 @@ export enum DataAssetShareType { public = 'public', private = 'private', } +export enum OrderEnum { + asc = 'asc', + desc = 'desc', +} export class EmbedObject { @ApiProperty() url: string; @@ -92,6 +96,8 @@ export class IDataAsset { comments: IComment[]; @ApiPropertyOptional() embed?: EmbedObject; + @ApiPropertyOptional({ enum: DataAssetShareType }) + share_type?: DataAssetShareType; } export class IOneDataAsset { @@ -104,9 +110,43 @@ export class IMakeAComment { message: string; } +export class CommentToDelete extends PickType(IComment, ['id', 'username']) {} export class IDeleteComment { @ApiProperty() - comment: IComment; + comment: CommentToDelete; +} + +export class ICatalogAllRequest { + @ApiPropertyOptional({ + description: 'Texto usado para filtrar os ativos no catálogo.', + }) + search; + + @ApiPropertyOptional({ + description: 'Número de registros a ser retornado', + maximum: 10000, + minimum: 1, + }) + size: number; + + @ApiPropertyOptional({ + description: 'Usado para paginação, em conjunto com `size`', + minimum: 1, + }) + page: number; + + @ApiPropertyOptional({ + description: + 'Campo do data asset para usar na ordenação. Padrão: `created_at` ', + }) + sort_by: string; + + @ApiPropertyOptional({ + enum: OrderEnum, + default: OrderEnum.asc, + description: 'Tipo de ordenação - `asc`: crescente; `desc`: decrescente ', + }) + order?: OrderEnum; } export class ICatalogAllResponse { @@ -141,7 +181,7 @@ export class IUpdateDataRequest { @ApiPropertyOptional() embed: EmbedObject; @ApiPropertyOptional({ enum: DataAssetShareType }) - share_type: DataAssetShareType; + share_type?: DataAssetShareType; } export class ICreateDataAsset implements CreateDataAssetRequest { @ApiProperty() diff --git a/src/modules/connection-test/connection-test.controller.ts b/src/modules/connection-test/connection-test.controller.ts index c3a86f8..f197358 100644 --- a/src/modules/connection-test/connection-test.controller.ts +++ b/src/modules/connection-test/connection-test.controller.ts @@ -9,7 +9,7 @@ import { ValidationPipe, } from '@nestjs/common'; import { ApiOkResponse, ApiTags } from '@nestjs/swagger'; -import { User, RequestUser } from 'src/authentication/user.decorator'; +import { User, RequestUser } from 'src/decorators/user.decorator'; import { ConnectionTestService } from './connection-test.service'; import { ConnectionTestPingRes, @@ -24,9 +24,11 @@ import { GetTableMetadataReq, } from './dto/connection-test'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; -import { Authenticated } from 'src/authentication/authentication.decorator'; +import { Authenticated } from 'src/decorators/authentication.decorator'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +@ApiInternalOnlyController() @ApiTags('Connection Test') @Controller('connection-test') @UseFilters(new GrpcToHttpExceptionFilter()) diff --git a/src/modules/connection-test/connection-test.service.ts b/src/modules/connection-test/connection-test.service.ts index 6e78443..310555a 100644 --- a/src/modules/connection-test/connection-test.service.ts +++ b/src/modules/connection-test/connection-test.service.ts @@ -19,7 +19,7 @@ import { CreateConnectionDto, DatabaseConnectionPropertiesDto, } from '../connection/dtos/connection'; -import { RequestUser } from 'src/authentication/user.decorator'; +import { RequestUser } from 'src/decorators/user.decorator'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; @Injectable() diff --git a/src/modules/connection/connection.controller.ts b/src/modules/connection/connection.controller.ts index 2aa47cf..255daba 100644 --- a/src/modules/connection/connection.controller.ts +++ b/src/modules/connection/connection.controller.ts @@ -7,19 +7,18 @@ import { Param, Delete, Get, - Headers, Query, UseFilters, } from '@nestjs/common'; -import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; +import { ApiExcludeEndpoint, ApiTags } from '@nestjs/swagger'; import { ConnectionClientService } from './client.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { Authenticated, RequireAllPermissions, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { ValidationPipe } from '../../pipes/object-validation.pipe'; import { ConnectionDetailsRes, @@ -30,11 +29,13 @@ import { import { CreateConnectionDto } from './dtos/connection'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; +import { Language } from 'src/decorators/language.decorator'; +import { LanguageEnum } from 'src/utils/languages.enum'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; const connectionPermissions = PERMISSIONS_GROUPS.CONNECTION.permissions; @UseFilters(new GrpcToHttpExceptionFilter()) @ApiTags('connections') -@ApiBearerAuth() @Authenticated() @Controller('connections') export class ConnectionController { @@ -47,7 +48,9 @@ export class ConnectionController { this.logger = dadosferaLogger.logger; } + @ApiInternalOnlyEndpoint() @Get('connections-migration') + @ApiExcludeEndpoint() @RequireAllPermissions( PERMISSIONS_GROUPS.DADOSFERA.permissions.CONNECTIONS_MIGRATION, ) @@ -83,12 +86,11 @@ export class ConnectionController { @RequireAllPermissions(connectionPermissions.CREATE) async updateConnection( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language: string, + @Language() language: LanguageEnum, @Param('id') id: string, @Body(new ValidationPipe()) body: UpdateConnectionDto, ): Promise { this.logger.info('/connections - Update Connection'); - if (!language) language = 'en-us'; const { user_id, customer_id, customer_name, username } = user; const metadata = PackTheMetadata({ @@ -135,11 +137,10 @@ export class ConnectionController { @Get() async getAllConnections( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Query() queries, ): Promise { this.logger.info('/connections - Get All Connection'); - if (!language) language = 'en-us'; const { user_id, customer_id, customer_name, username } = user; const { search, size, page, ...filters } = queries; @@ -161,13 +162,12 @@ export class ConnectionController { @Get('/:id') async getConnectionDetails( - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @User() user: RequestUser, @Param('id') id, @Query() queries, ): Promise { this.logger.info('/connections - Get Connection Details'); - if (!language) language = 'en-us'; console.log(queries); diff --git a/src/modules/connector/connector.controller.ts b/src/modules/connector/connector.controller.ts index c95ff54..10c57e4 100644 --- a/src/modules/connector/connector.controller.ts +++ b/src/modules/connector/connector.controller.ts @@ -11,11 +11,10 @@ import { UploadedFile, UseInterceptors, Inject, - Headers, UploadedFiles, } from '@nestjs/common'; import { FileInterceptor, FilesInterceptor } from '@nestjs/platform-express'; -import { ApiBearerAuth, ApiConsumes, ApiTags } from '@nestjs/swagger'; +import { ApiConsumes, ApiTags } from '@nestjs/swagger'; import { ConnectorClientService } from './client.service'; import { AddTagDto } from './dtos/add-tag'; import { CreateConnectorDto } from './dtos/create-connector'; @@ -27,11 +26,14 @@ import { Authenticated, RequireAllPermissions, RequireSomePermission, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; +import { Language } from 'src/decorators/language.decorator'; +import { LanguageEnum } from 'src/utils/languages.enum'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +@ApiInternalOnlyController() @ApiTags('connectors') -@ApiBearerAuth() @Authenticated() @Controller('connectors') export class ConnectorController { @@ -98,11 +100,10 @@ export class ConnectorController { PERMISSIONS_GROUPS.PIPELINE.permissions.DELETE, ) async getAllConnectors( - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, @Query() queries: GetAllDto, ) { this.logger.info('/GET - getAllConnectors Route'); - if (!language) language = 'en-us'; const { search, size, page, ...filters } = queries; @@ -143,12 +144,11 @@ export class ConnectorController { PERMISSIONS_GROUPS.PIPELINE.permissions.DELETE, ) async getConnector( - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, @Param('plugin') plugin: string, @Query('version') version: string, ) { this.logger.info('/GET/:plugin - getConnector Route'); - if (!language) language = 'en-us'; const pluginId = `${plugin}-${version}`; @@ -172,13 +172,11 @@ export class ConnectorController { PERMISSIONS_GROUPS.PIPELINE.permissions.DELETE, ) async getConnectorDetails( - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, @Param('plugin') plugin: string, @Query('version') version: string, ) { this.logger.info('/upload - Upload Connector Route'); - if (!language) language = 'en-us'; - const pluginId = `${plugin}-${version}`; const response: any = await this.connectorClientService.getConnectorDetails( diff --git a/src/modules/inputs/inputs.controller.ts b/src/modules/inputs/inputs.controller.ts index 4ce5dc6..0145bc3 100644 --- a/src/modules/inputs/inputs.controller.ts +++ b/src/modules/inputs/inputs.controller.ts @@ -12,7 +12,7 @@ import { import { InputsService } from './inputs.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; -import { AuthenticateCondition } from 'src/authentication/authentication.decorator'; +import { AuthenticateCondition } from 'src/decorators/authentication.decorator'; import { ApiOkResponse, ApiTags } from '@nestjs/swagger'; import { CreateInputReq, @@ -21,9 +21,10 @@ import { Input, } from './dtos/input.model'; import { UpdateInputRequest } from './dtos/old_interfaces'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { Info } from '@dadosfera/protospack-v2/dist/lib/Input/interfaces/entities'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; @ApiTags('Inputs') @Controller('inputs') @@ -66,6 +67,7 @@ export class InputsController { this.logger = dadosferaLogger.logger; } + @ApiInternalOnlyEndpoint() @Get('available-entities/:plugin') @ApiOkResponse({ type: GetAvailableEntitiesRes }) async getAvailableEntities( @@ -102,6 +104,7 @@ export class InputsController { return response; } + @ApiInternalOnlyEndpoint() @Get() async findAll(@User() user: RequestUser) { const { user_id, customer_id, customer_name: customer } = user; @@ -132,6 +135,7 @@ export class InputsController { return response; } + @ApiInternalOnlyEndpoint() @Patch(':id') async update(@Body() updateInputDto: UpdateInputRequest, @Param() params) { const { id } = params; @@ -147,6 +151,7 @@ export class InputsController { return response; } + @ApiInternalOnlyEndpoint() @Delete(':id') async delete(@Body() data, @Param() params) { const { id } = params; diff --git a/src/modules/mixpanel/mixpanel.controller.ts b/src/modules/mixpanel/mixpanel.controller.ts index bf04196..76f7809 100644 --- a/src/modules/mixpanel/mixpanel.controller.ts +++ b/src/modules/mixpanel/mixpanel.controller.ts @@ -1,8 +1,10 @@ import { Body, Controller, Inject, Param, Post } from '@nestjs/common'; import { init } from 'mixpanel'; -import { Authenticated } from 'src/authentication/authentication.decorator'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { Authenticated } from 'src/decorators/authentication.decorator'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; +@ApiInternalOnlyController() @Authenticated() @Controller('trackEvent') export class MixpanelController { diff --git a/src/modules/network-config/network-config-client.config.ts b/src/modules/network-config/network-config-client.config.ts index 09bed03..a5227f8 100644 --- a/src/modules/network-config/network-config-client.config.ts +++ b/src/modules/network-config/network-config-client.config.ts @@ -6,6 +6,8 @@ import { } from '@nestjs/microservices'; import { NetworkConfig } from '@dadosfera/protospack-v2'; +const isLocalConnection = !!process.env.INFACTORY_URL?.includes('0.0.0.0'); + export class NetworkConfigGrpcClient { public name = 'NetworkConfigGrpcClient'; @@ -17,8 +19,7 @@ export class NetworkConfigGrpcClient { NetworkConfig.ProtoPackages.ReadPackage, NetworkConfig.ProtoPackages.WritePackage, ], - credentials: - process.env.ENV === 'local' ? undefined : credentials.createSsl(), + credentials: isLocalConnection ? undefined : credentials.createSsl(), protoPath: [ NetworkConfig.ProtoPaths.ReadFilePath, NetworkConfig.ProtoPaths.WriteFilePath, diff --git a/src/modules/network-config/network-config.controller.ts b/src/modules/network-config/network-config.controller.ts index f65ecbb..1c7552c 100644 --- a/src/modules/network-config/network-config.controller.ts +++ b/src/modules/network-config/network-config.controller.ts @@ -1,12 +1,9 @@ import { Body, Controller, - Delete, Get, - Headers, Inject, Param, - Patch, Post, Query, UploadedFile, @@ -15,7 +12,7 @@ import { import { NetworkConfigService } from './network-config.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { ApiConsumes, ApiOkResponse, ApiTags } from '@nestjs/swagger'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { CreateNetworkConfigReq, CreateNetworkConfigRes, @@ -26,7 +23,9 @@ import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; import { Authenticated, RequireAllPermissions, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; +import { Language } from 'src/decorators/language.decorator'; +import { LanguageEnum } from 'src/utils/languages.enum'; const networkConfigPermissions = PERMISSIONS_GROUPS.NETWORK_CONFIG.permissions; @ApiTags('Network Config') @@ -40,18 +39,18 @@ export class NetworkConfigController { ) { this.logger = dadosferaLogger.logger; } + @Get() @ApiOkResponse({ type: FindAllNetworkConfigsRes }) async findAllNetworkConfigs( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Query() queries, ) { this.logger.info('GET /network-config', { user: user.user_id, customer: user.customer_name, }); - if (!language) language = 'en-us'; const { user_id, customer_id, customer_name } = user; const { search, size, page, ...filters } = queries; @@ -79,14 +78,14 @@ export class NetworkConfigController { @ApiOkResponse({ type: FindAllNetworkConfigsRes }) async findNetworkConfigByIdDetails( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Param('id') id: string, ) { this.logger.info('GET /network-config/:id', { user: user.user_id, customer: user.customer_name, }); - if (!language) language = 'en-us'; + return this.networkConfigService.findNetworkConfigByIdDetails(id, { customer_name: user.customer_name, customer_id: user.customer_id, diff --git a/src/modules/oauth/oauth.controller.ts b/src/modules/oauth/oauth.controller.ts index 518dd24..1e87866 100644 --- a/src/modules/oauth/oauth.controller.ts +++ b/src/modules/oauth/oauth.controller.ts @@ -5,6 +5,7 @@ import { ConnectionClientService } from '../connection/client.service'; import jwt from 'jsonwebtoken'; import DadosferaLogger from '@dadosfera/dadosfera-logs/dist'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; @ApiTags('oauth') @Controller('oauth') export class OauthController { @@ -15,7 +16,6 @@ export class OauthController { private logger: DadosferaLogger, ) { switch (process.env.ENV) { - case 'dev': case 'stg': this.redirectUrl = `https://app.${process.env.ENV}.dadosfera.ai/collect/auth-callback`; break; @@ -32,6 +32,7 @@ export class OauthController { return true; } + @ApiInternalOnlyEndpoint() @Get('hubspot/callback') @UseGuards(AuthGuard('hubspot')) @Redirect() @@ -45,6 +46,7 @@ export class OauthController { return true; } + @ApiInternalOnlyEndpoint() @Get('googleads/callback') @UseGuards(AuthGuard('google')) @Redirect() @@ -58,6 +60,7 @@ export class OauthController { return true; } + @ApiInternalOnlyEndpoint() @Get('google-sheets/callback') @UseGuards(AuthGuard('google')) @Redirect() @@ -71,6 +74,7 @@ export class OauthController { return true; } + @ApiInternalOnlyEndpoint() @Get('facebook/callback') @UseGuards(AuthGuard('facebook')) @Redirect() @@ -84,6 +88,7 @@ export class OauthController { return true; } + @ApiInternalOnlyEndpoint() @Get('mailchimp/callback') @UseGuards(AuthGuard('mailchimp')) @Redirect() @@ -97,6 +102,7 @@ export class OauthController { return true; } + @ApiInternalOnlyEndpoint() @Get('salesforce/callback') @UseGuards(AuthGuard('salesforce')) @Redirect() diff --git a/src/modules/oauth/passport-strategies/google-strategy.ts b/src/modules/oauth/passport-strategies/google-strategy.ts index 1bd6ffc..972ebc4 100644 --- a/src/modules/oauth/passport-strategies/google-strategy.ts +++ b/src/modules/oauth/passport-strategies/google-strategy.ts @@ -29,7 +29,6 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { super(options, verify); switch (process.env.ENV) { - case 'dev': case 'stg': this.redirect_uri = `https://maestro.${process.env.ENV}.dadosfera.ai/oauth`; break; diff --git a/src/modules/permissions/permissions.controller.ts b/src/modules/permissions/permissions.controller.ts index 0383d9f..13494bd 100644 --- a/src/modules/permissions/permissions.controller.ts +++ b/src/modules/permissions/permissions.controller.ts @@ -1,13 +1,16 @@ -import { Controller, Get, Headers, Inject } from '@nestjs/common'; +import { Controller, Get, Inject } from '@nestjs/common'; import { ApiHeader, ApiOkResponse, ApiTags } from '@nestjs/swagger'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; -import { Authenticated } from 'src/authentication/authentication.decorator'; +import { Authenticated } from 'src/decorators/authentication.decorator'; import { PermissionUsages } from 'src/authentication/permissions.enum'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { LanguageEnum } from 'src/utils/languages.enum'; import { GetPublicPermissionsRes } from './dto/entities'; import { PermissionsService } from './permissions.service'; +import { Language } from 'src/decorators/language.decorator'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +@ApiInternalOnlyController() @ApiTags('Permissions') @Authenticated() @Controller('permissions') @@ -32,10 +35,10 @@ export class PermissionsController { @ApiOkResponse({ type: GetPublicPermissionsRes }) getPublicPermissions( @User() user: RequestUser, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('getPublicPermissions', { user }); - if (!language) language = 'en-us'; + const permissionGroups = this.permissionsService.getPermissionsGrouped( PermissionUsages.PUBLIC, language, diff --git a/src/modules/permissions/permissions.service.ts b/src/modules/permissions/permissions.service.ts index f5a03a1..9ea6ac8 100644 --- a/src/modules/permissions/permissions.service.ts +++ b/src/modules/permissions/permissions.service.ts @@ -60,10 +60,10 @@ export class PermissionsService }).catch((err: ErrorBuilder) => { if ( err.code === 'No connection established' && - (process.env.LOCAL_ENV === 'true' || process.env.ENV === 'local') + process.env.ENV === 'local' ) { return this.logger.info( - "couldn't connect to DUC. suppresing in local env", + "couldn't connect to DUC. suppressing in local env", ); } diff --git a/src/modules/pipelines/pipelines.controller.ts b/src/modules/pipelines/pipelines.controller.ts index 776cd65..0d967a2 100644 --- a/src/modules/pipelines/pipelines.controller.ts +++ b/src/modules/pipelines/pipelines.controller.ts @@ -1,13 +1,15 @@ import { Body, Controller, Get, Inject, Param, Post } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiOperation, ApiTags } from '@nestjs/swagger'; import { AuthenticateCondition, Authenticated, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; import { PipelinesService } from './pipelines.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +@ApiInternalOnlyController() @ApiTags('Pipelines') @Controller('pipelines') @Authenticated() @@ -42,6 +44,11 @@ export class PipelinesController { } @Post('start/:id') + @ApiOperation({ + deprecated: true, + description: + 'This method is deprecated. Please use route /pipelinesV2/start/:id instead', + }) async activate(@Param() params, @Body() body) { const { id } = params; const { info } = body; @@ -60,6 +67,11 @@ export class PipelinesController { } @Get(':id/status') + @ApiOperation({ + deprecated: true, + description: + 'This method is deprecated. Please use route /pipelinesV2/:id/status instead', + }) async getPipelineStatus(@Body() body, @Param() params) { const { id } = params; body.id = id; diff --git a/src/modules/pipelinesV2/pipelines.controller.ts b/src/modules/pipelinesV2/pipelines.controller.ts index 7552cb4..c457f33 100644 --- a/src/modules/pipelinesV2/pipelines.controller.ts +++ b/src/modules/pipelinesV2/pipelines.controller.ts @@ -7,28 +7,30 @@ import { Param, Post, Put, - Headers, Query, UseFilters, HttpCode, HttpStatus, Patch, HttpException, + BadRequestException, } from '@nestjs/common'; import { ApiCreatedResponse, + ApiHeaders, ApiNoContentResponse, + ApiOperation, ApiTags, } from '@nestjs/swagger'; import { AuthenticateCondition, RequireAllPermissions, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; import { PipelinesService } from './pipelines.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { Messages } from '@dadosfera/protospack-v2/dist/lib/PipelineV2'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; import { PipelinesService as OldPipelineService } from 'src/modules/pipelines/pipelines.service'; @@ -40,9 +42,13 @@ import { IInitUploadCSVFile, } from './interfaces'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; +import { LanguageEnum } from 'src/utils/languages.enum'; +import { Language } from 'src/decorators/language.decorator'; +import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; -@UseFilters(new GrpcToHttpExceptionFilter()) @ApiTags('PipelinesV2') +@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) +@UseFilters(new GrpcToHttpExceptionFilter()) @Controller('pipelinesV2') @AuthenticateCondition((req, user) => { let action; @@ -82,12 +88,12 @@ export class PipelinesController { @Post() @ApiCreatedResponse({ type: IPipelineV2 }) async create( - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @User() user: RequestUser, @Body() createPipelineDto: ICreatePipelineV2Req, ) { this.logger.info('PipelinesController - create', { user }); - if (!language) language = 'en-us'; + const { customer_id, customer_name, username, user_id } = user; const metadata = PackTheMetadata({ customer_id, @@ -108,13 +114,11 @@ export class PipelinesController { @Get() async findAll( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Query() data, ) { this.logger.info('PipelinesController - findAll', { user }); - if (!language) language = 'en-us'; - const { customer_id, customer_name, user_id, username } = user; const metadata = PackTheMetadata({ customer_id, @@ -134,16 +138,13 @@ export class PipelinesController { @Get('/download-logs') async downloadLogs( @User() user: RequestUser, - @Headers('Dadosfera-Lang') language, - @Query() query, + @Language() language: LanguageEnum, + @Query('pipeline_run_id') pipeline_run_id: string, ) { this.logger.info('PipelinesController - downloadLogs', { user }); - if (!language) language = 'en-us'; - - if (!query) { - throw new HttpException('Query params not provided', 400); - } + if (!pipeline_run_id) + throw new BadRequestException('Missing pipeline_run_id'); const { customer_id, customer_name, user_id, username } = user; const metadata = PackTheMetadata({ @@ -155,7 +156,7 @@ export class PipelinesController { }); const url = await this.pipelinesClientService.downloadLogs( - query.pipeline_run_id, + pipeline_run_id, metadata, ); @@ -166,42 +167,52 @@ export class PipelinesController { @Get(':id/config') async getPipelineproperties( - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @User() user: RequestUser, @Param('id') id, ) { this.logger.info('PipelinesController - getPipelineproperties', { user }); - const metadata = PackTheMetadata({ - ...user, - language: language || 'pt-br', - }); + const metadata = PackTheMetadata({ ...user, language: language }); return this.pipelinesClientService.findOneProperties(id, metadata); } @Get(':id/objects') async getPipelineObjects( - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @User() user: RequestUser, @Param('id') id, ) { this.logger.info('PipelinesController - getPipelineObjects', { user }); - const metadata = PackTheMetadata({ - ...user, - language: language || 'pt-br', - }); + const metadata = PackTheMetadata({ ...user, language: language }); return this.pipelinesClientService.findOneObjects(id, metadata); } + @Get(':id/status') + async getPipelineStatus(@Body() body, @Param() params) { + const { id } = params; + body.id = id; + + this.logger.info( + process.env.DEV_URL + `/pipeline/${id} - ON GET PIPELINE STATUS ROUTE`, + { + user: body.info.user_id, + customer: body.info.customer, + }, + ); + + const response = await this.oldPipelinesService.getPipelineStatus(body); + + return response; + } + @Get('/:id') async findOne( - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @User() user: RequestUser, @Param('id') id, ): Promise { this.logger.info('PipelinesController - findOne', { user }); - if (!language) language = 'en-us'; - const { customer_id, customer_name, user_id, username } = user; const metadata = PackTheMetadata({ @@ -235,9 +246,9 @@ export class PipelinesController { return result; } - @Put('/:id') + @Patch('/:id') async update( - @Headers('Dadosfera-Lang') language, + @Language() language: LanguageEnum, @Body() updatePipelineDto, @Param('id') id, @User() user: RequestUser, @@ -247,7 +258,6 @@ export class PipelinesController { delete updatePipelineDto.info; const { customer_id, customer_name, user_id, username } = user; - if (!language) language = 'en-us'; const metadata = PackTheMetadata({ customer_id, @@ -270,16 +280,21 @@ export class PipelinesController { return response; } - @Patch('/:id') - async updateByPatch( - @Headers('Dadosfera-Lang') language, + @ApiInternalOnlyEndpoint() + @Put('/:id') + @ApiOperation({ + deprecated: true, + description: 'This method is deprecated. Please use PATCH instead', + }) + async updateDeprecated( + @Language() language: LanguageEnum, @Body() updatePipelineDto, @Param('id') id, @User() user: RequestUser, ) { - this.logger.info('PipelinesController - patch', { user }); + this.logger.info('PipelinesController - put', { user }); const response = await this.update(language, updatePipelineDto, id, user); - this.logger.info('PipelinesController - patch: OK', { user }); + this.logger.info('PipelinesController - put: OK', { user }); return response; } @@ -298,6 +313,7 @@ export class PipelinesController { this.logger.info('PipelinesController - delete: OK'); } + @ApiInternalOnlyEndpoint() @Post('/init-upload') @RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE) async initUploadFile( @@ -329,6 +345,7 @@ export class PipelinesController { return { urls: JSON.parse(urls), upload_id }; } + @ApiInternalOnlyEndpoint() @Post('/complete-upload') @RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE) async completeUploadFile( @@ -346,6 +363,7 @@ export class PipelinesController { ); } + @ApiInternalOnlyEndpoint() @Post('/file') @RequireAllPermissions(PERMISSIONS_GROUPS.PIPELINE.permissions.CREATE) async uploadedFile( @@ -387,4 +405,23 @@ export class PipelinesController { return pipeline; } + + @ApiInternalOnlyEndpoint() + @Post('start/:id') + async activate(@Param() params, @Body() body) { + const { id } = params; + const { info } = body; + + this.logger.info( + process.env.DEV_URL + `/pipeline/start/${id} - ON START PIPELINE ROUTE`, + { + user: body.info.user_id, + customer: body.info.customer, + }, + ); + + const response = await this.oldPipelinesService.runPipeline({ id, info }); + + return response; + } } diff --git a/src/modules/pipelinesV2/pipelines.service.ts b/src/modules/pipelinesV2/pipelines.service.ts index de62496..dcf740b 100644 --- a/src/modules/pipelinesV2/pipelines.service.ts +++ b/src/modules/pipelinesV2/pipelines.service.ts @@ -21,7 +21,7 @@ import { PipelineV2CreateRequest } from '@dadosfera/protospack-v2/dist/lib/Pipel import { Metadata } from '@grpc/grpc-js'; import { ConnectorClientService } from '../connector/client.service'; import { InputsService } from '../inputs/inputs.service'; -import { RequestUser } from 'src/authentication/user.decorator'; +import { RequestUser } from 'src/decorators/user.decorator'; import { TransformationsService } from '../transformations/transformations.service'; import { getObjValueFromPath } from 'src/utils/ObjValueFromPath'; import ErrorCodes from 'src/utils/errorCodes'; diff --git a/src/modules/productboard/productboard.controller.ts b/src/modules/productboard/productboard.controller.ts index 55327df..749b03d 100644 --- a/src/modules/productboard/productboard.controller.ts +++ b/src/modules/productboard/productboard.controller.ts @@ -1,12 +1,16 @@ import { Body, Controller, HttpException, Post } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import axios from 'axios'; -import { User, RequestUser } from 'src/authentication/user.decorator'; +import { Authenticated } from 'src/decorators/authentication.decorator'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +import { User, RequestUser } from 'src/decorators/user.decorator'; import { getSecretFromSecretsManager } from 'src/utils/SecretManager'; import { INote } from './dtos'; +@ApiInternalOnlyController() @ApiTags('Productboard') @Controller('productboard') +@Authenticated() export class ProductboardController { @Post('notes') async sendNote(@Body() note: INote, @User() user: RequestUser) { diff --git a/src/modules/roles/roles.controller.ts b/src/modules/roles/roles.controller.ts index ca5ab99..a595bcf 100644 --- a/src/modules/roles/roles.controller.ts +++ b/src/modules/roles/roles.controller.ts @@ -3,7 +3,6 @@ import { Controller, Delete, Get, - Headers, Inject, Param, Patch, @@ -14,11 +13,11 @@ import { } from '@nestjs/common'; import { ApiCreatedResponse, - ApiHeader, + ApiHeaders, ApiOkResponse, ApiTags, } from '@nestjs/swagger'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { RolesService } from './roles.service'; import { @@ -43,16 +42,14 @@ import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; import { Authenticated, RequireAllPermissions, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { LanguageEnum } from 'src/utils/languages.enum'; +import { Language } from 'src/decorators/language.decorator'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +@ApiInternalOnlyController() @ApiTags('Roles') -@ApiHeader({ - name: 'dadosfera-lang', - enum: LanguageEnum, - required: false, - description: 'Defaults to pt-br', -}) +@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) @Authenticated() @UseFilters(new GrpcToHttpExceptionFilter()) @Controller('roles') @@ -72,7 +69,7 @@ export class RolesController { async searchRoles( @User() user: RequestUser, @Query() params: GetRolesByCustomerReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('searchRoles', { user }); this.rolesService.setLanguage(language); @@ -85,7 +82,7 @@ export class RolesController { async createRole( @User() user: RequestUser, @Body() body: CreateRoleReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('createRole', { user }); this.rolesService.setLanguage(language); @@ -98,7 +95,7 @@ export class RolesController { async grantPermissionsToRole( @User() user: RequestUser, @Body() body: GrantPermissionsToRoleReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('grantPermissionsToRole', { user }); this.rolesService.setLanguage(language); @@ -111,7 +108,7 @@ export class RolesController { async revokePermissionsFromRole( @User() user: RequestUser, @Body() body: RevokePermissionsFromRoleReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('revokePermissionsToRole', { user }); this.rolesService.setLanguage(language); @@ -124,7 +121,7 @@ export class RolesController { async setRolePermissions( @User() user: RequestUser, @Body() body: SetRolePermissionsReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('setRolePermissions', { user }); this.rolesService.setLanguage(language); @@ -137,7 +134,7 @@ export class RolesController { async setRoleUsers( @User() user: RequestUser, @Body() body: SetRoleUsersReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('setRoleUsers', { user }); this.rolesService.setLanguage(language); @@ -150,7 +147,7 @@ export class RolesController { async getRoleById( @User() user: RequestUser, @Param('id') id: string, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('getRoleById', { user }); this.rolesService.setLanguage(language); @@ -162,7 +159,7 @@ export class RolesController { async deleteRole( @User() user: RequestUser, @Param('id') id: string, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('deleteRole', { user }); this.rolesService.setLanguage(language); @@ -176,7 +173,7 @@ export class RolesController { @User() user: RequestUser, @Param('id') id: string, @Body() body: UpdateRoleReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('updateRole', { user }); this.rolesService.setLanguage(language); diff --git a/src/modules/roles/roles.service.ts b/src/modules/roles/roles.service.ts index da12c7b..bd41ca5 100644 --- a/src/modules/roles/roles.service.ts +++ b/src/modules/roles/roles.service.ts @@ -18,7 +18,7 @@ import { Permission } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/ent import { lastValueFrom } from 'rxjs'; import { PermissionsService } from '../permissions/permissions.service'; import { LanguageEnum } from 'src/utils/languages.enum'; -import { RequestUser } from 'src/authentication/user.decorator'; +import { RequestUser } from 'src/decorators/user.decorator'; import { DucClient } from '../duc/client.config'; interface GetRolesPermissionsName { diff --git a/src/modules/termsOfUse/termsOfUse.controller.ts b/src/modules/termsOfUse/termsOfUse.controller.ts index e003367..d2d3fb1 100644 --- a/src/modules/termsOfUse/termsOfUse.controller.ts +++ b/src/modules/termsOfUse/termsOfUse.controller.ts @@ -9,17 +9,22 @@ import { Headers, UseFilters, } from '@nestjs/common'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiHeaders, ApiTags } from '@nestjs/swagger'; import { TermsOfUseAcceptRequest } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages'; import { TermsOfUseClientService } from './termsOfUse.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter'; -import { RequestUser, User } from '../../authentication/user.decorator'; +import { RequestUser, User } from '../../decorators/user.decorator'; import { Metadata } from '@grpc/grpc-js'; +import { Language } from 'src/decorators/language.decorator'; +import { LanguageEnum } from 'src/utils/languages.enum'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +@ApiInternalOnlyController() @ApiTags('TermsOfUse') +@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) @UseFilters(new GrpcToHttpExceptionFilter()) @Controller('terms-of-use') export class TermsOfUseController { @@ -36,7 +41,7 @@ export class TermsOfUseController { @Get('token') async getToken( @User({ required: true }) user: RequestUser, - @Headers('Dadosfera-Lang') language: string, + @Language() language: LanguageEnum, ) { this.logger.info('/terms-of-use - get token'); const metadata = new Metadata(); diff --git a/src/modules/transformations/transformations.controller.ts b/src/modules/transformations/transformations.controller.ts index 6c8def6..4cedddb 100644 --- a/src/modules/transformations/transformations.controller.ts +++ b/src/modules/transformations/transformations.controller.ts @@ -12,15 +12,17 @@ import { ApiTags } from '@nestjs/swagger'; import { TransformationsClientService } from './client.service'; import { IIdRequest } from './interfaces'; import { - AuthenticateCondition, Authenticated, RequireSomePermission, -} from 'src/authentication/authentication.decorator'; +} from 'src/decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; import { TransformationsService } from './transformations.service'; import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; const pipelinePermissions = PERMISSIONS_GROUPS.PIPELINE.permissions; + +@ApiInternalOnlyController() @ApiTags('Transformations') @Controller('transformations') @Authenticated() diff --git a/src/modules/users/users.controller.ts b/src/modules/users/users.controller.ts index 8a0c17e..9e00f7c 100644 --- a/src/modules/users/users.controller.ts +++ b/src/modules/users/users.controller.ts @@ -1,9 +1,9 @@ +import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { Body, Controller, Delete, Get, - Headers, HttpCode, HttpStatus, Inject, @@ -16,18 +16,22 @@ import { } from '@nestjs/common'; import { ApiCreatedResponse, - ApiHeader, + ApiHeaders, ApiOkResponse, ApiTags, } from '@nestjs/swagger'; -import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; +import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; import { Authenticated, RequireAllPermissions, -} from 'src/authentication/authentication.decorator'; -import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; -import { RequestUser, User } from 'src/authentication/user.decorator'; +} from 'src/decorators/authentication.decorator'; +import { Language } from 'src/decorators/language.decorator'; +import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator'; +import { RequestUser, User } from 'src/decorators/user.decorator'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; +import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; +import ErrorBuilder from 'src/utils/ErrorBuilder'; +import ErrorCodes from 'src/utils/errorCodes'; import { LanguageEnum } from 'src/utils/languages.enum'; import { AssignRoleToUserReq, @@ -40,26 +44,19 @@ import { GetAllHierarchiesRes, GetAllJobTitlesRes, GetAllUsersByCustomerIdRes, + IUserByCustomer, SetUserRolesReq, SetUserRolesRes, UnassignRoleToUserReq, UpdateUserReq, UpdateUserRes, - IUserByCustomer, } from './dtos/entities'; import { UsersService } from './users.service'; -import ErrorBuilder from 'src/utils/ErrorBuilder'; -import ErrorCodes from 'src/utils/errorCodes'; -import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; +@ApiInternalOnlyController() @ApiTags('Users') @Controller('users') -@ApiHeader({ - name: 'dadosfera-lang', - enum: LanguageEnum, - required: false, - description: 'Defaults to pt-br', -}) +@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) @Authenticated() @UseFilters(GrpcToHttpExceptionFilter) export class UsersController { @@ -76,7 +73,7 @@ export class UsersController { @Get() async getAllUsersByCustomerId( @User() user: RequestUser, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ): Promise { this.logger.info('getAllUsersByCustomerId', { user }); this.userService.setLanguage(language); @@ -88,7 +85,7 @@ export class UsersController { @ApiOkResponse({ type: GetAllHierarchiesRes }) async getAllHierarchies( @User() user: RequestUser, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ): Promise { this.logger.info('getAllHierarchies', { user }); this.userService.setLanguage(language); @@ -100,7 +97,7 @@ export class UsersController { @ApiOkResponse({ type: GetAllDepartmentsRes }) async getAllDepartments( @User() user: RequestUser, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ): Promise { this.logger.info('getAllHierarchies', { user }); this.userService.setLanguage(language); @@ -112,7 +109,7 @@ export class UsersController { @ApiOkResponse({ type: GetAllDepartmentsRes }) async getAllJobTitles( @User() user: RequestUser, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ): Promise { this.logger.info('getAllHierarchies', { user }); this.userService.setLanguage(language); @@ -126,7 +123,7 @@ export class UsersController { async findOneById( @User() user: RequestUser, @Param('id') id: string, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('findOneById', { user }); this.userService.setLanguage(language); @@ -147,7 +144,7 @@ export class UsersController { async createUser( @User() user: RequestUser, @Body() body: CreateUserReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { const metadata = PackTheMetadata({ access_token: user.access_token, @@ -165,7 +162,7 @@ export class UsersController { async batchCreateUser( @User() user: RequestUser, @Body() body: BatchCreateUserReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('batchCreateUser', { user }); this.userService.setLanguage(language); @@ -184,7 +181,7 @@ export class UsersController { async resendInvite( @User() user: RequestUser, @Param('id') id: string, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('resendInvite', { user }); this.userService.setLanguage(language); @@ -200,7 +197,7 @@ export class UsersController { async unassignRoleToUser( @User() user: RequestUser, @Query() request: UnassignRoleToUserReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('unassignRoleToUser', { user }); this.userService.setLanguage(language); @@ -213,7 +210,7 @@ export class UsersController { async deleteUser( @User() user: RequestUser, @Param('id') id: string, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('deleteUser', { user }); this.userService.setLanguage(language); @@ -226,7 +223,7 @@ export class UsersController { async setUserRoles( @User() user: RequestUser, @Body() body: SetUserRolesReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('createUser', { user }); this.userService.setLanguage(language); @@ -238,7 +235,7 @@ export class UsersController { async assignRoleToUser( @User() user: RequestUser, @Body() body: AssignRoleToUserReq, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('assignRoleToUser', { user }); this.userService.setLanguage(language); @@ -252,7 +249,7 @@ export class UsersController { @User() user: RequestUser, @Body() body: UpdateUserReq, @Param('id') id: string, - @Headers('dadosfera-lang') language, + @Language() language: LanguageEnum, ) { this.logger.info('updateUser', { user }); this.userService.setLanguage(language); diff --git a/src/utils/ErrorBuilder.ts b/src/utils/ErrorBuilder.ts index faf2b7c..88570e9 100644 --- a/src/utils/ErrorBuilder.ts +++ b/src/utils/ErrorBuilder.ts @@ -119,6 +119,14 @@ export function EnrichErrorCode(code: string) { code, }; + case ErrorCodes.AUTH.INVALID_REFRESH_TOKEN: + return { + statusCode: HttpStatus.UNAUTHORIZED, + error: 'Acesso expirado!', + message: 'Seu acesso expirou, favor fazer login novamente.', + code, + }; + case ErrorCodes.AUTH.FORBIDDEN: return { statusCode: HttpStatus.FORBIDDEN, diff --git a/src/utils/errorCodes.ts b/src/utils/errorCodes.ts index 871f006..3edb29f 100644 --- a/src/utils/errorCodes.ts +++ b/src/utils/errorCodes.ts @@ -1,5 +1,6 @@ export const AUTH = { UNAUTHORIZED: 'AUTH.UNAUTHORIZED', + INVALID_REFRESH_TOKEN: 'AUTH.INVALID_REFRESH_TOKEN', FORBIDDEN: 'AUTH.FORBIDDEN', WRONG_CREDENTIALS: 'AUTH.WRONG_CREDENTIALS', WRONG_PASSWORD_CONFIRMATION: 'AUTH.WRONG_PASSWORD_CONFIRMATION',