Compare commits

...
45 Commits
Author SHA1 Message Date
Gabriel Amorim 0970c748e0 Merge pull request #216 from dadosfera/feat/generate-token
Feat: generate token
2023-05-17 10:03:00 -03:00
Gabriel Amorim aabd741cad FEAT: new Customer Get Token Route 2023-05-16 09:05:05 -03:00
Gabriel Amorim 950c6414b6 FIX: update to new nestjs version 2023-05-12 08:28:33 -03:00
Gabriel Amorim d1149a4d52 Merge pull request #215 from dadosfera/alpha
FIX: permissions.enum.ts
2023-05-08 16:02:33 -03:00
Gabriel Amorim 4c6f4bfd84 FIX: renamed reference to intelligence permission 2023-05-08 15:56:52 -03:00
Gabriel Amorim 9caf3dc67f FIX: renamed reference to intelligence permission 2023-05-08 15:48:46 -03:00
Beatriz Antunes 635c4da48c Update permissions.enum.ts 2023-05-08 15:44:05 -03:00
Gabriel Amorim 44bb205483 Merge pull request #214 from dadosfera/fix/get-links-permission
FIX: remove permission check to get customer links
2023-05-05 13:52:38 -03:00
Gabriel Amorim edb4622684 FIX: remove permission to get customer links 2023-05-05 12:13:55 -03:00
Victor Radael abb46d78da Merge pull request #212 from dadosfera/feature/customer-links
SOLENG-1481 - Customer links endpoints
2023-04-17 17:01:41 -03:00
Victor Radael 04fdc0368a Merge pull request #213 from dadosfera/update/hubspot-tables
UPDATE: HubspotTables
2023-04-15 14:49:47 -03:00
Victor Radael 50d76622c5 UPDATE: HubspotTables 2023-04-15 14:45:18 -03:00
Victor Radael 238f56cb76 Merge branch 'SOLENG-1736' into feature/customer-links 2023-04-14 14:44:57 -03:00
Victor Radael e721d6f5f5 Merge branch 'main' into feature/customer-links 2023-04-14 13:30:57 -03:00
Victor Radael 44df13e820 UPDATE: Att protospack-v2 version 2023-04-14 13:13:47 -03:00
Victor Radael 1fd0f79dd5 Att hubspot connection 2023-04-13 15:41:44 -03:00
Victor Radael 1b92371737 Att hubspot connection 2023-04-13 14:55:33 -03:00
Colombo bf5b3484a1 FEAT: add controller method interfaces 2023-04-11 20:39:47 -03:00
Colombo eb1e248d4b FEAT: add customer (links) endpoint 2023-04-11 17:04:40 -03:00
Colombo 0827414051 FEAT: add new dto property 2023-04-10 19:36:36 -03:00
Colombo 081986607b CHORE: change protospack package to beta 2023-04-06 17:07:23 -03:00
Gabriel Amorim 189080199a Merge pull request #211 from dadosfera/feat/trigger-catalog-task
Feat/trigger catalog task
2023-03-17 12:14:15 -03:00
Gabriel Amorim 55281e3965 FIX: docs 2023-03-16 17:58:11 -03:00
Gabriel Amorim db8a6175e8 new protospack version 2023-03-16 17:45:15 -03:00
Gabriel Amorim 7b0d4dd5bc FIX: set route params type 2023-03-16 17:45:03 -03:00
Gabriel Amorim 6fd277ef3a docs 2023-03-14 16:02:22 -03:00
Gabriel Amorim 7b25bfdb69 FIX: add table_schema to request 2023-03-14 16:00:57 -03:00
Gabriel Amorim 2abc19c589 FEAT: trigger and get dataset cataloging task 2023-03-14 13:39:21 -03:00
Gabriel Amorim faf6b1df75 Merge pull request #210 from dadosfera/fix/delete-connector
Fix/delete connector
2023-03-09 18:14:14 -03:00
Gabriel Amorim 422be4a422 swaggers 2023-03-06 12:11:13 -03:00
Gabriel Amorim da136e0ef0 FIX: better swagger generation strategy (Only PRD server on external docs) 2023-03-06 12:10:12 -03:00
Gabriel Amorim 737cc9b8ea FIX: removed wrong JSON.parse on connector delete response 2023-03-06 12:09:29 -03:00
Gabriel Amorim 23f6b179fd Merge pull request #209 from dadosfera/feat/google-sheets-link
Feat/google sheets link
2023-02-27 16:03:52 -03:00
Gabriel Amorim 03e451c21d Merge branch 'main' into feat/google-sheets-link 2023-02-27 11:26:03 -03:00
Gabriel Amorim be061a0fb9 Merge pull request #208 from dadosfera/fix/upload-files
FIX: create pipeline from any file type on upload
2023-02-24 17:10:08 -03:00
Gabriel Amorim c83f6a68d1 update protospack version 2023-02-24 16:50:29 -03:00
Gabriel Amorim 2646e3e4f6 FEAT: return google sheets entire link 2023-02-24 15:58:06 -03:00
Gabriel Amorim 06424d6bcf FIX: docs 2023-02-24 14:47:49 -03:00
Gabriel Amorim 45b82515fc FIX: do not return config_controls that the pipeline don't have 2023-02-24 14:31:50 -03:00
Gabriel Amorim a9cc951e34 FIX: new error codes 2023-02-23 17:14:47 -03:00
Gabriel Amorim 93ccf506fb FIX: csv import with header=false 2023-02-22 15:13:36 -03:00
Gabriel Amorim 706d0ccfa0 FIX: get right image url 2023-02-22 14:32:41 -03:00
Beatriz Antunes c2eec4e95c Merge pull request #207 from dadosfera/fix/hubspot-chat-permission
FIX: change permission to access support chat
2023-02-22 13:10:54 -03:00
Gabriel Amorim ac3132b6eb FIX: create pipeline from any file type on upload 2023-02-22 10:18:28 -03:00
Gabriel Rosa a2c1f2da6f FIX: new zendesk permission 2023-02-17 14:33:14 -03:00
34 changed files with 3164 additions and 2330 deletions
+1 -1
View File
@@ -1 +1 @@
18.3.0 18.10.0
+3 -3
View File
@@ -1,5 +1,5 @@
# install all dependencies # install all dependencies
FROM node:18.3.0-alpine3.15 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.3.0-alpine3.15 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.3.0-alpine3.15 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.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) - [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
+335 -13
View File
@@ -241,7 +241,16 @@
}, },
"get": { "get": {
"operationId": "ConnectionController_getConnectionDetails", "operationId": "ConnectionController_getConnectionDetails",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -449,7 +458,16 @@
"/inputs/{id}": { "/inputs/{id}": {
"get": { "get": {
"operationId": "InputsController_findOne", "operationId": "InputsController_findOne",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -534,6 +552,46 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "search",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "filters",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "size",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "type",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -606,6 +664,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -638,6 +704,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -670,6 +744,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -709,6 +791,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -746,6 +836,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -783,6 +881,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -945,6 +1051,14 @@
"type": "string" "type": "string"
} }
}, },
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{ {
"name": "shared", "name": "shared",
"required": true, "required": true,
@@ -985,6 +1099,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"requestBody": { "requestBody": {
@@ -1085,6 +1207,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -1127,6 +1257,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -1169,6 +1307,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -1362,6 +1508,108 @@
] ]
} }
}, },
"/catalog/dataset-catalog-task": {
"post": {
"operationId": "CatalogController_triggerCatalog",
"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/TriggerCatalogReq"
}
}
}
},
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TriggerCatalogRes"
}
}
}
}
},
"tags": [
"Catalog"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/catalog/dataset-catalog-task/{session}": {
"get": {
"operationId": "CatalogController_getCatalogTask",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
},
{
"name": "session",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetDatasetCatalogTaskRes"
}
}
}
}
},
"tags": [
"Catalog"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/oauth/hubspot": { "/oauth/hubspot": {
"get": { "get": {
"operationId": "OauthController_oauthHubspot", "operationId": "OauthController_oauthHubspot",
@@ -1504,24 +1752,16 @@
} }
}, },
"info": { "info": {
"title": "Maestro - feat/docs-refactor", "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": {}
}, },
"tags": [], "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", "url": "https://maestro.dadosfera.ai",
"description": "Ambiente PRD" "description": "Dadosfera API"
} }
], ],
"components": { "components": {
@@ -1572,6 +1812,12 @@
}, },
"scheduleLimit": { "scheduleLimit": {
"type": "string" "type": "string"
},
"links": {
"type": "array",
"items": {
"type": "string"
}
} }
}, },
"required": [ "required": [
@@ -1579,7 +1825,8 @@
"id", "id",
"name", "name",
"tier", "tier",
"scheduleLimit" "scheduleLimit",
"links"
] ]
}, },
"AuthUser": { "AuthUser": {
@@ -2173,6 +2420,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -2213,6 +2463,7 @@
"required": [ "required": [
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -2233,6 +2484,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -2280,6 +2534,7 @@
"id", "id",
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -2802,6 +3057,73 @@
"required": [ "required": [
"comment" "comment"
] ]
},
"TriggerCatalogReq": {
"type": "object",
"properties": {
"table_name": {
"type": "string",
"description": "Name of the table on Snowflake",
"example": "TB__4DXSD4_TEST"
},
"table_schema": {
"type": "string",
"description": "Schema where the asset is located. If not set defaults to \"PUBLIC\""
},
"pipeline_id": {
"type": "string",
"description": "Id of the pipeline that generated the asset."
}
},
"required": [
"table_name"
]
},
"TriggerCatalogRes": {
"type": "object",
"properties": {
"session": {
"type": "string"
}
},
"required": [
"session"
]
},
"GetDatasetCatalogTaskRes": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"customer_name": {
"type": "string"
},
"session_id": {
"type": "string"
},
"status": {
"type": "string"
},
"table_name": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"updated_by": {
"type": "string"
}
},
"required": [
"created_at",
"customer_name",
"session_id",
"status",
"table_name",
"updated_at",
"updated_by"
]
} }
} }
} }
+523 -22
View File
@@ -690,7 +690,16 @@
}, },
"get": { "get": {
"operationId": "ConnectionController_getConnectionDetails", "operationId": "ConnectionController_getConnectionDetails",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -2574,7 +2583,16 @@
"/inputs/{id}": { "/inputs/{id}": {
"get": { "get": {
"operationId": "InputsController_findOne", "operationId": "InputsController_findOne",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -2707,6 +2725,46 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "search",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "filters",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "size",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "page",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
},
{
"name": "type",
"required": false,
"in": "query",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2779,6 +2837,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2811,6 +2877,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2843,6 +2917,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2882,6 +2964,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2919,6 +3009,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2959,6 +3057,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -2996,6 +3102,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -3177,6 +3291,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -3207,7 +3329,16 @@
"summary": "", "summary": "",
"deprecated": true, "deprecated": true,
"description": "This method is deprecated. Please use route /pipelinesV2/start/:id instead", "description": "This method is deprecated. Please use route /pipelinesV2/start/:id instead",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -3239,7 +3370,16 @@
"summary": "", "summary": "",
"deprecated": true, "deprecated": true,
"description": "This method is deprecated. Please use route /pipelinesV2/:id/status instead", "description": "This method is deprecated. Please use route /pipelinesV2/:id/status instead",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -3310,7 +3450,16 @@
"/transformations/{id}": { "/transformations/{id}": {
"get": { "get": {
"operationId": "TransformationsController_findOne", "operationId": "TransformationsController_findOne",
"parameters": [], "parameters": [
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"200": { "200": {
"description": "", "description": "",
@@ -3618,6 +3767,14 @@
"type": "string" "type": "string"
} }
}, },
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
},
{ {
"name": "shared", "name": "shared",
"required": true, "required": true,
@@ -3658,6 +3815,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"requestBody": { "requestBody": {
@@ -3758,6 +3923,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -3793,6 +3966,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -3835,6 +4016,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -3877,6 +4066,14 @@
], ],
"type": "string" "type": "string"
} }
},
{
"name": "id",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -4150,6 +4347,108 @@
] ]
} }
}, },
"/catalog/dataset-catalog-task": {
"post": {
"operationId": "CatalogController_triggerCatalog",
"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/TriggerCatalogReq"
}
}
}
},
"responses": {
"201": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TriggerCatalogRes"
}
}
}
}
},
"tags": [
"Catalog"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/catalog/dataset-catalog-task/{session}": {
"get": {
"operationId": "CatalogController_getCatalogTask",
"parameters": [
{
"name": "dadosfera-lang",
"in": "header",
"required": false,
"schema": {
"enum": [
"pt-br",
"en-us"
],
"type": "string"
}
},
{
"name": "session",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetDatasetCatalogTaskRes"
}
}
}
}
},
"tags": [
"Catalog"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/terms-of-use/token": { "/terms-of-use/token": {
"get": { "get": {
"operationId": "TermsOfUseController_getToken", "operationId": "TermsOfUseController_getToken",
@@ -4660,6 +4959,107 @@
] ]
} }
}, },
"/customers/{id}/links": {
"get": {
"operationId": "CustomersController_getCustomerLinks",
"parameters": [],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerLinksResponse"
}
}
}
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
}
]
},
"put": {
"operationId": "CustomersController_setCustomerLinks",
"parameters": [],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CustomerDto"
}
}
}
},
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
}
}
},
"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": {
"application/json": {
"schema": {
"type": "string"
}
}
}
}
},
"tags": [
"Customers"
],
"security": [
{
"access-token": []
},
{
"access-token": []
}
]
}
},
"/health": { "/health": {
"get": { "get": {
"operationId": "HealthController_check", "operationId": "HealthController_check",
@@ -4676,26 +5076,13 @@
} }
}, },
"info": { "info": {
"title": "Maestro - feat/docs-refactor", "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": {}
}, },
"tags": [], "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": { "components": {
"securitySchemes": { "securitySchemes": {
"access-token": { "access-token": {
@@ -4744,6 +5131,12 @@
}, },
"scheduleLimit": { "scheduleLimit": {
"type": "string" "type": "string"
},
"links": {
"type": "array",
"items": {
"type": "string"
}
} }
}, },
"required": [ "required": [
@@ -4751,7 +5144,8 @@
"id", "id",
"name", "name",
"tier", "tier",
"scheduleLimit" "scheduleLimit",
"links"
] ]
}, },
"AuthUser": { "AuthUser": {
@@ -6346,6 +6740,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -6386,6 +6783,7 @@
"required": [ "required": [
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -6406,6 +6804,9 @@
"description": { "description": {
"type": "string" "type": "string"
}, },
"type": {
"type": "string"
},
"connection_id": { "connection_id": {
"type": "string" "type": "string"
}, },
@@ -6453,6 +6854,7 @@
"id", "id",
"name", "name",
"description", "description",
"type",
"connection_id", "connection_id",
"cron", "cron",
"connector_name", "connector_name",
@@ -6520,6 +6922,9 @@
}, },
"header": { "header": {
"type": "boolean" "type": "boolean"
},
"engine": {
"type": "string"
} }
}, },
"required": [ "required": [
@@ -6528,7 +6933,8 @@
"description", "description",
"encoding", "encoding",
"sep", "sep",
"header" "header",
"engine"
] ]
}, },
"IRole": { "IRole": {
@@ -7044,6 +7450,73 @@
"comment" "comment"
] ]
}, },
"TriggerCatalogReq": {
"type": "object",
"properties": {
"table_name": {
"type": "string",
"description": "Name of the table on Snowflake",
"example": "TB__4DXSD4_TEST"
},
"table_schema": {
"type": "string",
"description": "Schema where the asset is located. If not set defaults to \"PUBLIC\""
},
"pipeline_id": {
"type": "string",
"description": "Id of the pipeline that generated the asset."
}
},
"required": [
"table_name"
]
},
"TriggerCatalogRes": {
"type": "object",
"properties": {
"session": {
"type": "string"
}
},
"required": [
"session"
]
},
"GetDatasetCatalogTaskRes": {
"type": "object",
"properties": {
"created_at": {
"type": "string"
},
"customer_name": {
"type": "string"
},
"session_id": {
"type": "string"
},
"status": {
"type": "string"
},
"table_name": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"updated_by": {
"type": "string"
}
},
"required": [
"created_at",
"customer_name",
"session_id",
"status",
"table_name",
"updated_at",
"updated_by"
]
},
"ConnectionTestPingReq": { "ConnectionTestPingReq": {
"type": "object", "type": "object",
"properties": { "properties": {
@@ -7337,6 +7810,34 @@
"content", "content",
"tags" "tags"
] ]
},
"CustomerLinksResponse": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"links"
]
},
"CustomerDto": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"links"
]
} }
} }
} }
+1764 -2194
View File
File diff suppressed because it is too large Load Diff
+16 -16
View File
@@ -6,7 +6,7 @@
"private": true, "private": true,
"license": "UNLICENSED", "license": "UNLICENSED",
"engines": { "engines": {
"node": "18.3.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",
@@ -29,21 +29,23 @@
"dependencies": { "dependencies": {
"@aws-sdk/client-secrets-manager": "^3.112.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-v2": "3.29.0", "@dadosfera/protospack-v2": "3.31.0",
"@grpc/grpc-js": "^1.6.7", "@grpc/grpc-js": "^1.6.7",
"@grpc/proto-loader": "^0.6.13", "@grpc/proto-loader": "^0.6.13",
"@nestjs/common": "^8.4.7", "@nestjs/cli": "^9.4.2",
"@nestjs/config": "^1.2.1", "@nestjs/common": "^9.4.0",
"@nestjs/core": "^8.4.7", "@nestjs/config": "^2.3.1",
"@nestjs/mapped-types": "*", "@nestjs/core": "^9.4.0",
"@nestjs/microservices": "^8.4.7", "@nestjs/mapped-types": "^1.2.2",
"@nestjs/passport": "^8.2.2", "@nestjs/microservices": "^9.4.0",
"@nestjs/platform-express": "^8.4.7", "@nestjs/passport": "^9.0.3",
"@nestjs/schedule": "^1.1.0", "@nestjs/platform-express": "^9.4.0",
"@nestjs/swagger": "^5.2.1", "@nestjs/schematics": "^9.1.0",
"@nestjs/swagger": "^6.3.0",
"@nestjs/testing": "^9.4.0",
"axios": "^0.27.2", "axios": "^0.27.2",
"class-transformer": "^0.5.1", "class-transformer": "^0.5.1",
"class-validator": "^0.13.2", "class-validator": "^0.14.0",
"cron-parser": "^4.4.0", "cron-parser": "^4.4.0",
"dotenv": "^14.3.2", "dotenv": "^14.3.2",
"elastic-apm-node": "^3.36.0", "elastic-apm-node": "^3.36.0",
@@ -51,6 +53,7 @@
"jsonwebtoken": "^9.0.0", "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",
"passport": "^0.6.0", "passport": "^0.6.0",
"passport-facebook": "^3.0.0", "passport-facebook": "^3.0.0",
"passport-forcedotcom": "^0.2.0", "passport-forcedotcom": "^0.2.0",
@@ -67,9 +70,6 @@
"multer": "1.4.5-lts.1" "multer": "1.4.5-lts.1"
}, },
"devDependencies": { "devDependencies": {
"@nestjs/cli": "^8.2.8",
"@nestjs/schematics": "^8.0.11",
"@nestjs/testing": "^8.4.7",
"@types/express": "^4.17.13", "@types/express": "^4.17.13",
"@types/jest": "27.0.2", "@types/jest": "27.0.2",
"@types/jsonwebtoken": "^8.5.8", "@types/jsonwebtoken": "^8.5.8",
@@ -96,4 +96,4 @@
"tsconfig-paths": "^3.14.1", "tsconfig-paths": "^3.14.1",
"typescript": "^4.6.3" "typescript": "^4.6.3"
} }
} }
+2
View File
@@ -25,6 +25,7 @@ import { ConfigModule } from '@nestjs/config';
import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module'; import { PipelinesV2Module } from './modules/pipelinesV2/pipelines.module';
import { ProductboardModule } from './modules/productboard/productboard.module'; import { ProductboardModule } from './modules/productboard/productboard.module';
import { MixpanelModule } from './modules/mixpanel/mixpanel.module'; import { MixpanelModule } from './modules/mixpanel/mixpanel.module';
import { CustomersModule } from './modules/customers/customers.module';
@Module({ @Module({
controllers: [], controllers: [],
@@ -56,6 +57,7 @@ import { MixpanelModule } from './modules/mixpanel/mixpanel.module';
OauthModule, OauthModule,
ProductboardModule, ProductboardModule,
MixpanelModule, MixpanelModule,
CustomersModule,
//Always leave HealthModule last, so it is on the bottom of swagger //Always leave HealthModule last, so it is on the bottom of swagger
HealthModule, HealthModule,
], ],
@@ -44,7 +44,7 @@ class NoClassAuthController {
@Get('has-all-permissions') @Get('has-all-permissions')
@RequireAllPermissions( @RequireAllPermissions(
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN, PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE, PERMISSIONS_GROUPS.DATAVIZ.permissions.METABASE,
) )
async hasAllPermissions(@Body() body) { async hasAllPermissions(@Body() body) {
return { body }; return { body };
@@ -53,7 +53,7 @@ class NoClassAuthController {
@Get('has-some-permission') @Get('has-some-permission')
@RequireSomePermission( @RequireSomePermission(
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN, PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE, PERMISSIONS_GROUPS.DATAVIZ.permissions.METABASE,
) )
async hasSomePermission(@Body() body) { async hasSomePermission(@Body() body) {
return { body }; return { body };
@@ -62,7 +62,7 @@ class NoClassAuthController {
@Controller('class-auth-condition') @Controller('class-auth-condition')
@AuthenticateCondition((req) => req.get('x-on-class') === 'ok') @AuthenticateCondition((req) => req.get('x-on-class') === 'ok')
@RequireSomePermission(PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE) @RequireSomePermission(PERMISSIONS_GROUPS.DATAVIZ.permissions.METABASE)
class ClassAuthConditionController { class ClassAuthConditionController {
@Get('body') @Get('body')
async getBody(@Body() body) { async getBody(@Body() body) {
@@ -444,13 +444,13 @@ describe('authentication.guard', () => {
NoClassAuthTest(tokenZ, ['zendesk']); NoClassAuthTest(tokenZ, ['zendesk']);
ClassAuthConditionTest(tokenZ, ['zendesk']); ClassAuthConditionTest(tokenZ, ['zendesk']);
const tokenM = CreateToken([PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE]); const tokenM = CreateToken([PERMISSIONS_GROUPS.DATAVIZ.permissions.METABASE]);
NoClassAuthTest(tokenM, ['metabase']); NoClassAuthTest(tokenM, ['metabase']);
ClassAuthConditionTest(tokenM, ['metabase']); ClassAuthConditionTest(tokenM, ['metabase']);
const tokenZM = CreateToken([ const tokenZM = CreateToken([
PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN, PERMISSIONS_GROUPS.ZENDESK.permissions.OPEN,
PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE, PERMISSIONS_GROUPS.DATAVIZ.permissions.METABASE,
]); ]);
NoClassAuthTest(tokenZM, ['zendesk', 'metabase']); NoClassAuthTest(tokenZM, ['zendesk', 'metabase']);
ClassAuthConditionTest(tokenZM, ['zendesk', 'metabase']); ClassAuthConditionTest(tokenZM, ['zendesk', 'metabase']);
+36 -6
View File
@@ -55,6 +55,16 @@ export const PERMISSIONS_GROUPS = {
'es-es': '', 'es-es': '',
}, },
}, },
GENERATE_TOKEN: {
seqid: 46,
claim: 'customer:generate-token',
usage: PermissionUsages.PUBLIC,
name: {
'pt-br': 'Gerar Token de Acesso',
'en-us': 'Generate Acess Token',
'es-es': 'Gerar Token de Acceso',
},
},
}, },
}, },
@@ -346,6 +356,16 @@ export const PERMISSIONS_GROUPS = {
'es-es': 'Acceder al Módulo de Incorporación de Activos', 'es-es': 'Acceder al Módulo de Incorporación de Activos',
}, },
}, },
TRIGGER_CATALOG_TASK: {
seqid: 45,
claim: 'catalog:trigger-task',
usage: PermissionUsages.INTERNAL,
name: {
'pt-br': 'Executar a catalogação de um ativo',
'en-us': 'Trigger an asset cataloging',
'es-es': 'Realizar el listado de un activo',
},
},
}, },
}, },
@@ -428,18 +448,18 @@ export const PERMISSIONS_GROUPS = {
permissions: { permissions: {
OPEN: { OPEN: {
seqid: 16, seqid: 16,
claim: 'GET /zendesk', claim: 'support-chat:access',
usage: PermissionUsages.INTERNAL, usage: PermissionUsages.INTERNAL,
name: { name: {
'pt-br': 'Acessar Zendesk', 'pt-br': 'Acessar chat de suporte',
'en-us': 'Access Zendesk', 'en-us': 'Access support chat',
'es-es': 'Acceso Zendesk', 'es-es': 'Acceder al chat de soporte',
}, },
}, },
}, },
}, },
ANALYZE: { DATAVIZ: {
title: { title: {
'pt-br': 'Analisar | Visualização', 'pt-br': 'Analisar | Visualização',
'en-us': 'Analyze | Visualization', 'en-us': 'Analyze | Visualization',
@@ -456,6 +476,15 @@ export const PERMISSIONS_GROUPS = {
'es-es': 'Acceso Metabase', 'es-es': 'Acceso Metabase',
}, },
}, },
},
},
INTELLIGENCE: {
title: {
'pt-br': 'Analisar | Inteligência',
'en-us': 'Analyze | Intelligence',
'es-es': 'Analizar | Inteligencia',
},
permissions: {
INTELLIGENCE: { INTELLIGENCE: {
seqid: 31, seqid: 31,
claim: 'intelligence:open', claim: 'intelligence:open',
@@ -577,7 +606,8 @@ export const DADOSFERA_MODULES: Array<DadosferaModule> = [
name: 'Intelligence Module', name: 'Intelligence Module',
description: 'Orchest Module', description: 'Orchest Module',
key: 'intelligence', key: 'intelligence',
permissionSeqId: PERMISSIONS_GROUPS.ANALYZE.permissions.INTELLIGENCE.seqid, permissionSeqId:
PERMISSIONS_GROUPS.INTELLIGENCE.permissions.INTELLIGENCE.seqid,
}, },
{ {
name: 'Proccessing Module', name: 'Proccessing Module',
+1 -1
View File
@@ -46,7 +46,7 @@ describe('user.decorator', () => {
const fakeUserPayload = { const fakeUserPayload = {
user_id: 'd50d33c7-6c2b-463c-861f-e21667e7c125', user_id: 'd50d33c7-6c2b-463c-861f-e21667e7c125',
username: 'super.admin', username: 'super.admin',
permissions: [PERMISSIONS_GROUPS.ANALYZE.permissions.METABASE].map( permissions: [PERMISSIONS_GROUPS.DATAVIZ.permissions.METABASE].map(
({ seqid }) => seqid, ({ seqid }) => seqid,
), ),
customer_id: '9d18e8ae-24b9-41a3-9e8f-a25ce57555b11', customer_id: '9d18e8ae-24b9-41a3-9e8f-a25ce57555b11',
+7 -6
View File
@@ -42,7 +42,7 @@ function configureSwagger(app: INestApplication) {
} }
const swaggerTitle = branchName ? `Maestro - ${branchName}` : 'Maestro'; const swaggerTitle = branchName ? `Maestro - ${branchName}` : 'Maestro';
const config = new DocumentBuilder() const swaggerConfig = new DocumentBuilder()
.setTitle(swaggerTitle) .setTitle(swaggerTitle)
.setDescription('Documentation for Maestro gateway') .setDescription('Documentation for Maestro gateway')
.addSecurity('access-token', { .addSecurity('access-token', {
@@ -50,11 +50,12 @@ function configureSwagger(app: INestApplication) {
name: 'Authorization', name: 'Authorization',
in: 'header', in: 'header',
}) })
.setDescription('This is the Maestro API') .setDescription('This is the Maestro API');
.addServer('https://maestro.stg.dadosfera.ai', 'Ambiente STG')
.addServer('https://maestro-2.stg.dadosfera.ai', 'Ambiente STG2') if (process.env.INTERNAL_SWAGGER !== 'true')
.addServer('https://maestro.dadosfera.ai', 'Ambiente PRD') swaggerConfig.addServer('https://maestro.dadosfera.ai', 'Dadosfera API');
.build();
const config = swaggerConfig.build();
const document = SwaggerModule.createDocument(app, config); const document = SwaggerModule.createDocument(app, config);
+3
View File
@@ -1,3 +1,4 @@
import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities';
import { import {
AuthSignInRequest, AuthSignInRequest,
AuthSignInResponse, AuthSignInResponse,
@@ -74,6 +75,8 @@ export class AuthCustomer {
tier: string; tier: string;
@ApiProperty() @ApiProperty()
scheduleLimit: string; scheduleLimit: string;
@ApiProperty()
links: Link[];
} }
export class AuthSignInReq implements AuthSignInRequest { export class AuthSignInReq implements AuthSignInRequest {
+62 -8
View File
@@ -14,9 +14,15 @@ import {
Query, Query,
UseFilters, UseFilters,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiHeaders, ApiTags } from '@nestjs/swagger'; import {
ApiCreatedResponse,
ApiHeaders,
ApiOkResponse,
ApiTags,
} from '@nestjs/swagger';
import { import {
Authenticated, Authenticated,
RequireAllPermissions,
RequireSomePermission, RequireSomePermission,
} from '../../decorators/authentication.decorator'; } from '../../decorators/authentication.decorator';
import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum';
@@ -25,6 +31,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata';
import { RequestUser, User } from 'src/decorators/user.decorator'; import { RequestUser, User } from 'src/decorators/user.decorator';
import { import {
GetDatasetCatalogTaskRes,
ICatalogAllRequest, ICatalogAllRequest,
ICatalogAllResponse, ICatalogAllResponse,
IColumnsMetadataResponse, IColumnsMetadataResponse,
@@ -35,6 +42,8 @@ import {
IOneDataAsset, IOneDataAsset,
IPreviewResponse, IPreviewResponse,
IUpdateDataRequest, IUpdateDataRequest,
TriggerCatalogReq,
TriggerCatalogRes,
} from './dtos'; } from './dtos';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
import { Language } from 'src/decorators/language.decorator'; import { Language } from 'src/decorators/language.decorator';
@@ -180,7 +189,7 @@ export class CatalogController {
) )
async getDataAsset( async getDataAsset(
@User() user: RequestUser, @User() user: RequestUser,
@Param('id') id, @Param('id') id: string,
@Query('shared') shared?: 'true', @Query('shared') shared?: 'true',
) { ) {
const { username, user_id, customer_id, customer_name, permissions } = user; const { username, user_id, customer_id, customer_name, permissions } = user;
@@ -196,7 +205,7 @@ export class CatalogController {
let has_permission = false; let has_permission = false;
const metadata = PackTheMetadata({ const metadata = PackTheMetadata({
username, username,
user_id: undefined, user_id,
customer_id, customer_id,
customer_name, customer_name,
}); });
@@ -237,7 +246,7 @@ export class CatalogController {
async getDataAssetRls( async getDataAssetRls(
@User() user: RequestUser, @User() user: RequestUser,
@Headers() headers, @Headers() headers,
@Param('id') id, @Param('id') id: string,
) { ) {
const { username, user_id, customer_id, customer_name, permissions } = user; const { username, user_id, customer_id, customer_name, permissions } = user;
@@ -292,7 +301,7 @@ export class CatalogController {
async getDataAssetColumnsMetadata( async getDataAssetColumnsMetadata(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Param('id') id, @Param('id') id: string,
): Promise<IColumnsMetadataResponse> { ): Promise<IColumnsMetadataResponse> {
const { customer_name, customer_id, user_id, username } = user; const { customer_name, customer_id, user_id, username } = user;
@@ -323,7 +332,7 @@ export class CatalogController {
async getDataAssetPreview( async getDataAssetPreview(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Param('id') id, @Param('id') id: string,
): Promise<IPreviewResponse> { ): Promise<IPreviewResponse> {
const { customer_name, customer_id, user_id, username } = user; const { customer_name, customer_id, user_id, username } = user;
@@ -353,7 +362,7 @@ export class CatalogController {
async getDataAssetDocs( async getDataAssetDocs(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Param('id') id, @Param('id') id: string,
): Promise<IDocsResponse> { ): Promise<IDocsResponse> {
const { customer_name, customer_id, user_id, username } = user; const { customer_name, customer_id, user_id, username } = user;
@@ -383,7 +392,7 @@ export class CatalogController {
async updateDataAsset( async updateDataAsset(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Param('id') data_asset_id, @Param('id') data_asset_id: string,
@Body() body: IUpdateDataRequest, @Body() body: IUpdateDataRequest,
): Promise<IOneDataAsset> { ): Promise<IOneDataAsset> {
const { customer_id, customer_name, user_id, username } = user; const { customer_id, customer_name, user_id, username } = user;
@@ -579,4 +588,49 @@ export class CatalogController {
return response; return response;
} }
@Post('dataset-catalog-task')
@RequireAllPermissions(
PERMISSIONS_GROUPS.CATALOG.permissions.TRIGGER_CATALOG_TASK,
)
@ApiCreatedResponse({ type: TriggerCatalogRes })
async triggerCatalog(
@User() user: RequestUser,
@Body() body: TriggerCatalogReq,
) {
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
});
const session = await this.catalogService.triggerCatalog(body, metadata);
return { session };
}
@Get('dataset-catalog-task/:session')
@RequireAllPermissions(
PERMISSIONS_GROUPS.CATALOG.permissions.TRIGGER_CATALOG_TASK,
)
@ApiOkResponse({ type: GetDatasetCatalogTaskRes })
async getCatalogTask(
@User() user: RequestUser,
@Param('session') session: string,
) {
const { customer_id, customer_name, user_id, username } = user;
const metadata = PackTheMetadata({
customer_id,
customer_name,
user_id,
username,
});
const response = await this.catalogService.getDatasetCatalogTask(
session,
metadata,
);
return response;
}
} }
+13 -1
View File
@@ -18,7 +18,7 @@ import { CatalogClientConfiguration } from './catalog-client';
import { UsersService } from '../users/users.service'; import { UsersService } from '../users/users.service';
import { RolesService } from '../roles/roles.service'; import { RolesService } from '../roles/roles.service';
import { Metadata } from '@grpc/grpc-js'; import { Metadata } from '@grpc/grpc-js';
import { IUpdateDataRequest } from './dtos'; import { IUpdateDataRequest, TriggerCatalogReq } from './dtos';
class CatalogService implements OnModuleInit { class CatalogService implements OnModuleInit {
catalogReadService: ReadService.CatalogReadServices; catalogReadService: ReadService.CatalogReadServices;
@@ -333,6 +333,18 @@ class CatalogService implements OnModuleInit {
} as typeof data_asset; } as typeof data_asset;
}); });
} }
async triggerCatalog(data: TriggerCatalogReq, metadata: Metadata) {
const { session } = await lastValueFrom(
this.catalogWriteService.TriggerDatasetCataloging(data, metadata),
);
return session;
}
async getDatasetCatalogTask(session: string, metadata: Metadata) {
const res = await lastValueFrom(
this.catalogReadService.GetDatasetCatalogTask({ session }, metadata),
);
return res;
}
} }
export { CatalogService }; export { CatalogService };
+41
View File
@@ -271,3 +271,44 @@ export class IColumnsMetadataResponse {
@ApiProperty({ type: [IColumnMetadata] }) @ApiProperty({ type: [IColumnMetadata] })
columns_metadata: IColumnMetadata[]; columns_metadata: IColumnMetadata[];
} }
export class TriggerCatalogReq {
@ApiProperty({
description: 'Name of the table on Snowflake',
example: 'TB__4DXSD4_TEST',
})
table_name: string;
@ApiPropertyOptional({
description:
'Schema where the asset is located. If not set defaults to "PUBLIC"',
})
table_schema?: string;
@ApiPropertyOptional({
description: 'Id of the pipeline that generated the asset.',
})
pipeline_id: string;
}
export class TriggerCatalogRes {
@ApiProperty()
session: string;
}
export class GetDatasetCatalogTaskRes {
@ApiProperty()
created_at: string;
@ApiProperty()
customer_name: string;
@ApiProperty()
session_id: string;
@ApiProperty()
status: string;
@ApiProperty()
table_name: string;
@ApiProperty()
updated_at: string;
@ApiProperty()
updated_by: string;
}
@@ -164,7 +164,7 @@ export class ConnectionController {
async getConnectionDetails( async getConnectionDetails(
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@User() user: RequestUser, @User() user: RequestUser,
@Param('id') id, @Param('id') id: string,
@Query() queries, @Query() queries,
): Promise<ConnectionDetailsRes> { ): Promise<ConnectionDetailsRes> {
this.logger.info('/connections - Get Connection Details'); this.logger.info('/connections - Get Connection Details');
@@ -273,16 +273,13 @@ export class ConnectorController {
@Param('plugin') plugin: string, @Param('plugin') plugin: string,
@Query('version') version: string, @Query('version') version: string,
) { ) {
this.logger.info('/upload - Upload Connector Route'); this.logger.info('DELETE /:plugin - Delete Connector Route');
const response: any = await this.connectorClientService.deleteConnector( const response = await this.connectorClientService.deleteConnector(
plugin, plugin,
version, version,
); );
return { return { message: response.message, connector: response.connector };
message: response.message || 'ok',
connector: { ...JSON.parse(response.connector) },
};
} }
} }
@@ -0,0 +1,74 @@
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { IdResponse } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import {
Body,
Controller,
Get,
Inject,
Param,
Put,
Query,
UseFilters,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { PERMISSIONS_GROUPS } from 'src/authentication/permissions.enum';
import {
Authenticated,
RequireAllPermissions,
} from 'src/decorators/authentication.decorator';
import { ApiInternalOnlyController } from 'src/decorators/swagger.decorator';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
import { CustomersService } from './customers.service';
import { CustomerDto, CustomerLinksResponse } from './dtos/customers';
import { RequestUser, User } from 'src/decorators/user.decorator';
import type { StringValue } from 'ms';
@ApiInternalOnlyController()
@ApiTags('Customers')
@Controller('customers')
@Authenticated()
@UseFilters(GrpcToHttpExceptionFilter)
export class CustomersController {
logger: DadosferaLogger;
constructor(
@Inject(DadosferaLogger)
dadosferaLogger: DadosferaLogger,
private customersService: CustomersService,
) {
this.logger = dadosferaLogger.logger;
}
@Get(':id/links')
async getCustomerLinks(@Param('id') id): Promise<CustomerLinksResponse> {
this.logger.info('getCustomerLinks', { id });
const links = await this.customersService.getLinks(id);
return { links };
}
@Put(':id/links')
@RequireAllPermissions(PERMISSIONS_GROUPS.USERS.permissions.ADMIN)
setCustomerLinks(
@Body() body: CustomerDto,
@Param('id') id,
): Promise<IdResponse> {
const { links } = body;
this.logger.info('setCustomerLinks', { id, links });
return this.customersService.setLinks(id, links);
}
@Get('token')
@RequireAllPermissions(PERMISSIONS_GROUPS.AUTH.permissions.GENERATE_TOKEN)
async getCustomerToken(
@Query('exp') exp: StringValue,
@User() user: RequestUser,
): Promise<string> {
this.logger.info('getCustomerToken', { exp, user });
const data = {
customerId: user.customer_id,
userId: user.user_id,
customerName: user.customer_name,
};
return this.customersService.generateToken(exp, data);
}
}
+16
View File
@@ -0,0 +1,16 @@
import { Module } from '@nestjs/common';
import { DadosferaLogger } from '@dadosfera/dadosfera-logs';
import { ClientsModule } from '@nestjs/microservices';
import { DucClient } from '../duc/client.config';
import { CustomersController } from './customers.controller';
import { CustomersService } from './customers.service';
const client = new DucClient();
@Module({
imports: [ClientsModule.register([client.providerOptions])],
controllers: [CustomersController],
providers: [CustomersService, DadosferaLogger],
exports: [CustomersService],
})
export class CustomersModule {}
+123
View File
@@ -0,0 +1,123 @@
import {
OnModuleInit,
Inject,
Injectable,
HttpException,
HttpStatus,
InternalServerErrorException,
} from '@nestjs/common';
import { firstValueFrom, lastValueFrom } from 'rxjs';
import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities';
import { DucClient } from '../duc/client.config';
import { ClientGrpc } from '@nestjs/microservices';
import { ProtoServices } from '@dadosfera/protospack-v2/dist/lib/Duc';
import { CustomerUpdateRequest } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/messages';
import { CustomersProtoService } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/write-service';
import ErrorCodes from 'src/utils/errorCodes';
import jwt from 'jsonwebtoken';
import {
GetSecretValueCommand,
SecretsManagerClient,
} from '@aws-sdk/client-secrets-manager';
import getEnv from 'src/utils/getEnv';
import { logger } from 'elastic-apm-node';
// This function will accept any string, which may result in a bug.
@Injectable()
export class CustomersService implements OnModuleInit {
private customerService: CustomersProtoService;
constructor(
@Inject(DucClient.name) private readonly grpcClient: ClientGrpc,
) {}
onModuleInit() {
this.customerService = this.grpcClient.getService<CustomersProtoService>(
ProtoServices.CustomersProtoService,
);
}
async getLinks(customerId: string) {
try {
const result = await lastValueFrom(
this.customerService.CustomerFindOneById({ id: customerId }),
);
return result.customer?.links || [];
} catch (err) {
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND)
throw new HttpException(err.details, HttpStatus.NOT_FOUND);
throw err;
}
}
async setLinks(customerId: string, links: Link[]) {
if (!customerId || !links) {
throw new HttpException(null, HttpStatus.BAD_REQUEST);
}
try {
return await firstValueFrom(
this.customerService.CustomerUpdate({
id: customerId,
links,
} as CustomerUpdateRequest),
);
} catch (err) {
if (err.details === ErrorCodes.CUSTOMER.NOT_FOUND)
throw new HttpException(err.details, HttpStatus.NOT_FOUND);
else throw err;
}
}
async generateToken(
expiresIn = '30m',
data: { customerId: string; userId: string; customerName: string },
) {
const { customerId, userId: generatedById, customerName } = data;
const secretsManagerClient = new SecretsManagerClient({});
const getSecretComand = new GetSecretValueCommand({
SecretId: `${getEnv()}/${customerName}/jwt-signing-key`,
});
let private_key_pem;
await secretsManagerClient
.send(getSecretComand)
.then((res) => {
const secret = JSON.parse(res.SecretString);
private_key_pem = secret.private_key_pem;
})
.catch((err) => {
logger.error(err.stack);
throw new InternalServerErrorException(
'Error finding keys for customer',
);
});
let jwt_token;
try {
jwt_token = jwt.sign(
{
customerId,
generatedById,
},
private_key_pem,
{
algorithm: 'RS256',
expiresIn,
issuer: 'maestro',
},
);
} catch (err) {
logger.error(err.stack);
throw new InternalServerErrorException('Error generating token');
}
// const verify = jwt.verify(jwt_token, public_key_pem, {
// algorithms: ['RS256'],
// issuer: 'maestro',
// });
// const decoded = jwt.decode(jwt_token, { complete: true });
return jwt_token;
}
}
+12
View File
@@ -0,0 +1,12 @@
import { Link } from '@dadosfera/protospack-v2/dist/lib/Duc/interfaces/entities';
import { ApiProperty } from '@nestjs/swagger';
export class CustomerDto {
@ApiProperty()
links: Link[];
}
export class CustomerLinksResponse {
@ApiProperty()
links: Link[];
}
+1 -2
View File
@@ -123,8 +123,7 @@ export class InputsController {
} }
@Get('/:id') @Get('/:id')
async findOne(@Body() body, @Param() params) { async findOne(@Body() body, @Param('id') id: string) {
const { id } = params;
this.logger.info(`/input/${id} - ON FIND ONE ROUTE`, { this.logger.info(`/input/${id} - ON FIND ONE ROUTE`, {
user: body.info.user_id, user: body.info.user_id,
customer: body.info.customer, customer: body.info.customer,
-2
View File
@@ -5,7 +5,6 @@ import {
Inject, Inject,
Injectable, Injectable,
} from '@nestjs/common'; } from '@nestjs/common';
import { Timeout } from '@nestjs/schedule';
import CronParser, { CronExpression } from 'cron-parser'; import CronParser, { CronExpression } from 'cron-parser';
import { ClientGrpc } from '@nestjs/microservices'; import { ClientGrpc } from '@nestjs/microservices';
import DadosferaLogger from '@dadosfera/dadosfera-logs/dist'; import DadosferaLogger from '@dadosfera/dadosfera-logs/dist';
@@ -222,7 +221,6 @@ export class InputsService {
return lastValueFrom(this.inputWriteService.InputRemove(idRequest)); return lastValueFrom(this.inputWriteService.InputRemove(idRequest));
} }
@Timeout(60000 * 10) // Timeout set for 10 minutes
async testConnection(data) { async testConnection(data) {
try { try {
const testConnectionInputResponse = const testConnectionInputResponse =
@@ -17,7 +17,7 @@ export class HubspotStrategy extends PassportStrategy(Strategy) {
clientSecret: oauthSecrets.hubspot.client_secret, clientSecret: oauthSecrets.hubspot.client_secret,
callbackURL: oauthSecrets.hubspot.redirect_uri, callbackURL: oauthSecrets.hubspot.redirect_uri,
scope: scope:
'automation business-intelligence oauth forms integration-sync sales-email-read crm.lists.read crm.objects.contacts.read crm.schemas.contacts.read crm.objects.companies.read crm.objects.deals.read crm.schemas.companies.read crm.schemas.deals.read crm.objects.owners.read crm.objects.quotes.read crm.schemas.quotes.read crm.objects.line_items.read crm.schemas.line_items.read', 'tickets automation business-intelligence oauth forms integration-sync sales-email-read crm.lists.read crm.objects.contacts.read crm.schemas.contacts.read crm.objects.companies.read crm.objects.deals.read crm.schemas.companies.read crm.schemas.deals.read crm.objects.owners.read crm.objects.quotes.read crm.schemas.quotes.read crm.objects.line_items.read crm.schemas.line_items.read',
passReqToCallback: true, passReqToCallback: true,
}, },
(accessToken, refreshToken, tokenInfo, profile, done) => { (accessToken, refreshToken, tokenInfo, profile, done) => {
@@ -49,8 +49,7 @@ export class PipelinesController {
description: description:
'This method is deprecated. Please use route /pipelinesV2/start/:id instead', 'This method is deprecated. Please use route /pipelinesV2/start/:id instead',
}) })
async activate(@Param() params, @Body() body) { async activate(@Param('id') id: string, @Body() body) {
const { id } = params;
const { info } = body; const { info } = body;
this.logger.info( this.logger.info(
@@ -72,8 +71,7 @@ export class PipelinesController {
description: description:
'This method is deprecated. Please use route /pipelinesV2/:id/status instead', 'This method is deprecated. Please use route /pipelinesV2/:id/status instead',
}) })
async getPipelineStatus(@Body() body, @Param() params) { async getPipelineStatus(@Body() body, @Param('id') id: string) {
const { id } = params;
body.id = id; body.id = id;
this.logger.info( this.logger.info(
+18
View File
@@ -10,6 +10,8 @@ export class IPipelineV2 {
@ApiProperty() @ApiProperty()
description: string; description: string;
@ApiProperty() @ApiProperty()
type: string;
@ApiProperty()
connection_id: string; connection_id: string;
@ApiProperty() @ApiProperty()
cron: string; cron: string;
@@ -104,4 +106,20 @@ export class ICreatePipelineCSVFile {
@ApiProperty() @ApiProperty()
header: boolean; header: boolean;
@ApiProperty()
engine: string;
}
export class PipelineFindAllReq {
@ApiPropertyOptional()
search?: string | undefined;
@ApiPropertyOptional()
filters?: string | undefined;
@ApiPropertyOptional()
size?: string | undefined;
@ApiPropertyOptional()
page?: string | undefined;
@ApiPropertyOptional()
type?: string | undefined;
} }
+25 -20
View File
@@ -40,6 +40,7 @@ import {
ICreatePipelineV2Req, ICreatePipelineV2Req,
IPipelineV2, IPipelineV2,
IInitUploadCSVFile, IInitUploadCSVFile,
PipelineFindAllReq,
} from './interfaces'; } from './interfaces';
import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter';
import { LanguageEnum } from 'src/utils/languages.enum'; import { LanguageEnum } from 'src/utils/languages.enum';
@@ -115,7 +116,7 @@ export class PipelinesController {
async findAll( async findAll(
@User() user: RequestUser, @User() user: RequestUser,
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Query() data, @Query() data: PipelineFindAllReq,
) { ) {
this.logger.info('PipelinesController - findAll', { user }); this.logger.info('PipelinesController - findAll', { user });
@@ -169,7 +170,7 @@ export class PipelinesController {
async getPipelineproperties( async getPipelineproperties(
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@User() user: RequestUser, @User() user: RequestUser,
@Param('id') id, @Param('id') id: string,
) { ) {
this.logger.info('PipelinesController - getPipelineproperties', { user }); this.logger.info('PipelinesController - getPipelineproperties', { user });
const metadata = PackTheMetadata({ ...user, language: language }); const metadata = PackTheMetadata({ ...user, language: language });
@@ -180,7 +181,7 @@ export class PipelinesController {
async getPipelineObjects( async getPipelineObjects(
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@User() user: RequestUser, @User() user: RequestUser,
@Param('id') id, @Param('id') id: string,
) { ) {
this.logger.info('PipelinesController - getPipelineObjects', { user }); this.logger.info('PipelinesController - getPipelineObjects', { user });
const metadata = PackTheMetadata({ ...user, language: language }); const metadata = PackTheMetadata({ ...user, language: language });
@@ -188,8 +189,7 @@ export class PipelinesController {
} }
@Get(':id/status') @Get(':id/status')
async getPipelineStatus(@Body() body, @Param() params) { async getPipelineStatus(@Body() body, @Param('id') id: string) {
const { id } = params;
body.id = id; body.id = id;
this.logger.info( this.logger.info(
@@ -209,7 +209,7 @@ export class PipelinesController {
async findOne( async findOne(
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@User() user: RequestUser, @User() user: RequestUser,
@Param('id') id, @Param('id') id: string,
): Promise<Messages.PipelineV2FindOneResponse> { ): Promise<Messages.PipelineV2FindOneResponse> {
this.logger.info('PipelinesController - findOne', { user }); this.logger.info('PipelinesController - findOne', { user });
@@ -250,7 +250,7 @@ export class PipelinesController {
async update( async update(
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Body() updatePipelineDto, @Body() updatePipelineDto,
@Param('id') id, @Param('id') id: string,
@User() user: RequestUser, @User() user: RequestUser,
) { ) {
this.logger.info('PipelinesController - update', { user }); this.logger.info('PipelinesController - update', { user });
@@ -289,7 +289,7 @@ export class PipelinesController {
async updateDeprecated( async updateDeprecated(
@Language() language: LanguageEnum, @Language() language: LanguageEnum,
@Body() updatePipelineDto, @Body() updatePipelineDto,
@Param('id') id, @Param('id') id: string,
@User() user: RequestUser, @User() user: RequestUser,
) { ) {
this.logger.info('PipelinesController - put', { user }); this.logger.info('PipelinesController - put', { user });
@@ -301,9 +301,8 @@ export class PipelinesController {
@Delete(':id') @Delete(':id')
@ApiNoContentResponse() @ApiNoContentResponse()
@HttpCode(HttpStatus.NO_CONTENT) @HttpCode(HttpStatus.NO_CONTENT)
async delete(@Param() params, @User() user: RequestUser) { async delete(@Param('id') id: string, @User() user: RequestUser) {
this.logger.info('PipelinesController - delete', { user }); this.logger.info('PipelinesController - delete', { user });
const { id } = params;
const metadata = PackTheMetadata({ const metadata = PackTheMetadata({
customer_id: user.customer_id, customer_id: user.customer_id,
customer_name: user.customer_name, customer_name: user.customer_name,
@@ -370,30 +369,37 @@ export class PipelinesController {
@User() user: RequestUser, @User() user: RequestUser,
@Body() body: ICreatePipelineCSVFile, @Body() body: ICreatePipelineCSVFile,
) { ) {
this.logger.info('/upload - Upload Connector Route'); this.logger.info('/file - Upload Connector Route');
const metadata = PackTheMetadata({ ...user }); const metadata = PackTheMetadata({ ...user });
const { name, sep, header, encoding, description, file_name } = body; const { name, sep, header, encoding, description, file_name, engine } =
body;
const file_format_params = {
...(sep && { sep }),
...(encoding && { encoding }),
...(header !== undefined ? { header } : {}),
};
const source_prefix = `${user.customer_name}/${file_name}`; const source_prefix = `${user.customer_name}/${file_name}`;
const upload_pipeline = { const upload_pipeline: ICreatePipelineV2Req = {
connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION, connection_id: process.env.UPLOAD_FILE_AGENT_CONNECTION,
connector_name: 'Amazon S3', connector_name: 'Amazon S3',
connector_plugin: 'aws_s3', connector_plugin: 'aws_s3',
connector_version: '1.0.0', connector_version: '1.0.0',
image_url: 'https://assets.dadosfera.ai/images/connectors/csv.svg', image_url: `https://assets.dadosfera.ai/images/connectors/${engine}.svg`,
name, name,
description, description,
transformations_ids: [], transformations_ids: [],
tags: [], tags: [],
cron: '@once', cron: '@once',
config: { cron: '@once', tables: [] }, type: 'upload',
properties: { properties: {
engine: 'csv', engine,
source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS, source_bucket: process.env.BUCKET_CUSTOMER_CSV_ASSETS,
source_prefix, source_prefix,
file_format_params: { sep, encoding, header: Boolean(header) }, file_format_params,
is_a_upload_csv: true,
}, },
input_id: undefined, input_id: undefined,
}; };
@@ -408,8 +414,7 @@ export class PipelinesController {
@ApiInternalOnlyEndpoint() @ApiInternalOnlyEndpoint()
@Post('start/:id') @Post('start/:id')
async activate(@Param() params, @Body() body) { async activate(@Param('id') id: string, @Body() body) {
const { id } = params;
const { info } = body; const { info } = body;
this.logger.info( this.logger.info(
+28 -14
View File
@@ -23,7 +23,7 @@ import { ConnectorClientService } from '../connector/client.service';
import { InputsService } from '../inputs/inputs.service'; import { InputsService } from '../inputs/inputs.service';
import { RequestUser } from 'src/decorators/user.decorator'; import { RequestUser } from 'src/decorators/user.decorator';
import { TransformationsService } from '../transformations/transformations.service'; import { TransformationsService } from '../transformations/transformations.service';
import { getObjValueFromPath } from 'src/utils/ObjValueFromPath'; import { getObjValueFromPath, objHasPath } from 'src/utils/ObjValueFromPath';
import ErrorCodes from 'src/utils/errorCodes'; import ErrorCodes from 'src/utils/errorCodes';
import ErrorBuilder from 'src/utils/ErrorBuilder'; import ErrorBuilder from 'src/utils/ErrorBuilder';
@@ -220,7 +220,7 @@ export class PipelinesService implements OnModuleInit {
this.logger.info('PipelinesClientService - findOneProperties'); this.logger.info('PipelinesClientService - findOneProperties');
const { pipeline } = await this.findOne({ id }, metadata); const { pipeline } = await this.findOne({ id }, metadata);
const pipelineProperties = JSON.parse(pipeline.properties); const properties = JSON.parse(pipeline.properties);
const connectorId = `${pipeline.connector_plugin}-${pipeline.connector_version}`; const connectorId = `${pipeline.connector_plugin}-${pipeline.connector_version}`;
@@ -228,24 +228,38 @@ export class PipelinesService implements OnModuleInit {
connectorId, connectorId,
metadata.get('language')[0].toString(), metadata.get('language')[0].toString(),
); );
const connector = JSON.parse(res.connector); const connector: { [key: string]: any; config_controls: any[] } =
const config_controls = connector.config_controls || []; JSON.parse(res.connector);
const config_controls = (connector.config_controls || []).filter(
(config_control) => {
const path: string = config_control.name;
if (!objHasPath({ object: { properties }, path })) return false;
for (const config_control of config_controls) { let default_value = getObjValueFromPath({
const path: string = config_control.name; object: { properties },
const default_value = getObjValueFromPath({ path,
object: { properties: pipelineProperties }, });
path,
}); if (default_value != undefined) {
if (default_value != undefined) if (
config_control.default_value = default_value; path === 'properties.spreadsheet_id' &&
} typeof default_value === 'string'
)
default_value = 'https://docs.google.com/spreadsheets/d/'.concat(
default_value,
);
config_control.default_value = default_value;
}
return true;
},
);
return { return {
pipeline: { pipeline: {
...pipeline, ...pipeline,
config_controls, config_controls,
properties: pipelineProperties, properties,
}, },
}; };
} }
@@ -72,8 +72,7 @@ export class TransformationsController {
@Get('/:id') @Get('/:id')
@RequireSomePermission(pipelinePermissions.GET) @RequireSomePermission(pipelinePermissions.GET)
async findOne(@Body() data, @Param() params) { async findOne(@Body() data, @Param('id') id: string) {
const { id } = params;
this.logger.info(`/transformation/${id} - ON Find One ROUTE`, { this.logger.info(`/transformation/${id} - ON Find One ROUTE`, {
user: data.info.user_id, user: data.info.user_id,
customer: data.info.customer, customer: data.info.customer,
+14
View File
@@ -308,6 +308,20 @@ export function EnrichErrorCode(code: string) {
'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte', 'Tente realizar a ação novamente. Caso o erro persista, entre em contato com o suporte',
code, code,
}; };
case ErrorCodes.CATALOG.PREVIEW_TOO_BIG:
return {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'Erro ao buscar prévia',
message: 'Ocorreu um erro devido ao tamanho da prévia do ativo.',
code,
};
case ErrorCodes.CATALOG.METADATA_TOO_BIG:
return {
statusCode: HttpStatus.INTERNAL_SERVER_ERROR,
error: 'Erro ao buscar informações',
message: 'Ocorreu um erro devido ao tamanho das informações do ativo.',
code,
};
case ErrorCodes.INTERNAL: case ErrorCodes.INTERNAL:
case ErrorCodes.UNKNOWN: case ErrorCodes.UNKNOWN:
default: default:
+19 -1
View File
@@ -1,4 +1,7 @@
export function getObjValueFromPath<T>(data: { object: T; path: string }): T { export function getObjValueFromPath<T extends object>(data: {
object: T;
path: string;
}): any {
const { object, path } = data; const { object, path } = data;
const keys = path.split('.'); const keys = path.split('.');
@@ -8,3 +11,18 @@ export function getObjValueFromPath<T>(data: { object: T; path: string }): T {
} }
return value; return value;
} }
export function objHasPath<T extends object>(data: {
object: T;
path: string;
}): boolean {
const { object, path } = data;
const keys = path.split('.');
let value = JSON.parse(JSON.stringify(object));
for (const key of keys) {
if (!(key in value)) return false;
value = value[key];
}
return true;
}
+3
View File
@@ -39,6 +39,7 @@ export const CUSTOMER = {
INVALID_ID: 'CUSTOMER.INVALID_ID', INVALID_ID: 'CUSTOMER.INVALID_ID',
NOT_FOUND: 'CUSTOMER.NOT_FOUND', NOT_FOUND: 'CUSTOMER.NOT_FOUND',
ALREADY_EXISTS: 'CUSTOMER.ALREADY_EXISTS', ALREADY_EXISTS: 'CUSTOMER.ALREADY_EXISTS',
BAD_REQUEST: 'CUSTOMER.BAD_REQUEST',
}; };
const TERMS_OF_USE = { const TERMS_OF_USE = {
UP_TO_DATE: 'TERMS_OF_USE.UP_TO_DATE', UP_TO_DATE: 'TERMS_OF_USE.UP_TO_DATE',
@@ -70,6 +71,8 @@ const TRANSFORMATION = {
}; };
const CATALOG = { const CATALOG = {
DATA_ASSET_NOT_FOUND: 'CATALOG.DATA_ASSET_NOT_FOUND', DATA_ASSET_NOT_FOUND: 'CATALOG.DATA_ASSET_NOT_FOUND',
PREVIEW_TOO_BIG: 'CATALOG.PREVIEW_TOO_BIG',
METADATA_TOO_BIG: 'CATALOG.METADATA_TOO_BIG',
}; };
const ErrorCodes = { const ErrorCodes = {
UNKNOWN: 'UNKNOWN', UNKNOWN: 'UNKNOWN',
+10
View File
@@ -0,0 +1,10 @@
const availableLocalEnvs: Array<typeof process.env.ENV> = ['stg', 'test'];
export default function getEnv(): typeof process.env.ENV {
if (process.env.ENV === 'local') {
if (availableLocalEnvs.includes(process.env.LOCAL_ENV))
return process.env.LOCAL_ENV;
return 'stg';
}
return process.env.ENV;
}