From 5fb8dae312dc14a95cf105e25090222baa66f6e0 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Wed, 9 Nov 2022 17:35:18 -0300 Subject: [PATCH 1/9] FIX: pipeline details now showing correct default values on s3 pipelines --- docsfera.json | 4 ++-- src/modules/pipelinesV2/pipelines.service.ts | 18 ++++++++---------- src/utils/ObjValueFromPath.ts | 10 ++++++++++ 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/utils/ObjValueFromPath.ts diff --git a/docsfera.json b/docsfera.json index a26d359..9c47172 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3277,9 +3277,9 @@ } }, "info": { - "title": "Maestro - fix/customer-modules", + "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 14:29", + "version": "9.11.2022 - 17:34", "contact": {} }, "tags": [], diff --git a/src/modules/pipelinesV2/pipelines.service.ts b/src/modules/pipelinesV2/pipelines.service.ts index cdaac50..f4d0f4f 100644 --- a/src/modules/pipelinesV2/pipelines.service.ts +++ b/src/modules/pipelinesV2/pipelines.service.ts @@ -22,6 +22,7 @@ import { ConnectorClientService } from '../connector/client.service'; import { InputsService } from '../inputs/inputs.service'; import { RequestUser } from 'src/authentication/user.decorator'; import { TransformationsService } from '../transformations/transformations.service'; +import { getObjValueFromPath } from 'src/utils/ObjValueFromPath'; export class PipelinesService implements OnModuleInit { logger: DadosferaLogger; @@ -213,16 +214,13 @@ export class PipelinesService implements OnModuleInit { const connector = JSON.parse(res.connector); const config_controls = connector.config_controls || []; - for (const key in pipelineProperties) { - const i = config_controls - .map((cc) => cc.name) - .indexOf(`properties.${key}`); - if (i > -1) { - config_controls[i] = { - ...config_controls[i], - default_value: pipelineProperties[key], - }; - } + for (const config_control of config_controls) { + const path: string = config_control.name; + const default_value = getObjValueFromPath({ + object: { properties: pipelineProperties }, + path, + }); + if (default_value) config_control.default_value = default_value; } return { diff --git a/src/utils/ObjValueFromPath.ts b/src/utils/ObjValueFromPath.ts new file mode 100644 index 0000000..1ea24fb --- /dev/null +++ b/src/utils/ObjValueFromPath.ts @@ -0,0 +1,10 @@ +export function getObjValueFromPath(data: { object: T; path: string }): T { + const { object, path } = data; + const keys = path.split('.'); + + let value = JSON.parse(JSON.stringify(object)); + for (const key of keys) { + if (value) value = value[key]; + } + return value; +} From cd5886337b44cd76368f4cdac4a2348d982b15f7 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Wed, 9 Nov 2022 18:40:53 -0300 Subject: [PATCH 2/9] FIX: customer modules --- docsfera.json | 2 +- package-lock.json | 14 +++++++------- package.json | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docsfera.json b/docsfera.json index 9c47172..ed66912 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3279,7 +3279,7 @@ "info": { "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 17:34", + "version": "9.11.2022 - 18:35", "contact": {} }, "tags": [], diff --git a/package-lock.json b/package-lock.json index 964b3fc..d8036d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4", - "@dadosfera/protospack-v2": "3.19.2", + "@dadosfera/protospack-v2": "3.19.3-beta.1", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", @@ -1726,9 +1726,9 @@ } }, "node_modules/@dadosfera/protospack-v2": { - "version": "3.19.2", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.2.tgz", - "integrity": "sha512-0+5V4zo7x36Y9xojYnktTllm41uhAttEFTT13i2sBXn4Cb6xSCX5rOyMHwRHb4TOHTpWvaO58lGjP/i0x+lpEg==", + "version": "3.19.3-beta.1", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.3-beta.1.tgz", + "integrity": "sha512-GLjz5nIL4WSs27/1gOJwRcS9eQ1xUIWFGyjgvXTE8i5W5LotU5E8CqnusY4XIwwpHaAAqo0dPIpSZ+x3FoVJWQ==", "dependencies": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", @@ -12307,9 +12307,9 @@ } }, "@dadosfera/protospack-v2": { - "version": "3.19.2", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.2.tgz", - "integrity": "sha512-0+5V4zo7x36Y9xojYnktTllm41uhAttEFTT13i2sBXn4Cb6xSCX5rOyMHwRHb4TOHTpWvaO58lGjP/i0x+lpEg==", + "version": "3.19.3-beta.1", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.3-beta.1.tgz", + "integrity": "sha512-GLjz5nIL4WSs27/1gOJwRcS9eQ1xUIWFGyjgvXTE8i5W5LotU5E8CqnusY4XIwwpHaAAqo0dPIpSZ+x3FoVJWQ==", "requires": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", diff --git a/package.json b/package.json index 357f9ed..c250f21 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4", - "@dadosfera/protospack-v2": "3.19.2", + "@dadosfera/protospack-v2": "3.19.3-beta.1", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", From 7ee1215da2d78a99fa84d328254f32889f5b7856 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Wed, 9 Nov 2022 18:48:50 -0300 Subject: [PATCH 3/9] Deploy docs using github hosted runner --- .github/workflows/deploy-manually.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy-manually.yml b/.github/workflows/deploy-manually.yml index 2ce4395..4bf6b0b 100644 --- a/.github/workflows/deploy-manually.yml +++ b/.github/workflows/deploy-manually.yml @@ -144,8 +144,7 @@ jobs: docker system df api_docs: needs: [extract_environment, semantic_release, deploy] - runs-on: - [self-hosted, "${{ needs.extract_environment.outputs.environment }}"] + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 From abc625849204c550e983738fb340eb6492889e01 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Wed, 9 Nov 2022 19:30:13 -0300 Subject: [PATCH 4/9] FIX: fixed condition to set default value on pipeline details --- docsfera.json | 2 +- src/modules/pipelinesV2/pipelines.service.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docsfera.json b/docsfera.json index ed66912..77f7d96 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3279,7 +3279,7 @@ "info": { "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 18:35", + "version": "9.11.2022 - 19:28", "contact": {} }, "tags": [], diff --git a/src/modules/pipelinesV2/pipelines.service.ts b/src/modules/pipelinesV2/pipelines.service.ts index f4d0f4f..d0f76d6 100644 --- a/src/modules/pipelinesV2/pipelines.service.ts +++ b/src/modules/pipelinesV2/pipelines.service.ts @@ -220,7 +220,8 @@ export class PipelinesService implements OnModuleInit { object: { properties: pipelineProperties }, path, }); - if (default_value) config_control.default_value = default_value; + if (default_value != undefined) + config_control.default_value = default_value; } return { From 4a7e660a49355792d3d5f795173a66fe5f01f114 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Wed, 9 Nov 2022 20:06:23 -0300 Subject: [PATCH 5/9] FIX: fixed condition of getObjValueFromPath --- docsfera.json | 2 +- src/modules/connector/client.service.ts | 10 ++++++---- src/utils/ObjValueFromPath.ts | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docsfera.json b/docsfera.json index 77f7d96..950e6af 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3279,7 +3279,7 @@ "info": { "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 19:28", + "version": "9.11.2022 - 20:4", "contact": {} }, "tags": [], diff --git a/src/modules/connector/client.service.ts b/src/modules/connector/client.service.ts index 45143ef..fdd1cdb 100644 --- a/src/modules/connector/client.service.ts +++ b/src/modules/connector/client.service.ts @@ -84,7 +84,7 @@ export class ConnectorClientService implements OnModuleInit { }); const responseParsed = JSON.parse(res.message); const connectorErrors = responseParsed.items - .filter((i) => i.update._index === 'connector' && i.update.error) + .filter((i) => i.update._index === 'connectors' && i.update.error) .map((i) => ({ id: i.update._id, reason: i.update.error, @@ -115,7 +115,8 @@ export class ConnectorClientService implements OnModuleInit { })); const connectorCreated = responseParsed.items .filter( - (i) => i.update._index === 'connector' && i.update.result === 'created', + (i) => + i.update._index === 'connectors' && i.update.result === 'created', ) .map((i) => ({ id: i.update._id, @@ -149,7 +150,8 @@ export class ConnectorClientService implements OnModuleInit { })); const connectorUpdated = responseParsed.items .filter( - (i) => i.update._index === 'connector' && i.update.result === 'updated', + (i) => + i.update._index === 'connectors' && i.update.result === 'updated', ) .map((i) => ({ id: i.update._id, @@ -183,7 +185,7 @@ export class ConnectorClientService implements OnModuleInit { })); const connectorNoop = responseParsed.items .filter( - (i) => i.update._index === 'connector' && i.update.result === 'noop', + (i) => i.update._index === 'connectors' && i.update.result === 'noop', ) .map((i) => ({ id: i.update._id, diff --git a/src/utils/ObjValueFromPath.ts b/src/utils/ObjValueFromPath.ts index 1ea24fb..43674bd 100644 --- a/src/utils/ObjValueFromPath.ts +++ b/src/utils/ObjValueFromPath.ts @@ -4,7 +4,7 @@ export function getObjValueFromPath(data: { object: T; path: string }): T { let value = JSON.parse(JSON.stringify(object)); for (const key of keys) { - if (value) value = value[key]; + if (value != undefined) value = value[key]; } return value; } From 8bd7d54aa7fef05ff9b3b85e9ee685ef5a005d02 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Thu, 10 Nov 2022 09:16:02 -0300 Subject: [PATCH 6/9] new protospack version --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 46db5ca..df0b276 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4", - "@dadosfera/protospack-v2": "3.19.3-beta.1", + "@dadosfera/protospack-v2": "3.19.3", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", @@ -1727,9 +1727,9 @@ } }, "node_modules/@dadosfera/protospack-v2": { - "version": "3.19.3-beta.1", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.3-beta.1.tgz", - "integrity": "sha512-GLjz5nIL4WSs27/1gOJwRcS9eQ1xUIWFGyjgvXTE8i5W5LotU5E8CqnusY4XIwwpHaAAqo0dPIpSZ+x3FoVJWQ==", + "version": "3.19.3", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.3.tgz", + "integrity": "sha512-27mewnpCr7gYqwumVgKeqvaRZTbSrpjVHtevemavLUxkZvacfvCQUy+uIv5BZYZpST3lMEPKyvA5wA5XtMAB6A==", "dependencies": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", @@ -12330,9 +12330,9 @@ } }, "@dadosfera/protospack-v2": { - "version": "3.19.3-beta.1", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.3-beta.1.tgz", - "integrity": "sha512-GLjz5nIL4WSs27/1gOJwRcS9eQ1xUIWFGyjgvXTE8i5W5LotU5E8CqnusY4XIwwpHaAAqo0dPIpSZ+x3FoVJWQ==", + "version": "3.19.3", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.19.3.tgz", + "integrity": "sha512-27mewnpCr7gYqwumVgKeqvaRZTbSrpjVHtevemavLUxkZvacfvCQUy+uIv5BZYZpST3lMEPKyvA5wA5XtMAB6A==", "requires": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", diff --git a/package.json b/package.json index 55c5c06..6b0c36b 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4", - "@dadosfera/protospack-v2": "3.19.3-beta.1", + "@dadosfera/protospack-v2": "3.19.3", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", From cf4e7da1d8d56afd8d554f0c42782cfdd29d0316 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Thu, 10 Nov 2022 09:46:22 -0300 Subject: [PATCH 7/9] Typing login route --- docsfera.json | 680 ++++++++++++++++++---------- src/app.module.ts | 2 +- src/modules/auth/auth.controller.ts | 26 +- src/modules/auth/dtos/login.ts | 89 +++- tsconfig.build.json | 2 +- 5 files changed, 533 insertions(+), 266 deletions(-) diff --git a/docsfera.json b/docsfera.json index 11db613..62d13f3 100644 --- a/docsfera.json +++ b/docsfera.json @@ -5,6 +5,265 @@ "schema": { "openapi": "3.0.0", "paths": { + "/auth/sign-in": { + "post": { + "operationId": "AuthController_signIn", + "parameters": [ + { + "name": "Dadosfera-Lang", + "required": true, + "in": "header", + "schema": { + "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/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, + "in": "header", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/change-password": { + "post": { + "operationId": "AuthController_changePassword", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/reset-password": { + "post": { + "operationId": "AuthController_resetPassword", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/verify-reset-password-code": { + "post": { + "operationId": "AuthController_verifyResetPasswordCode", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/confirm-reset-password": { + "post": { + "operationId": "AuthController_confirmResetPassword", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/enable-totp": { + "post": { + "operationId": "AuthController_enableTotpMFA", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/disable-totp": { + "post": { + "operationId": "AuthController_disableTotpMFA", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/dismiss-totp": { + "post": { + "operationId": "AuthController_dismissTotpMFA", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, + "/auth/verify-totp": { + "post": { + "operationId": "AuthController_verifyTotp", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + }, + "tags": [ + "Auth" + ] + } + }, "/connectors": { "post": { "operationId": "ConnectorController_uploadConnector", @@ -385,255 +644,6 @@ ] } }, - "/auth/sso/snowflake": { - "post": { - "operationId": "AuthController_snowflakeSignIn", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/sign-in": { - "post": { - "operationId": "AuthController_signIn", - "parameters": [ - { - "name": "Dadosfera-Lang", - "required": true, - "in": "header", - "schema": { - "type": "string" - } - } - ], - "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, - "in": "header", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/change-password": { - "post": { - "operationId": "AuthController_changePassword", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/reset-password": { - "post": { - "operationId": "AuthController_resetPassword", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/verify-reset-password-code": { - "post": { - "operationId": "AuthController_verifyResetPasswordCode", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/confirm-reset-password": { - "post": { - "operationId": "AuthController_confirmResetPassword", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/enable-totp": { - "post": { - "operationId": "AuthController_enableTotpMFA", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/disable-totp": { - "post": { - "operationId": "AuthController_disableTotpMFA", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/dismiss-totp": { - "post": { - "operationId": "AuthController_dismissTotpMFA", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, - "/auth/verify-totp": { - "post": { - "operationId": "AuthController_verifyTotp", - "parameters": [], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object" - } - } - } - } - }, - "tags": [ - "Auth" - ] - } - }, "/permissions": { "get": { "operationId": "PermissionsController_getPublicPermissions", @@ -3290,7 +3300,7 @@ "info": { "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "9.11.2022 - 20:4", + "version": "10.11.2022 - 9:44", "contact": {} }, "tags": [], @@ -3304,6 +3314,176 @@ } }, "schemas": { + "AuthSignInReq": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "password": { + "type": "string" + }, + "totp": { + "type": "string" + } + }, + "required": [ + "username", + "password" + ] + }, + "AuthCustomer": { + "type": "object", + "properties": { + "modules": { + "type": "array", + "items": { + "type": "string" + } + }, + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "tier": { + "type": "string" + } + }, + "required": [ + "modules", + "id", + "name", + "tier" + ] + }, + "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" + ] + }, "CreateConnectorDto": { "type": "object", "properties": { diff --git a/src/app.module.ts b/src/app.module.ts index 9905c93..d736888 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -39,8 +39,8 @@ import { MixpanelModule } from './modules/mixpanel/mixpanel.module'; ConfigModule.forRoot({ isGlobal: true, }), - ConnectorModule, AuthModule, + ConnectorModule, PermissionsModule, TermsOfUseModule, ConnectionModule, diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index 4e4714c..503dc64 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -10,7 +10,6 @@ import { } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { - AuthSignInRequest, AuthRefreshAccessTokenRequest, AuthChangePasswordRequest, AuthResetPasswordRequest, @@ -28,6 +27,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { GrpcToHttpExceptionFilter } from '../../error/grpc-to-http-exception.filter'; import { RequestUser, User } from 'src/authentication/user.decorator'; import { Metadata } from '@grpc/grpc-js'; +import { AuthSignInReq, AuthSignInRes } from './dtos/login'; @ApiTags('Auth') @UseFilters(new GrpcToHttpExceptionFilter()) @@ -43,6 +43,18 @@ export class AuthController { this.logger = dadosferaLogger.logger; } + @Post('sign-in') + @HttpCode(HttpStatus.OK) + async signIn( + @Body() { username, password, totp }: AuthSignInReq, + @Headers('Dadosfera-Lang') language: string, + ): Promise { + this.logger.info('/auth - SignIn'); + const metadata = new Metadata(); + metadata.add('language', language || 'pt-br'); + return this.authClient.signIn({ username, password, totp }, metadata); + } + @Post('/sso/snowflake') @RequireAllPermissions(PERMISSIONS_GROUPS.SNOWFLAKE.permissions.OPEN) @HttpCode(HttpStatus.OK) @@ -58,18 +70,6 @@ export class AuthController { }); } - @Post('sign-in') - @HttpCode(HttpStatus.OK) - async signIn( - @Body() { username, password, totp }: AuthSignInRequest, - @Headers('Dadosfera-Lang') language: string, - ) { - this.logger.info('/auth - SignIn'); - const metadata = new Metadata(); - metadata.add('language', language || 'pt-br'); - return this.authClient.signIn({ username, password, totp }, metadata); - } - @Post('refresh-access-token') @HttpCode(HttpStatus.OK) async refreshAccessToken( diff --git a/src/modules/auth/dtos/login.ts b/src/modules/auth/dtos/login.ts index cae27fd..32e1885 100644 --- a/src/modules/auth/dtos/login.ts +++ b/src/modules/auth/dtos/login.ts @@ -1,4 +1,8 @@ -import { ApiProperty } from '@nestjs/swagger'; +import { + AuthSignInRequest, + AuthSignInResponse, +} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages'; +import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; export class LoginDto { @ApiProperty() @@ -10,3 +14,86 @@ export class LoginDto { @ApiProperty({ required: false }) totp: string; } +export class AuthTokens { + @ApiProperty() + accessToken: string; + @ApiProperty() + refreshToken: string; + @ApiPropertyOptional() + termsOfUseToken: string; + @ApiProperty({ deprecated: true }) + idToken: string; +} +export enum MfaStatuses { + PENDING = 'pending', + NONE = 'none', + TOTP = 'totp', +} + +export enum TouStatuses { + PENDING = 'pending', + REQUIRED = 'required', + OK = 'ok', +} +export class TermsOfUse { + @ApiProperty() + version: number; + @ApiProperty() + publicUrl: string; + @ApiProperty() + enforceDate: string; + @ApiProperty() + createdAt: string; +} +export class TermsOfUseStatus { + @ApiProperty({ enum: TouStatuses }) + status: string; + @ApiPropertyOptional() + lastSigned?: TermsOfUse; + @ApiPropertyOptional() + next?: TermsOfUse; +} +export class AuthUser { + @ApiProperty() + id: string; + @ApiProperty() + name: string; + @ApiProperty() + username: string; + @ApiProperty() + createdAt: string; +} +export class AuthCustomer { + @ApiProperty() + modules: string[]; + @ApiProperty() + id: string; + @ApiProperty() + name: string; + @ApiProperty() + tier: string; +} + +export class AuthSignInReq implements AuthSignInRequest { + @ApiProperty() + username: string; + @ApiProperty() + password: string; + @ApiPropertyOptional() + totp: string; +} + +export class AuthSignInRes implements AuthSignInResponse { + @ApiProperty() + permissions: string[]; + @ApiProperty({ enum: MfaStatuses }) + mfaStatus: string; + @ApiPropertyOptional() + customer?: AuthCustomer; + @ApiPropertyOptional() + user?: AuthUser; + @ApiPropertyOptional() + tokens?: AuthTokens; + @ApiPropertyOptional() + termsOfUse?: TermsOfUseStatus; +} diff --git a/tsconfig.build.json b/tsconfig.build.json index 64f86c6..ca83a6b 100644 --- a/tsconfig.build.json +++ b/tsconfig.build.json @@ -1,4 +1,4 @@ { "extends": "./tsconfig.json", - "exclude": ["node_modules", "test", "dist", "**/*spec.ts"] + "exclude": ["node_modules", "test", "dist", "**/*spec.ts", "jest.config.ts"] } From 44aa0e6010725195849fee68d7654a75ffae2409 Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Thu, 10 Nov 2022 09:47:30 -0300 Subject: [PATCH 8/9] improved run prod command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b0c36b..313f84a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", + "start:prod": "npm run build && node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "test": "jest", "test:watch": "jest --watch", From 19f5c947bd7f14cfaa2958b8db9f948f3831d3ab Mon Sep 17 00:00:00 2001 From: Gabriel Rosa Date: Thu, 10 Nov 2022 10:12:14 -0300 Subject: [PATCH 9/9] Set release version on swagger when deploying main --- .github/workflows/deploy-manually.yml | 6 +++++- docsfera.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-manually.yml b/.github/workflows/deploy-manually.yml index 4bf6b0b..a845884 100644 --- a/.github/workflows/deploy-manually.yml +++ b/.github/workflows/deploy-manually.yml @@ -174,12 +174,16 @@ jobs: - name: Generate API docs env: - ENV: ${{ needs.extract_environment.outputs.environment }} DOCS_URL: ${{ secrets.DOCS_URL }} DOCS_API_TOKEN: ${{ secrets.DOCS_API_TOKEN }} DOCS_PAGE_ID: ${{ steps.extract_docs_info.outputs.page_id }} DOCS_BLOCK_ID: ${{ steps.extract_docs_info.outputs.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.json + fi sed -i -e "s/\${DOCS_API_TOKEN}/$DOCS_API_TOKEN/g" docsfera.json 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 diff --git a/docsfera.json b/docsfera.json index 62d13f3..80c74d6 100644 --- a/docsfera.json +++ b/docsfera.json @@ -3300,7 +3300,7 @@ "info": { "title": "Maestro - fix/pipeline-details-bug", "description": "Documentation for Maestro gateway", - "version": "10.11.2022 - 9:44", + "version": "10.11.2022 - 10:7", "contact": {} }, "tags": [],