Compare commits

..
12 Commits
Author SHA1 Message Date
Gabriel Rosa b280871bce CI: fix syntax 2024-01-04 14:44:20 -03:00
Gabriel Rosa fd73663940 CI: fix syntax 2024-01-04 14:37:32 -03:00
Gabriel Rosa e420bf6547 CI: choose wether to deploy to dockerhub 2024-01-04 10:25:51 -03:00
Gabriel Rosa cc4cc99ccc FEAT: new refreshToken response
- temporarily disable mixpanel tracking
2023-12-09 11:58:03 -03:00
Gabriel Rosa fd0d68b149 FIX: removed state 2023-12-07 19:39:09 -03:00
Gabriel Rosa 98759b1cf5 FIX: logging oauth error 2023-12-07 17:27:30 -03:00
Gabriel Rosa 695fac97e9 FIX: get frontend url 2023-12-07 11:01:38 -03:00
Gabriel Rosa 86b076246e FEAT: magalu id login 2023-12-06 20:36:14 -03:00
Rafael Santana faa98cae8b UPDATE: triple equals 2023-12-01 13:20:40 -03:00
Rafael Santana 313ecc81ec UPDATE: missing semicolon 2023-12-01 13:20:04 -03:00
Rafael Santana 820d71d16d UPDATE: Adding the cloud_environment to point to the correct nimbus in maestro 2023-12-01 13:13:26 -03:00
Rafael Santana 734978b76f UPDATE: Increasing log level 2023-11-29 17:47:08 -03:00
37 changed files with 11581 additions and 3963 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ module.exports = {
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'prettier', 'plugin:prettier/recommended',
], ],
root: true, root: true,
env: { env: {
+11 -7
View File
@@ -52,7 +52,7 @@ jobs:
id: semantic id: semantic
with: with:
extra_plugins: | extra_plugins: |
conventional-changelog-eslint@4 conventional-changelog-eslint@4.0.0
branches: | branches: |
[ [
'main' 'main'
@@ -87,6 +87,10 @@ jobs:
run: | run: |
python3 -m pip install --upgrade pip python3 -m pip install --upgrade pip
- name: Install Docker Compose
run: |
python3 -m pip install docker-compose --upgrade
- name: Install AWS CLI - name: Install AWS CLI
run: | run: |
python3 -m pip install awscli --upgrade python3 -m pip install awscli --upgrade
@@ -111,8 +115,8 @@ jobs:
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
run: | run: |
docker compose -f build.docker-compose.yml build docker-compose -f build.docker-compose.yml build
docker compose -f build.docker-compose.yml push docker-compose -f build.docker-compose.yml push
- name: Login to Docker Hub - name: Login to Docker Hub
if: ${{inputs.push_to_dockerhub}} if: ${{inputs.push_to_dockerhub}}
@@ -128,15 +132,15 @@ jobs:
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
run: | run: |
docker compose -f build.docker-compose.dockerhub.yml build docker-compose -f build.docker-compose.dockerhub.yml build
docker compose -f build.docker-compose.dockerhub.yml push docker-compose -f build.docker-compose.dockerhub.yml push
- name: Create ZIP file to Deploy AWS Beanstalk - name: Create ZIP file to Deploy AWS Beanstalk
env: env:
ENV: ${{ needs.extract_environment.outputs.environment }} ENV: ${{ needs.extract_environment.outputs.environment }}
IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }} IMAGE_TAG: ${{ needs.semantic_release.outputs.new_release_version }}
ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }} ACCOUNT_ID: ${{ steps.aws.outputs.aws-account-id }}
NODE_EXPORTER_URL: ${{format('{0}.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest', steps.aws.outputs.aws-account-id)}} # ${{needs.extract_environment.outputs.environment == 'prd' && '611330257153.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest' || '468720548566.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest'}} NODE_EXPORTER_URL: ${{needs.extract_environment.outputs.environment == 'prd' && '611330257153.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest' || '468720548566.dkr.ecr.us-east-1.amazonaws.com\/monitoring\/node_exporter:latest'}}
run: | run: |
sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml sed -i -e "s/\${ENV}/$ENV/g" docker-compose.yml
sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml sed -i -e "s/\${IMAGE_TAG}/$IMAGE_TAG/g" docker-compose.yml
@@ -164,7 +168,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Extract Docs BlockId and PageId - name: Extract Docs BlockId and PageId
env: env:
+2 -8
View File
@@ -6,16 +6,10 @@ on:
jobs: jobs:
test: test:
runs-on: [self-hosted, prd] runs-on: self-hosted
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
id: aws
with:
aws-region: us-east-1
- name: Build - name: Build
env: env:
+1 -1
View File
@@ -1 +1 @@
18.17 18.10.0
+2 -2
View File
@@ -12,7 +12,7 @@
"start:debug" "start:debug"
], ],
"runtimeExecutable": "npm", "runtimeExecutable": "npm",
"runtimeVersion": "18.17", "runtimeVersion": "18.10.0",
"skipFiles": [ "skipFiles": [
"<node_internals>/**" "<node_internals>/**"
], ],
@@ -20,4 +20,4 @@
"console": "integratedTerminal" "console": "integratedTerminal"
} }
] ]
} }
+3 -3
View File
@@ -1,5 +1,5 @@
# install all dependencies # install all dependencies
FROM node:18.17-alpine as packages FROM node:18.10-alpine as packages
WORKDIR /app WORKDIR /app
COPY package.json package-lock.json ./ COPY package.json package-lock.json ./
RUN apk add --no-cache aws-cli \ RUN apk add --no-cache aws-cli \
@@ -7,12 +7,12 @@ RUN apk add --no-cache aws-cli \
&& npm install && npm install
# unit test specific build # unit test specific build
FROM node:18.17-alpine as test FROM node:18.10-alpine as test
WORKDIR /app WORKDIR /app
COPY --from=packages /app/node_modules ./node_modules COPY --from=packages /app/node_modules ./node_modules
COPY . ./ COPY . ./
FROM node:18.17-alpine FROM node:18.10-alpine
WORKDIR /app WORKDIR /app
COPY . /app/ COPY . /app/
COPY --from=packages /app/node_modules ./node_modules COPY --from=packages /app/node_modules ./node_modules
+1 -1
View File
@@ -12,7 +12,7 @@ These instructions will allow you to get a working copy of the project on your l
### 📋 Requirements ### 📋 Requirements
- [NodeJS v18.17 / NPM v9.6.7](https://nodejs.org/pt-br/download/) (you can opt to use [NVM](https://github.com/nvm-sh/nvm) to easily manage node versions) - [NodeJS v18.10.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) - 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 - Create your Access Key on the "Security credentials" menu
- Set the Access Key on your local development machine - Set the Access Key on your local development machine
+2 -231
View File
@@ -133,32 +133,7 @@
}, },
"get": { "get": {
"operationId": "ConnectionController_getAllConnections", "operationId": "ConnectionController_getAllConnections",
"parameters": [ "parameters": [],
{
"name": "search",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "size",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -515,45 +490,6 @@
] ]
} }
}, },
"/pipelinesV2/monitoring-dashboard": {
"get": {
"operationId": "PipelinesController_getMonitoringDashboard",
"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": { "/pipelinesV2": {
"post": { "post": {
"operationId": "PipelinesController_create", "operationId": "PipelinesController_create",
@@ -1800,118 +1736,6 @@
] ]
} }
}, },
"/customers/{id}/links": {
"get": {
"operationId": "CustomersController_getCustomerLinks",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerLinksResponse"
}
}
}
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
}
]
},
"put": {
"operationId": "CustomersController_setCustomerLinks",
"parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerLinkRequest"
}
}
}
},
"responses": {
"200": {
"description": ""
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/customers/token": {
"get": {
"operationId": "CustomersController_getCustomerToken",
"parameters": [
{
"name": "exp",
"required": true,
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/health": { "/health": {
"get": { "get": {
"operationId": "HealthController_check", "operationId": "HealthController_check",
@@ -1928,7 +1752,7 @@
} }
}, },
"info": { "info": {
"title": "Maestro - feat/new-customer-monitoring", "title": "Maestro - feat/generate-token",
"description": "This is the Maestro API", "description": "This is the Maestro API",
"version": "1.0.0", "version": "1.0.0",
"contact": {} "contact": {}
@@ -2209,9 +2033,6 @@
"ConnectionToCatalogDto": { "ConnectionToCatalogDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": {
"type": "string"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
@@ -3303,56 +3124,6 @@
"updated_at", "updated_at",
"updated_by" "updated_by"
] ]
},
"CustomerLink": {
"type": "object",
"properties": {
"href": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"iconSrc": {
"type": "string"
}
},
"required": [
"href",
"name",
"description"
]
},
"CustomerLinksResponse": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CustomerLink"
}
}
},
"required": [
"links"
]
},
"CustomerLinkRequest": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CustomerLink"
}
}
},
"required": [
"links"
]
} }
} }
} }
+91 -141
View File
@@ -542,6 +542,67 @@
] ]
} }
}, },
"/auth/oauth/magalu-id": {
"get": {
"operationId": "AuthController_magaluIdOauth",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "boolean"
}
}
}
}
},
"tags": [
"Auth"
]
}
},
"/auth/oauth/magalu-id/callback": {
"get": {
"operationId": "AuthController_magaluIdOauthCallback",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
}
],
"responses": {
"200": {
"description": ""
}
},
"tags": [
"Auth"
]
}
},
"/connections": { "/connections": {
"post": { "post": {
"operationId": "ConnectionController_createConnection", "operationId": "ConnectionController_createConnection",
@@ -582,32 +643,7 @@
}, },
"get": { "get": {
"operationId": "ConnectionController_getAllConnections", "operationId": "ConnectionController_getAllConnections",
"parameters": [ "parameters": [],
{
"name": "search",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "size",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -2688,45 +2724,6 @@
] ]
} }
}, },
"/pipelinesV2/monitoring-dashboard": {
"get": {
"operationId": "PipelinesController_getMonitoringDashboard",
"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": { "/pipelinesV2": {
"post": { "post": {
"operationId": "PipelinesController_create", "operationId": "PipelinesController_create",
@@ -5013,7 +5010,14 @@
"parameters": [], "parameters": [],
"responses": { "responses": {
"201": { "201": {
"description": "" "description": "",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
} }
}, },
"security": [ "security": [
@@ -5026,16 +5030,7 @@
"/customers/{id}/links": { "/customers/{id}/links": {
"get": { "get": {
"operationId": "CustomersController_getCustomerLinks", "operationId": "CustomersController_getCustomerLinks",
"parameters": [ "parameters": [],
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -5059,29 +5054,27 @@
}, },
"put": { "put": {
"operationId": "CustomersController_setCustomerLinks", "operationId": "CustomersController_setCustomerLinks",
"parameters": [ "parameters": [],
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"requestBody": { "requestBody": {
"required": true, "required": true,
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/CustomerLinkRequest" "$ref": "#/components/schemas/CustomerDto"
} }
} }
} }
}, },
"responses": { "responses": {
"200": { "200": {
"description": "" "description": "",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
} }
}, },
"tags": [ "tags": [
@@ -5114,7 +5107,7 @@
"200": { "200": {
"description": "", "description": "",
"content": { "content": {
"text/plain": { "application/json": {
"schema": { "schema": {
"type": "string" "type": "string"
} }
@@ -5135,28 +5128,6 @@
] ]
} }
}, },
"/customers/monitoring-dashboard": {
"get": {
"operationId": "CustomersController_getCustomerMonitoringDashboard",
"parameters": [],
"responses": {
"200": {
"description": ""
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/health": { "/health": {
"get": { "get": {
"operationId": "HealthController_check", "operationId": "HealthController_check",
@@ -5173,7 +5144,7 @@
} }
}, },
"info": { "info": {
"title": "Maestro - SOLENG-4628-feat/restrict-asset-options", "title": "Maestro - ci/dockerhub",
"description": "This is the Maestro API", "description": "This is the Maestro API",
"version": "1.0.0", "version": "1.0.0",
"contact": {} "contact": {}
@@ -5397,11 +5368,15 @@
}, },
"accessToken": { "accessToken": {
"type": "string" "type": "string"
},
"refreshToken": {
"type": "string"
} }
}, },
"required": [ "required": [
"permissions", "permissions",
"accessToken" "accessToken",
"refreshToken"
] ]
}, },
"CreateConnectionDto": { "CreateConnectionDto": {
@@ -5449,9 +5424,6 @@
"ConnectionToCatalogDto": { "ConnectionToCatalogDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"id": {
"type": "string"
},
"name": { "name": {
"type": "string" "type": "string"
}, },
@@ -7911,35 +7883,13 @@
"tags" "tags"
] ]
}, },
"CustomerLink": {
"type": "object",
"properties": {
"href": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
},
"iconSrc": {
"type": "string"
}
},
"required": [
"href",
"name",
"description"
]
},
"CustomerLinksResponse": { "CustomerLinksResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"links": { "links": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/CustomerLink" "type": "string"
} }
} }
}, },
@@ -7947,13 +7897,13 @@
"links" "links"
] ]
}, },
"CustomerLinkRequest": { "CustomerDto": {
"type": "object", "type": "object",
"properties": { "properties": {
"links": { "links": {
"type": "array", "type": "array",
"items": { "items": {
"$ref": "#/components/schemas/CustomerLink" "type": "string"
} }
} }
}, },
+1
View File
@@ -4,6 +4,7 @@ declare global {
NODE_ENV: 'test'; NODE_ENV: 'test';
ENV: 'local' | 'stg' | 'prd' | 'test'; ENV: 'local' | 'stg' | 'prd' | 'test';
LOCAL_ENV: 'stg' | 'prd'; LOCAL_ENV: 'stg' | 'prd';
CLOUD_ENVIRONMENT: 'aws' | 'gcp' | 'mgc';
DUC_URL: string; DUC_URL: string;
INFACTORY_URL: string; INFACTORY_URL: string;
+11206 -3334
View File
File diff suppressed because it is too large Load Diff
+36 -36
View File
@@ -6,7 +6,7 @@
"private": true, "private": true,
"license": "UNLICENSED", "license": "UNLICENSED",
"engines": { "engines": {
"node": "^18.17.0" "node": "18.10.0"
}, },
"scripts": { "scripts": {
"preinstall": "aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1", "preinstall": "aws codeartifact login --tool npm --namespace @dadosfera --repository dadosfera-npm --domain dadosfera --domain-owner 611330257153 --region us-east-1",
@@ -27,31 +27,30 @@
"test:e2e": "jest --config ./test/jest-e2e.json" "test:e2e": "jest --config ./test/jest-e2e.json"
}, },
"dependencies": { "dependencies": {
"@aws-sdk/client-secrets-manager": "^3.414.0", "@aws-sdk/client-secrets-manager": "^3.112.0",
"@dadosfera/dadosfera-logs": "^1.0.0-beta.4", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4",
"@dadosfera/protospack": "2.5.3", "@dadosfera/protospack-v2": "3.32.0-beta.2",
"@dadosfera/protospack-v2": "3.33.1-beta.2", "@grpc/grpc-js": "^1.6.7",
"@grpc/grpc-js": "^1.9.3", "@grpc/proto-loader": "^0.6.13",
"@grpc/proto-loader": "^0.7.9", "@nestjs/cli": "^9.4.2",
"@nestjs/cli": "^9.5.0", "@nestjs/common": "^9.4.0",
"@nestjs/common": "^9.4.3", "@nestjs/config": "^2.3.1",
"@nestjs/config": "^2.3.4", "@nestjs/core": "^9.4.0",
"@nestjs/core": "^9.4.3",
"@nestjs/mapped-types": "^1.2.2", "@nestjs/mapped-types": "^1.2.2",
"@nestjs/microservices": "^9.4.3", "@nestjs/microservices": "^9.4.0",
"@nestjs/passport": "^9.0.3", "@nestjs/passport": "^9.0.3",
"@nestjs/platform-express": "^9.4.3", "@nestjs/platform-express": "^9.4.0",
"@nestjs/schematics": "^9.2.0", "@nestjs/schematics": "^9.1.0",
"@nestjs/swagger": "^6.3.0", "@nestjs/swagger": "^6.3.0",
"@nestjs/testing": "^9.4.3", "@nestjs/testing": "^9.4.0",
"axios": "^0.27.2", "axios": "^1.6.2",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.14.0", "class-validator": "^0.14.0",
"cron-parser": "^4.9.0", "cron-parser": "^4.4.0",
"dotenv": "^14.3.2", "dotenv": "^14.3.2",
"elastic-apm-node": "^3.50.0", "elastic-apm-node": "^3.36.0",
"helmet": "^5.1.1", "helmet": "^5.1.0",
"jsonwebtoken": "^9.0.2", "jsonwebtoken": "^9.0.0",
"jwk-to-pem": "^2.0.5", "jwk-to-pem": "^2.0.5",
"mixpanel": "^0.17.0", "mixpanel": "^0.17.0",
"ms": "^3.0.0-canary.1", "ms": "^3.0.0-canary.1",
@@ -61,39 +60,40 @@
"passport-google-oauth20": "^2.0.0", "passport-google-oauth20": "^2.0.0",
"passport-hubspot-oauth2": "^1.0.3", "passport-hubspot-oauth2": "^1.0.3",
"passport-mailchimp": "^1.1.0", "passport-mailchimp": "^1.1.0",
"protospack": "2.5.2",
"reflect-metadata": "^0.1.13", "reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"rxjs": "^7.5.5", "rxjs": "^7.5.5",
"swagger-ui-express": "^4.6.3" "swagger-ui-express": "^4.4.0"
}, },
"overrides": { "overrides": {
"multer": "1.4.5-lts.1" "multer": "1.4.5-lts.1"
}, },
"devDependencies": { "devDependencies": {
"@types/express": "^4.17.17", "@types/express": "^4.17.13",
"@types/jest": "27.0.2", "@types/jest": "27.0.2",
"@types/jsonwebtoken": "^8.5.9", "@types/jsonwebtoken": "^8.5.8",
"@types/jwk-to-pem": "^2.0.1", "@types/jwk-to-pem": "^2.0.1",
"@types/multer": "^1.4.7", "@types/multer": "^1.4.7",
"@types/node": "^16.18.52", "@types/node": "^16.11.41",
"@types/passport-facebook": "^2.1.11", "@types/passport-facebook": "^2.1.11",
"@types/passport-google-oauth20": "^2.0.11", "@types/passport-google-oauth20": "^2.0.11",
"@types/passport-oauth2": "^1.4.12", "@types/passport-oauth2": "^1.4.11",
"@types/supertest": "^2.0.12", "@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/eslint-plugin": "^5.35.0",
"@typescript-eslint/parser": "^5.62.0", "@typescript-eslint/parser": "^5.35.0",
"eslint": "^8.49.0", "eslint": "^8.18.0",
"eslint-config-prettier": "^8.10.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.0.0",
"jest": "^27.5.1", "jest": "^27.5.1",
"nock": "^13.3.3", "nock": "^13.2.7",
"prettier": "^2.8.8", "prettier": "^2.7.1",
"source-map-support": "^0.5.20", "source-map-support": "^0.5.20",
"supertest": "^6.3.3", "supertest": "^6.2.3",
"ts-jest": "^27.1.5", "ts-jest": "^27.1.5",
"ts-loader": "^9.4.4", "ts-loader": "^9.3.1",
"ts-node": "^10.9.1", "ts-node": "^10.8.1",
"tsconfig-paths": "^3.14.2", "tsconfig-paths": "^3.14.1",
"typescript": "^4.9.5" "typescript": "^4.6.3"
} }
} }
+5 -1
View File
@@ -79,9 +79,13 @@ export class AuthenticationGuard
request, request,
mustBeAuthenticated: boolean, mustBeAuthenticated: boolean,
): RequestUser | false { ): RequestUser | false {
const accessToken = request.get('Authorization'); const accessToken: string = request.get('Authorization');
let accessTokenPayload: RequestUser; let accessTokenPayload: RequestUser;
this.logger.info(`mustBeAuthenticated: ${mustBeAuthenticated}`);
this.logger.info(
`accessToken (first 5 chars): ${accessToken?.slice(0, 5)}`,
);
// If the user isn't authenticated, an error will occurr anywhere here. // If the user isn't authenticated, an error will occurr anywhere here.
// Fancy error avoidance isn't performed by purpose, such as avoiding to access null values. // Fancy error avoidance isn't performed by purpose, such as avoiding to access null values.
try { try {
+11 -19
View File
@@ -67,6 +67,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
PIPELINE: { PIPELINE: {
title: { title: {
'pt-br': 'Coletar | Pipelines', 'pt-br': 'Coletar | Pipelines',
@@ -116,6 +117,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CONNECTION: { CONNECTION: {
title: { title: {
'pt-br': 'Coletar | Fontes de dados', 'pt-br': 'Coletar | Fontes de dados',
@@ -155,6 +157,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
NETWORK_CONFIG: { NETWORK_CONFIG: {
title: { title: {
'pt-br': 'Coletar | Redes', 'pt-br': 'Coletar | Redes',
@@ -184,6 +187,7 @@ export const PERMISSIONS_GROUPS = {
// }, // },
}, },
}, },
OUTPUT: { OUTPUT: {
title: { title: {
'pt-br': 'Output', 'pt-br': 'Output',
@@ -233,6 +237,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
TRANSFORMATIONS: { TRANSFORMATIONS: {
title: { title: {
'pt-br': 'Micro-transformações', 'pt-br': 'Micro-transformações',
@@ -282,6 +287,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CATALOG: { CATALOG: {
title: { title: {
'pt-br': 'Explorar | Catálogo', 'pt-br': 'Explorar | Catálogo',
@@ -362,6 +368,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CONNECTORS: { CONNECTORS: {
title: { title: {
'pt-br': 'Conectores', 'pt-br': 'Conectores',
@@ -411,6 +418,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
SNOWFLAKE: { SNOWFLAKE: {
title: { title: {
'pt-br': 'Explorar | Consolidar', 'pt-br': 'Explorar | Consolidar',
@@ -430,6 +438,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
ZENDESK: { ZENDESK: {
title: { title: {
'pt-br': 'Zendesk', 'pt-br': 'Zendesk',
@@ -449,6 +458,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
DATAVIZ: { DATAVIZ: {
title: { title: {
'pt-br': 'Analisar | Visualização', 'pt-br': 'Analisar | Visualização',
@@ -487,6 +497,7 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
MODULES: { MODULES: {
title: { title: {
'pt-br': 'Módulos da Dadosfera', 'pt-br': 'Módulos da Dadosfera',
@@ -583,25 +594,6 @@ export const PERMISSIONS_GROUPS = {
}, },
}, },
}, },
CUSTOMER: {
title: {
'pt-br': 'Organização',
'en-us': 'Organization',
'es-es': 'Organización',
},
permissions: {
MONITORING_DASHBOARD: {
seqid: 47,
claim: 'customer:monitoring-dashboard',
usage: PermissionUsages.PUBLIC,
name: {
'pt-br': 'Ver o dashboard de monitoramento',
'en-us': 'View the monitoring dashboard',
'es-es': 'Ver el dashboard de monitoreo',
},
},
},
},
}; };
export interface DadosferaModule { export interface DadosferaModule {
name: string; name: string;
+92 -28
View File
@@ -52,6 +52,7 @@ import jwt from 'jsonwebtoken';
import { LanguageEnum } from 'src/utils/languages.enum'; import { LanguageEnum } from 'src/utils/languages.enum';
import { Language } from 'src/decorators/language.decorator'; import { Language } from 'src/decorators/language.decorator';
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
import { getFrontendUrl } from 'src/utils/getFrontendBaseUrl';
@ApiTags('Auth') @ApiTags('Auth')
@ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }]) @ApiHeaders([{ name: 'dadosfera-lang', enum: LanguageEnum, required: false }])
@@ -59,7 +60,7 @@ import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator';
@Controller('auth') @Controller('auth')
export class AuthController { export class AuthController {
logger: DadosferaLogger; logger: DadosferaLogger;
redirectUrl: string; frontendRedirectUrl: string;
constructor( constructor(
@Inject(DadosferaLogger) @Inject(DadosferaLogger)
@@ -67,17 +68,7 @@ export class AuthController {
private authClient: AuthClientService, private authClient: AuthClientService,
) { ) {
this.logger = dadosferaLogger.logger; this.logger = dadosferaLogger.logger;
this.frontendRedirectUrl = getFrontendUrl('/auth/login').href;
switch (process.env.ENV) {
case 'stg':
this.redirectUrl = `https://app.${process.env.ENV}.dadosfera.ai/auth/login`;
break;
case 'prd':
this.redirectUrl = `https://app.dadosfera.ai/auth/login`;
break;
default:
this.redirectUrl = `http://localhost:4200/auth/login`;
}
} }
@Post('sign-in') @Post('sign-in')
@@ -105,7 +96,7 @@ export class AuthController {
customer_name, customer_name,
language, language,
}); });
this.logger.info(`metadata: ${metadata}`);
return this.authClient.refreshAccessToken({ refreshToken }, metadata); return this.authClient.refreshAccessToken({ refreshToken }, metadata);
} }
@@ -269,7 +260,13 @@ export class AuthController {
@UseGuards(AuthGuard('google-login')) @UseGuards(AuthGuard('google-login'))
@Redirect() @Redirect()
async googleOauthCallback(@Req() req) { async googleOauthCallback(@Req() req) {
const { url, email, token, language = 'pt-br' } = await this.callback(req); const {
url,
email,
token,
refreshToken,
language = 'pt-br',
} = await this.callback(req);
if (url.searchParams.get('error')) { if (url.searchParams.get('error')) {
this.logger.error('/oauth/google - ERROR'); this.logger.error('/oauth/google - ERROR');
return { url: url.href }; return { url: url.href };
@@ -279,6 +276,7 @@ export class AuthController {
.oauthSignIn({ .oauthSignIn({
username: email, username: email,
token, token,
refreshToken,
}) })
.then(({ session }) => { .then(({ session }) => {
this.logger.info('/oauth/google - SUCESS'); this.logger.info('/oauth/google - SUCESS');
@@ -308,18 +306,79 @@ export class AuthController {
return { url: url.href }; return { url: url.href };
} }
async callback(req: Request) { @ApiInternalOnlyEndpoint()
@Get('oauth/magalu-id')
@UseGuards(AuthGuard('magalu-id-login'))
magaluIdOauth() {
this.logger.info('/oauth/magalu-id');
return true;
}
@ApiInternalOnlyEndpoint()
@Get('oauth/magalu-id/callback')
@UseGuards(AuthGuard('magalu-id-login'))
@Redirect()
async magaluIdOauthCallback(@Req() req) {
const {
url,
email,
token,
refreshToken,
language = 'pt-br',
} = await this.callback(req, 'magalu-id');
if (url.searchParams.get('error')) {
this.logger.error('/oauth/magalu-id/callback - ERROR');
this.logger.error(url.searchParams.get('error'));
return { url: url.href };
}
await this.authClient
.oauthSignIn({
username: email,
token,
refreshToken,
})
.then(({ session }) => {
this.logger.info('/oauth/magalu-id/callback - SUCESS');
url.searchParams.set('session', session);
})
.catch((err) => {
this.logger.error('/oauth/magalu-id/callback - LOGIN ERROR');
let error = OauthErrors.INVALID_CREDENTIALS[language].error;
let error_description =
OauthErrors.INVALID_CREDENTIALS[language].error_description;
switch (err.details) {
case ErrorCodes.USER.NOT_FOUND:
error = OauthErrors.USER_NOT_FOUND[language].error;
error_description =
OauthErrors.USER_NOT_FOUND[language].error_description(email);
break;
case ErrorCodes.AUTH.UNAUTHORIZED:
error = OauthErrors.INVALID_SESSION[language].error;
error_description =
OauthErrors.INVALID_SESSION[language].error_description;
break;
}
url.searchParams.set('error', error);
url.searchParams.set('error_description', error_description);
return null;
});
return { url: url.href };
}
async callback(req: Request, oauth_type?: 'google' | 'magalu-id') {
const { error, state } = req.query; const { error, state } = req.query;
const { authInfo } = req; const { authInfo } = req;
const url = new URL(this.redirectUrl); const url = new URL(this.frontendRedirectUrl);
let email, token, error_title, error_description; let email, token, refreshToken, error_title, error_description;
let language: 'pt-br' | 'en-us' = 'pt-br'; const language: 'pt-br' | 'en-us' = 'pt-br';
// let stateObject;
const stateObject = jwt.verify( // try {
state as string, // stateObject = jwt.verify(state as string, process.env.JWT_PRIVATE_KEY);
process.env.JWT_PRIVATE_KEY, // } catch (error) {
); // console.log('error', error);
if (typeof stateObject != 'string') language = stateObject.language; // }
// if (typeof stateObject != 'string') language = stateObject.language;
if (error || !authInfo) { if (error || !authInfo) {
this.logger.error(error); this.logger.error(error);
@@ -330,11 +389,16 @@ export class AuthController {
OauthErrors.INVALID_CREDENTIALS[language].error_description; OauthErrors.INVALID_CREDENTIALS[language].error_description;
if (error) error_description += ` - [${error}]`; if (error) error_description += ` - [${error}]`;
} else { } else {
const { accessToken } = authInfo as any; const { accessToken, refreshToken: rt } = authInfo as any;
const { _json: userInfo } = req.user as any; const { _json: userInfo = {} } = req.user as any;
email = userInfo.email; email = userInfo.email;
token = accessToken; token = accessToken;
refreshToken = rt;
if (oauth_type === 'magalu-id') {
const jwtDecoded = jwt.decode(token, { json: true });
email = jwtDecoded.email;
}
} }
if (error_title) { if (error_title) {
@@ -342,6 +406,6 @@ export class AuthController {
url.searchParams.set('error_description', error_description); url.searchParams.set('error_description', error_description);
} }
return { token, email, url, language }; return { token, refreshToken, email, url, language };
} }
} }
+2
View File
@@ -8,6 +8,7 @@ import { AuthClientService } from './auth.service';
import { DucClient } from '../duc/client.config'; import { DucClient } from '../duc/client.config';
import { GoogleLoginStrategy } from './passport-strategies/google-strategy'; import { GoogleLoginStrategy } from './passport-strategies/google-strategy';
import { getOauthSecrets } from 'src/utils/OauthSecrets'; import { getOauthSecrets } from 'src/utils/OauthSecrets';
import { MagaluIdStrategy } from './passport-strategies/magalu-id-strategy';
const client = new DucClient(); const client = new DucClient();
@Module({ @Module({
@@ -17,6 +18,7 @@ const client = new DucClient();
AuthClientService, AuthClientService,
DadosferaLogger, DadosferaLogger,
GoogleLoginStrategy, GoogleLoginStrategy,
MagaluIdStrategy,
{ provide: 'OAUTH_SECRETS', useValue: getOauthSecrets() }, { provide: 'OAUTH_SECRETS', useValue: getOauthSecrets() },
], ],
exports: [AuthClientService], exports: [AuthClientService],
+3 -5
View File
@@ -17,6 +17,7 @@ import {
AuthResetPasswordRequest, AuthResetPasswordRequest,
AuthVerifyResetPasswordCodeRequest, AuthVerifyResetPasswordCodeRequest,
AuthConfirmResetPasswordRequest, AuthConfirmResetPasswordRequest,
AuthOauthSignInRequest,
} from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages'; } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import { DucClient } from '../duc/client.config'; import { DucClient } from '../duc/client.config';
import { Metadata } from '@grpc/grpc-js'; import { Metadata } from '@grpc/grpc-js';
@@ -162,10 +163,7 @@ export class AuthClientService implements OnModuleInit {
return lastValueFrom(this.authService.AuthGetSession({ session })); return lastValueFrom(this.authService.AuthGetSession({ session }));
} }
async oauthSignIn(data: { username: string; token: string }) { async oauthSignIn(data: AuthOauthSignInRequest) {
const { username, token } = data; return lastValueFrom(this.authService.AuthOauthSignIn(data));
return lastValueFrom(
this.authService.AuthOauthSignIn({ token, username, refreshToken: '' }),
);
} }
} }
+2
View File
@@ -117,4 +117,6 @@ export class AuthRefreshAccessTokenRes {
permissions: string[]; permissions: string[];
@ApiProperty() @ApiProperty()
accessToken: string; accessToken: string;
@ApiProperty()
refreshToken: string;
} }
@@ -0,0 +1,47 @@
import {
Strategy as Oauth2Strategy,
StrategyOptions,
VerifyCallback,
VerifyFunction,
} from 'passport-oauth2';
import { PassportStrategy } from '@nestjs/passport';
import { Inject, Injectable } from '@nestjs/common';
import { OauthSecrets } from 'src/utils/OauthSecrets';
import { Request } from 'express';
import jwt from 'jsonwebtoken';
@Injectable()
export class MagaluIdStrategy extends PassportStrategy(
Oauth2Strategy,
'magalu-id-login',
) {
redirect_uri: string;
constructor() {
const options: StrategyOptions = {
clientID: process.env.MAGALU_ID_CLIENT_ID,
clientSecret: process.env.MAGALU_ID_CLIENT_SECRET,
callbackURL: process.env.MAGALU_ID_CALLBACK_URL,
scope: ['openid'],
authorizationURL: 'https://id.magalu.com/login',
tokenURL: 'https://id.magalu.com/oauth/token',
};
const verify: VerifyFunction = (
accessToken: string,
refreshToken: string,
profile: any,
verified: VerifyCallback,
) => {
return verified(null, profile, { accessToken, refreshToken });
};
super(options, verify);
}
// authenticate(req: Request, options: Record<string, any>) {
// const language =
// req.headers['dadosfera-lang'] || req.query.language || 'pt-br';
// // options.state = jwt.sign({ language }, process.env.JWT_PRIVATE_KEY);
// super.authenticate(req, options);
// console.log('authenticate', JSON.stringify(options));
// }
}
+7 -1
View File
@@ -49,10 +49,16 @@ class CatalogService implements OnModuleInit {
_getNimbusUrl(body) { _getNimbusUrl(body) {
const customer = body.info.customer.toLowerCase(); const customer = body.info.customer.toLowerCase();
if (process.env.ENV === 'prd') { const cloud_environment = process.env.CLOUD_ENVIRONMENT || 'aws';
if (process.env.ENV === 'prd' && cloud_environment === 'aws') {
return `https://nimbus-${customer}.dadosfera.ai`; return `https://nimbus-${customer}.dadosfera.ai`;
} }
if (process.env.ENV === 'prd' && cloud_environment === 'mgc') {
return `https://nimbus-${customer}.dadosfera.com`;
}
return `https://nimbus-${customer}.${process.env.ENV.replace( return `https://nimbus-${customer}.${process.env.ENV.replace(
'local', 'local',
'stg', 'stg',
@@ -24,7 +24,6 @@ import {
ConnectionDetailsRes, ConnectionDetailsRes,
ConnectionRes, ConnectionRes,
ConnectionsRes, ConnectionsRes,
GetAllConnectionsReq,
UpdateConnectionDto, UpdateConnectionDto,
} from './dtos/connection'; } from './dtos/connection';
import { CreateConnectionDto } from './dtos/connection'; import { CreateConnectionDto } from './dtos/connection';
@@ -139,7 +138,7 @@ export class ConnectionController {
async getAllConnections( async getAllConnections(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Query() queries: GetAllConnectionsReq, @Query() queries,
): Promise<ConnectionsRes> { ): Promise<ConnectionsRes> {
this.logger.info('/connections - Get All Connection'); this.logger.info('/connections - Get All Connection');
+2 -14
View File
@@ -9,7 +9,6 @@ import {
ConnectionToCatalog, ConnectionToCatalog,
} from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/entities'; } from '@dadosfera/protospack-v2/dist/lib/ConnectionManager/interfaces/entities';
import { import {
GetAllConnectionRequest,
GetAllConnectionResponse, GetAllConnectionResponse,
GetConnectionDetailsResponse, GetConnectionDetailsResponse,
GetConnectionResponse, GetConnectionResponse,
@@ -22,7 +21,7 @@ export type ConnectionCredentialsType =
| 'oauth' | 'oauth'
| 'api_key' | 'api_key'
| 'service_account' | 'service_account'
| 'headers_auth'; | 'headers_authF';
export interface ConnectionApiConnection { export interface ConnectionApiConnection {
config_id: string; config_id: string;
plugin: string; plugin: string;
@@ -95,6 +94,7 @@ export class ConnectionDto implements Connection {
export class ConnectionToCatalogDto implements ConnectionToCatalog { export class ConnectionToCatalogDto implements ConnectionToCatalog {
// ---Automatically generated information - will not be sent by the frontend--- // // ---Automatically generated information - will not be sent by the frontend--- //
id: string;
customer_id: string; customer_id: string;
updated_at: string; updated_at: string;
created_at: string; created_at: string;
@@ -104,9 +104,6 @@ export class ConnectionToCatalogDto implements ConnectionToCatalog {
customer_name: string; customer_name: string;
// ---Information sent by the frontend--- // // ---Information sent by the frontend--- //
@ApiPropertyOptional()
id: string;
@ApiProperty() @ApiProperty()
name: string; name: string;
@@ -150,15 +147,6 @@ export class UpdateConnectionDto extends PickType(ConnectionDto, [
'properties', 'properties',
]) {} ]) {}
export class GetAllConnectionsReq implements GetAllConnectionRequest {
@ApiPropertyOptional()
search?: string;
@ApiPropertyOptional()
page?: string;
@ApiPropertyOptional()
size?: string;
}
export class ConnectionsRes implements GetAllConnectionResponse { export class ConnectionsRes implements GetAllConnectionResponse {
@ApiProperty({ type: [ConnectionToCatalogDto] }) @ApiProperty({ type: [ConnectionToCatalogDto] })
connections: ConnectionToCatalogDto[]; connections: ConnectionToCatalogDto[];
+10 -29
View File
@@ -4,28 +4,26 @@ import {
Body, Body,
Controller, Controller,
Get, Get,
HttpCode,
HttpStatus,
Inject, Inject,
Param, Param,
Put, Put,
Query, Query,
UseFilters, UseFilters,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiOkResponse, ApiProduces, ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum'; import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
import { import {
Authenticated, Authenticated,
RequireAllPermissions, RequireAllPermissions,
} from 'src/decorators/authentication.decorator'; } from 'src/decorators/authentication.decorator';
import { ApiInternalOnlyEndpoint } from 'src/decorators/swagger.decorator'; import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
import { CustomersService } from './customers.service'; import { CustomersService } from './customers.service';
import { CustomerLinkRequest, CustomerLinksResponse } from './dtos/customers'; import { CustomerDto, CustomerLinksResponse } from './dtos/customers';
import { RequestUser, User } from 'src/decorators/user.decorator'; import { RequestUser, User } from 'src/decorators/user.decorator';
import type { StringValue } from 'ms'; import type { StringValue } from 'ms';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
@ApiInternalOnlyController()
@ApiTags('Customers') @ApiTags('Customers')
@Controller('customers') @Controller('customers')
@Authenticated() @Authenticated()
@@ -42,8 +40,7 @@ export class CustomersController {
} }
@Get(':id/links') @Get(':id/links')
@ApiOkResponse({ type: CustomerLinksResponse }) async getCustomerLinks(@Param('id') id): Promise<CustomerLinksResponse> {
async getCustomerLinks(@Param('id') id: string) {
this.logger.info('getCustomerLinks', { id }); this.logger.info('getCustomerLinks', { id });
const links = await this.customersService.getLinks(id); const links = await this.customersService.getLinks(id);
return { links }; return { links };
@@ -51,20 +48,17 @@ export class CustomersController {
@Put(':id/links') @Put(':id/links')
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN) @RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
@ApiOkResponse() setCustomerLinks(
@HttpCode(HttpStatus.OK) @Body() body: CustomerDto,
async setCustomerLinks( @Param('id') id,
@Body() body: CustomerLinkRequest, ): Promise<IdResponse> {
@Param('id') id: string,
) {
const { links } = body; const { links } = body;
this.logger.info('setCustomerLinks', { id, links }); this.logger.info('setCustomerLinks', { id, links });
await this.customersService.setLinks(id, links); return this.customersService.setLinks(id, links);
} }
@Get('token') @Get('token')
@RequireAllPermissions(PERMISSIONS_GROUPS.AUTH.permissions.GENERATE_TOKEN) @RequireAllPermissions(PERMISSIONS_GROUPS.AUTH.permissions.GENERATE_TOKEN)
@ApiProduces('text/plain')
async getCustomerToken( async getCustomerToken(
@Query('exp') exp: StringValue, @Query('exp') exp: StringValue,
@User() user: RequestUser, @User() user: RequestUser,
@@ -77,17 +71,4 @@ export class CustomersController {
}; };
return this.customersService.generateToken(exp, data); return this.customersService.generateToken(exp, data);
} }
@Get('monitoring-dashboard')
@RequireAllPermissions(
PERMISSIONS_GROUPS.CUSTOMER.permissions.MONITORING_DASHBOARD,
)
async getCustomerMonitoringDashboard(
@User() user: RequestUser,
): Promise<{ url: string }> {
this.logger.info('getCustomerMonitoringDashboard');
const metadata = PackTheMetadata(user);
return this.customersService.getMonitoringDashboardUrl(metadata);
}
} }
+2 -9
View File
@@ -4,18 +4,11 @@ import { ClientsModule } from '@nestjs/microservices';
import { DucClient } from '../duc/client.config'; import { DucClient } from '../duc/client.config';
import { CustomersController } from './customers.controller'; import { CustomersController } from './customers.controller';
import { CustomersService } from './customers.service'; import { CustomersService } from './customers.service';
import { PipelinesClientConfiguration } from '../pipelinesV2/pipelines-client';
const ducClient = new DucClient(); const client = new DucClient();
const piFactoryClient = new PipelinesClientConfiguration();
@Module({ @Module({
imports: [ imports: [ClientsModule.register([client.providerOptions])],
ClientsModule.register([
ducClient.providerOptions,
piFactoryClient.providerOptions,
]),
],
controllers: [CustomersController], controllers: [CustomersController],
providers: [CustomersService, DadosferaLogger], providers: [CustomersService, DadosferaLogger],
exports: [CustomersService], exports: [CustomersService],
@@ -22,34 +22,20 @@ import {
} from '@aws-sdk/client-secrets-manager'; } from '@aws-sdk/client-secrets-manager';
import getEnv from 'src/utils/getEnv'; import getEnv from 'src/utils/getEnv';
import { logger } from 'elastic-apm-node'; import { logger } from 'elastic-apm-node';
import {
ReadService,
ProtoServices as PipelineProtoServices,
} from '@dadosfera/protospack-v2/dist/lib/PipelineV2';
import { Metadata } from '@grpc/grpc-js';
import { PipelinesClientConfiguration } from '../pipelinesV2/pipelines-client';
// This function will accept any string, which may result in a bug. // This function will accept any string, which may result in a bug.
@Injectable() @Injectable()
export class CustomersService implements OnModuleInit { export class CustomersService implements OnModuleInit {
private customerService: CustomersProtoService; private customerService: CustomersProtoService;
private pipelineReadService: ReadService.PipelineV2ReadService;
constructor( constructor(
@Inject(DucClient.name) private readonly grpcClient: ClientGrpc, @Inject(DucClient.name) private readonly grpcClient: ClientGrpc,
@Inject(PipelinesClientConfiguration.name)
private readonly pipelinesGrpcClient: ClientGrpc,
) {} ) {}
onModuleInit() { onModuleInit() {
this.customerService = this.grpcClient.getService<CustomersProtoService>( this.customerService = this.grpcClient.getService<CustomersProtoService>(
ProtoServices.CustomersProtoService, ProtoServices.CustomersProtoService,
); );
this.pipelineReadService =
this.pipelinesGrpcClient.getService<ReadService.PipelineV2ReadService>(
PipelineProtoServices.PipelineV2ReadService,
);
} }
async getLinks(customerId: string) { async getLinks(customerId: string) {
@@ -134,21 +120,4 @@ export class CustomersService implements OnModuleInit {
// const decoded = jwt.decode(jwt_token, { complete: true }); // const decoded = jwt.decode(jwt_token, { complete: true });
return jwt_token; return jwt_token;
} }
async getMonitoringDashboardUrl(metadata: Metadata) {
logger.info('CustomersService - getMonitoringDashboardUrl');
const res = await lastValueFrom(
this.pipelineReadService.PipelineV2GetDashboardUrl(
{
dashboard_id: '45',
exp: '15m',
metabase_customer_name: 'dadosferatech',
},
metadata,
),
);
logger.info('Done');
return res;
}
} }
+5 -15
View File
@@ -1,22 +1,12 @@
import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities'; import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { ApiProperty } from '@nestjs/swagger';
export class CustomerLink implements Link { export class CustomerDto {
@ApiProperty() @ApiProperty()
href: string; links: Link[];
@ApiProperty()
name: string;
@ApiProperty()
description: string;
@ApiPropertyOptional()
iconSrc: string;
}
export class CustomerLinkRequest {
@ApiProperty({ type: [CustomerLink] })
links: CustomerLink[];
} }
export class CustomerLinksResponse { export class CustomerLinksResponse {
@ApiProperty({ type: [CustomerLink] }) @ApiProperty()
links: CustomerLink[]; links: Link[];
} }
+1 -1
View File
@@ -1,4 +1,4 @@
import { Info } from '@dadosfera/protospack/dist/lib/interfaces'; import { Info } from 'protospack/dist/lib/interfaces';
interface Values { interface Values {
jdbc_user: string; jdbc_user: string;
@@ -15,6 +15,8 @@ export class MixpanelController {
@Post(':id') @Post(':id')
async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) { async trackEvent(@Param('id') id, @Body() body, @User() user: RequestUser) {
delete body.info; delete body.info;
//TODO: remove this when mixpanel track is working
return true;
const mixpanel = init(this.mixpanelToken); const mixpanel = init(this.mixpanelToken);
const separator = user.username.includes('-') ? '-' : '.'; const separator = user.username.includes('-') ? '-' : '.';
+2 -6
View File
@@ -1,9 +1,6 @@
import { ConflictException, Inject, OnModuleInit } from '@nestjs/common'; import { ConflictException, Inject, OnModuleInit } from '@nestjs/common';
import { ClientGrpc } from '@nestjs/microservices'; import { ClientGrpc } from '@nestjs/microservices';
import { import { PipelineServicesNames, PipelinesServiceInterface } from 'protospack';
PipelineServicesNames,
PipelinesServiceInterface,
} from '@dadosfera/protospack';
import { lastValueFrom } from 'rxjs'; import { lastValueFrom } from 'rxjs';
import { IIdRequest } from './interfaces'; import { IIdRequest } from './interfaces';
@@ -14,10 +11,9 @@ import { PipelinesClientConfiguration } from './pipelines-client';
export class PipelinesClientService implements OnModuleInit { export class PipelinesClientService implements OnModuleInit {
private pipelineService: PipelinesServiceInterface; private pipelineService: PipelinesServiceInterface;
logger: DadosferaLogger; logger: DadosferaLogger;
constructor( constructor(
@Inject(DadosferaLogger) @Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger, dadosferaLogger: DadosferaLogger,
@Inject(PipelinesClientConfiguration.name) @Inject(PipelinesClientConfiguration.name)
private readonly grpcClient: ClientGrpc, private readonly grpcClient: ClientGrpc,
) { ) {
+1 -1
View File
@@ -1,4 +1,4 @@
import { Info } from '@dadosfera/protospack/dist/lib/interfaces'; import { Info } from 'protospack/dist/lib/interfaces';
export interface ICreatePipelineDto { export interface ICreatePipelineDto {
input: IdRequest; input: IdRequest;
+1 -1
View File
@@ -3,7 +3,7 @@ import {
GrpcOptions, GrpcOptions,
Transport, Transport,
} from '@nestjs/microservices'; } from '@nestjs/microservices';
import { PipelinePackages, PipelineProtoFilePath } from '@dadosfera/protospack'; import { PipelinePackages, PipelineProtoFilePath } from 'protospack';
import { credentials } from '@grpc/grpc-js'; import { credentials } from '@grpc/grpc-js';
const isLocalConnection = !!process.env.PIFACTORY_URL?.includes('0.0.0.0'); const isLocalConnection = !!process.env.PIFACTORY_URL?.includes('0.0.0.0');
+1 -1
View File
@@ -1,5 +1,5 @@
import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger'; import { ApiProperty, ApiPropertyOptional, OmitType } from '@nestjs/swagger';
import { Info } from '@dadosfera/protospack/dist/lib/interfaces'; import { Info } from 'protospack/dist/lib/interfaces';
export class IPipelineV2 { export class IPipelineV2 {
@ApiProperty() @ApiProperty()
@@ -14,7 +14,6 @@ import {
Patch, Patch,
HttpException, HttpException,
BadRequestException, BadRequestException,
CacheTTL,
} from '@nestjs/common'; } from '@nestjs/common';
import { import {
ApiCreatedResponse, ApiCreatedResponse,
@@ -87,18 +86,6 @@ export class PipelinesController {
this.logger = dadosferaLogger.logger; this.logger = dadosferaLogger.logger;
} }
@Get('monitoring-dashboard')
async getMonitoringDashboard(@User() user: RequestUser) {
this.logger.info('PipelinesController - getMonitoringDashboard', { user });
const metadata = PackTheMetadata(user);
const response =
await this.pipelinesClientService.getMonitoringDashboardUrl(metadata);
return response;
}
@Post() @Post()
@ApiCreatedResponse({ type: IPipelineV2 }) @ApiCreatedResponse({ type: IPipelineV2 })
async create( async create(
@@ -321,22 +321,4 @@ export class PipelinesService implements OnModuleInit {
); );
}); });
} }
async getMonitoringDashboardUrl(metadata: Metadata) {
this.logger.info('PipelinesClientService - getMonitoringDashboardUrl');
const res = await lastValueFrom(
this.pipelineReadService.PipelineV2GetDashboardUrl(
{
dashboard_id: '83',
exp: '15m',
metabase_customer_name: 'dadosferatech',
},
metadata,
),
);
this.logger.info('Done');
return res;
}
} }
+1 -1
View File
@@ -1,4 +1,4 @@
import { Info } from '@dadosfera/protospack/dist/lib/interfaces'; import { Info } from 'protospack/dist/lib/interfaces';
export interface ICreateTransformationsRequest { export interface ICreateTransformationsRequest {
transformations: Transformation[]; transformations: Transformation[];
+6 -2
View File
@@ -152,7 +152,9 @@ export class UsersController {
}); });
this.logger.info('createUser', { user }); this.logger.info('createUser', { user });
this.userService.setLanguage(language); this.userService.setLanguage(language);
this.logger.info(`user: ${user}`);
this.logger.info(`body: ${body}`);
this.logger.info(`metadata: ${metadata}`);
return await this.userService.createUser(body, metadata); return await this.userService.createUser(body, metadata);
} }
@@ -171,7 +173,9 @@ export class UsersController {
access_token: user.access_token, access_token: user.access_token,
language, language,
}); });
this.logger.info(`user: ${user}`);
this.logger.info(`body: ${body}`);
this.logger.info(`metadata: ${metadata}`);
return await this.userService.batchCreateUser(body, metadata); return await this.userService.batchCreateUser(body, metadata);
} }
+20
View File
@@ -0,0 +1,20 @@
import getEnv from './getEnv';
export function getFrontendUrl(path?: string): URL {
const frontendUrl = new URL('https://app.dadosfera.ai');
if (path) frontendUrl.pathname = path;
const env = getEnv();
if (process.env.ENV === 'local') {
frontendUrl.protocol = 'http';
frontendUrl.host = 'localhost:4200';
return frontendUrl;
}
if (process.env.CLOUD_ENVIRONMENT === 'mgc')
frontendUrl.host = 'app.dadosfera.com';
if (env !== 'prd')
frontendUrl.host = frontendUrl.host.replace('app.', `app.${env}.`);
return frontendUrl;
}