diff --git a/docsfera.external.json b/docsfera.external.json index b0c23f8..ee94532 100644 --- a/docsfera.external.json +++ b/docsfera.external.json @@ -241,7 +241,16 @@ }, "get": { "operationId": "ConnectionController_getConnectionDetails", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -449,7 +458,16 @@ "/inputs/{id}": { "get": { "operationId": "InputsController_findOne", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -646,6 +664,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -678,6 +704,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -710,6 +744,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -749,6 +791,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -786,6 +836,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -823,6 +881,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -985,6 +1051,14 @@ "type": "string" } }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, { "name": "shared", "required": true, @@ -1025,6 +1099,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "requestBody": { @@ -1125,6 +1207,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -1167,6 +1257,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -1209,6 +1307,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -1402,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": { "get": { "operationId": "OauthController_oauthHubspot", @@ -1544,7 +1752,7 @@ } }, "info": { - "title": "Maestro - fix/delete-connector", + "title": "Maestro - feat/trigger-catalog-task", "description": "This is the Maestro API", "version": "1.0.0", "contact": {} @@ -2842,6 +3050,73 @@ "required": [ "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" + ] } } } diff --git a/docsfera.json b/docsfera.json index 637dece..47f0d6f 100644 --- a/docsfera.json +++ b/docsfera.json @@ -690,7 +690,16 @@ }, "get": { "operationId": "ConnectionController_getConnectionDetails", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -2574,7 +2583,16 @@ "/inputs/{id}": { "get": { "operationId": "InputsController_findOne", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -2819,6 +2837,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -2851,6 +2877,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -2883,6 +2917,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -2922,6 +2964,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -2959,6 +3009,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -2999,6 +3057,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -3036,6 +3102,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -3217,6 +3291,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -3247,7 +3329,16 @@ "summary": "", "deprecated": true, "description": "This method is deprecated. Please use route /pipelinesV2/start/:id instead", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "201": { "description": "", @@ -3279,7 +3370,16 @@ "summary": "", "deprecated": true, "description": "This method is deprecated. Please use route /pipelinesV2/:id/status instead", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -3350,7 +3450,16 @@ "/transformations/{id}": { "get": { "operationId": "TransformationsController_findOne", - "parameters": [], + "parameters": [ + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "", @@ -3658,6 +3767,14 @@ "type": "string" } }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } + }, { "name": "shared", "required": true, @@ -3698,6 +3815,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "requestBody": { @@ -3798,6 +3923,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -3833,6 +3966,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -3875,6 +4016,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -3917,6 +4066,14 @@ ], "type": "string" } + }, + { + "name": "id", + "required": true, + "in": "path", + "schema": { + "type": "string" + } } ], "responses": { @@ -4190,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": { "get": { "operationId": "TermsOfUseController_getToken", @@ -4716,7 +4975,7 @@ } }, "info": { - "title": "Maestro - fix/delete-connector", + "title": "Maestro - feat/trigger-catalog-task", "description": "This is the Maestro API", "version": "1.0.0", "contact": {} @@ -7083,6 +7342,73 @@ "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": { "type": "object", "properties": { diff --git a/package-lock.json b/package-lock.json index 664cad4..be22e6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4", - "@dadosfera/protospack-v2": "3.29.1", + "@dadosfera/protospack-v2": "3.30.0", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", @@ -1727,9 +1727,9 @@ } }, "node_modules/@dadosfera/protospack-v2": { - "version": "3.29.1", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.1.tgz", - "integrity": "sha512-uVswwXltdG0aX8cYVSFPRcROPWjOlW5bJGFfn5RNodKyHeBiTVDWBB3/YgocKrWV4mYBSbZ11ctBzjSAOkf/0Q==", + "version": "3.30.0", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.30.0.tgz", + "integrity": "sha512-00wqZyZmjd6rMECga2S3Ow0dk6c5fZoWd6Th+Ajofq6q/kycTU66p/5xdf0sPf//WyXMGCXasqGSZa0h9i01vg==", "dependencies": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", @@ -4495,9 +4495,10 @@ "license": "MIT" }, "node_modules/cookiejar": { - "version": "2.1.3", - "dev": true, - "license": "MIT" + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", + "dev": true }, "node_modules/core-util-is": { "version": "1.0.3", @@ -7759,9 +7760,10 @@ "license": "ISC" }, "node_modules/json5": { - "version": "2.2.1", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true, - "license": "MIT", "bin": { "json5": "lib/cli.js" }, @@ -7968,9 +7970,9 @@ } }, "node_modules/luxon": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz", - "integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==", + "version": "1.28.1", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.1.tgz", + "integrity": "sha512-gYHAa180mKrNIUJCbwpmD0aTu9kV0dREDrwNnuyFAsO1Wt0EVYSZelPnJlbj9HplzXX/YWXHFTL45kvZ53M0pw==", "engines": { "node": "*" } @@ -10384,9 +10386,10 @@ } }, "node_modules/tsconfig-paths/node_modules/json5": { - "version": "1.0.1", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, - "license": "MIT", "dependencies": { "minimist": "^1.2.0" }, @@ -12284,9 +12287,9 @@ } }, "@dadosfera/protospack-v2": { - "version": "3.29.1", - "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.29.1.tgz", - "integrity": "sha512-uVswwXltdG0aX8cYVSFPRcROPWjOlW5bJGFfn5RNodKyHeBiTVDWBB3/YgocKrWV4mYBSbZ11ctBzjSAOkf/0Q==", + "version": "3.30.0", + "resolved": "https://dadosfera-611330257153.d.codeartifact.us-east-1.amazonaws.com:443/npm/dadosfera-npm/@dadosfera/protospack-v2/-/protospack-v2-3.30.0.tgz", + "integrity": "sha512-00wqZyZmjd6rMECga2S3Ow0dk6c5fZoWd6Th+Ajofq6q/kycTU66p/5xdf0sPf//WyXMGCXasqGSZa0h9i01vg==", "requires": { "@grpc/grpc-js": "^1.6.7", "rxjs": "^7.5.5", @@ -14190,7 +14193,9 @@ "version": "1.0.6" }, "cookiejar": { - "version": "2.1.3", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", "dev": true }, "core-util-is": { @@ -16399,7 +16404,9 @@ "dev": true }, "json5": { - "version": "2.2.1", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", "dev": true }, "jsonc-parser": { @@ -16548,9 +16555,9 @@ } }, "luxon": { - "version": "1.28.0", - "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.0.tgz", - "integrity": "sha512-TfTiyvZhwBYM/7QdAVDh+7dBTBA29v4ik0Ce9zda3Mnf8on1S5KJI8P2jKFZ8+5C0jhmr0KwJEO/Wdpm0VeWJQ==" + "version": "1.28.1", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-1.28.1.tgz", + "integrity": "sha512-gYHAa180mKrNIUJCbwpmD0aTu9kV0dREDrwNnuyFAsO1Wt0EVYSZelPnJlbj9HplzXX/YWXHFTL45kvZ53M0pw==" }, "macos-release": { "version": "2.5.0", @@ -18138,7 +18145,9 @@ }, "dependencies": { "json5": { - "version": "1.0.1", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz", + "integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==", "dev": true, "requires": { "minimist": "^1.2.0" diff --git a/package.json b/package.json index b2f45ee..cbae592 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "dependencies": { "@aws-sdk/client-secrets-manager": "^3.112.0", "@dadosfera/dadosfera-logs": "^1.0.0-beta.4", - "@dadosfera/protospack-v2": "3.29.1", + "@dadosfera/protospack-v2": "3.30.0", "@grpc/grpc-js": "^1.6.7", "@grpc/proto-loader": "^0.6.13", "@nestjs/common": "^8.4.7", diff --git a/src/authentication/permissions.enum.ts b/src/authentication/permissions.enum.ts index 4441763..5280795 100644 --- a/src/authentication/permissions.enum.ts +++ b/src/authentication/permissions.enum.ts @@ -346,6 +346,16 @@ export const PERMISSIONS_GROUPS = { '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', + }, + }, }, }, diff --git a/src/modules/catalog/catalog.controller.ts b/src/modules/catalog/catalog.controller.ts index 6583726..4f86deb 100644 --- a/src/modules/catalog/catalog.controller.ts +++ b/src/modules/catalog/catalog.controller.ts @@ -14,9 +14,15 @@ import { Query, UseFilters, } from '@nestjs/common'; -import { ApiHeaders, ApiTags } from '@nestjs/swagger'; +import { + ApiCreatedResponse, + ApiHeaders, + ApiOkResponse, + ApiTags, +} from '@nestjs/swagger'; import { Authenticated, + RequireAllPermissions, RequireSomePermission, } from '../../decorators/authentication.decorator'; import { PERMISSIONS_GROUPS } from '../../authentication/permissions.enum'; @@ -25,6 +31,7 @@ import { DadosferaLogger } from '@dadosfera/dadosfera-logs'; import { PackTheMetadata } from 'src/utils/ PackTheMetadata'; import { RequestUser, User } from 'src/decorators/user.decorator'; import { + GetDatasetCatalogTaskRes, ICatalogAllRequest, ICatalogAllResponse, IColumnsMetadataResponse, @@ -35,6 +42,8 @@ import { IOneDataAsset, IPreviewResponse, IUpdateDataRequest, + TriggerCatalogReq, + TriggerCatalogRes, } from './dtos'; import { GrpcToHttpExceptionFilter } from 'src/error/grpc-to-http-exception.filter'; import { Language } from 'src/decorators/language.decorator'; @@ -180,7 +189,7 @@ export class CatalogController { ) async getDataAsset( @User() user: RequestUser, - @Param('id') id, + @Param('id') id: string, @Query('shared') shared?: 'true', ) { const { username, user_id, customer_id, customer_name, permissions } = user; @@ -196,7 +205,7 @@ export class CatalogController { let has_permission = false; const metadata = PackTheMetadata({ username, - user_id: undefined, + user_id, customer_id, customer_name, }); @@ -237,7 +246,7 @@ export class CatalogController { async getDataAssetRls( @User() user: RequestUser, @Headers() headers, - @Param('id') id, + @Param('id') id: string, ) { const { username, user_id, customer_id, customer_name, permissions } = user; @@ -292,7 +301,7 @@ export class CatalogController { async getDataAssetColumnsMetadata( @User() user: RequestUser, @Language() language: LanguageEnum, - @Param('id') id, + @Param('id') id: string, ): Promise { const { customer_name, customer_id, user_id, username } = user; @@ -323,7 +332,7 @@ export class CatalogController { async getDataAssetPreview( @User() user: RequestUser, @Language() language: LanguageEnum, - @Param('id') id, + @Param('id') id: string, ): Promise { const { customer_name, customer_id, user_id, username } = user; @@ -353,7 +362,7 @@ export class CatalogController { async getDataAssetDocs( @User() user: RequestUser, @Language() language: LanguageEnum, - @Param('id') id, + @Param('id') id: string, ): Promise { const { customer_name, customer_id, user_id, username } = user; @@ -383,7 +392,7 @@ export class CatalogController { async updateDataAsset( @User() user: RequestUser, @Language() language: LanguageEnum, - @Param('id') data_asset_id, + @Param('id') data_asset_id: string, @Body() body: IUpdateDataRequest, ): Promise { const { customer_id, customer_name, user_id, username } = user; @@ -579,4 +588,49 @@ export class CatalogController { 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; + } } diff --git a/src/modules/catalog/catalog.service.ts b/src/modules/catalog/catalog.service.ts index cd0adf3..6f743c1 100644 --- a/src/modules/catalog/catalog.service.ts +++ b/src/modules/catalog/catalog.service.ts @@ -18,7 +18,7 @@ import { CatalogClientConfiguration } from './catalog-client'; import { UsersService } from '../users/users.service'; import { RolesService } from '../roles/roles.service'; import { Metadata } from '@grpc/grpc-js'; -import { IUpdateDataRequest } from './dtos'; +import { IUpdateDataRequest, TriggerCatalogReq } from './dtos'; class CatalogService implements OnModuleInit { catalogReadService: ReadService.CatalogReadServices; @@ -333,6 +333,18 @@ class CatalogService implements OnModuleInit { } 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 }; diff --git a/src/modules/catalog/dtos/index.ts b/src/modules/catalog/dtos/index.ts index 3d29575..d7d135f 100644 --- a/src/modules/catalog/dtos/index.ts +++ b/src/modules/catalog/dtos/index.ts @@ -271,3 +271,44 @@ export class IColumnsMetadataResponse { @ApiProperty({ type: [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; +} diff --git a/src/modules/connection/connection.controller.ts b/src/modules/connection/connection.controller.ts index 255daba..d0231b5 100644 --- a/src/modules/connection/connection.controller.ts +++ b/src/modules/connection/connection.controller.ts @@ -164,7 +164,7 @@ export class ConnectionController { async getConnectionDetails( @Language() language: LanguageEnum, @User() user: RequestUser, - @Param('id') id, + @Param('id') id: string, @Query() queries, ): Promise { this.logger.info('/connections - Get Connection Details'); diff --git a/src/modules/inputs/inputs.controller.ts b/src/modules/inputs/inputs.controller.ts index 0145bc3..82ddd36 100644 --- a/src/modules/inputs/inputs.controller.ts +++ b/src/modules/inputs/inputs.controller.ts @@ -123,8 +123,7 @@ export class InputsController { } @Get('/:id') - async findOne(@Body() body, @Param() params) { - const { id } = params; + async findOne(@Body() body, @Param('id') id: string) { this.logger.info(`/input/${id} - ON FIND ONE ROUTE`, { user: body.info.user_id, customer: body.info.customer, diff --git a/src/modules/pipelines/pipelines.controller.ts b/src/modules/pipelines/pipelines.controller.ts index 0d967a2..24806c2 100644 --- a/src/modules/pipelines/pipelines.controller.ts +++ b/src/modules/pipelines/pipelines.controller.ts @@ -49,8 +49,7 @@ export class PipelinesController { description: 'This method is deprecated. Please use route /pipelinesV2/start/:id instead', }) - async activate(@Param() params, @Body() body) { - const { id } = params; + async activate(@Param('id') id: string, @Body() body) { const { info } = body; this.logger.info( @@ -72,8 +71,7 @@ export class PipelinesController { description: 'This method is deprecated. Please use route /pipelinesV2/:id/status instead', }) - async getPipelineStatus(@Body() body, @Param() params) { - const { id } = params; + async getPipelineStatus(@Body() body, @Param('id') id: string) { body.id = id; this.logger.info( diff --git a/src/modules/pipelinesV2/pipelines.controller.ts b/src/modules/pipelinesV2/pipelines.controller.ts index 5d5a6b7..9e75e93 100644 --- a/src/modules/pipelinesV2/pipelines.controller.ts +++ b/src/modules/pipelinesV2/pipelines.controller.ts @@ -170,7 +170,7 @@ export class PipelinesController { async getPipelineproperties( @Language() language: LanguageEnum, @User() user: RequestUser, - @Param('id') id, + @Param('id') id: string, ) { this.logger.info('PipelinesController - getPipelineproperties', { user }); const metadata = PackTheMetadata({ ...user, language: language }); @@ -181,7 +181,7 @@ export class PipelinesController { async getPipelineObjects( @Language() language: LanguageEnum, @User() user: RequestUser, - @Param('id') id, + @Param('id') id: string, ) { this.logger.info('PipelinesController - getPipelineObjects', { user }); const metadata = PackTheMetadata({ ...user, language: language }); @@ -189,8 +189,7 @@ export class PipelinesController { } @Get(':id/status') - async getPipelineStatus(@Body() body, @Param() params) { - const { id } = params; + async getPipelineStatus(@Body() body, @Param('id') id: string) { body.id = id; this.logger.info( @@ -210,7 +209,7 @@ export class PipelinesController { async findOne( @Language() language: LanguageEnum, @User() user: RequestUser, - @Param('id') id, + @Param('id') id: string, ): Promise { this.logger.info('PipelinesController - findOne', { user }); @@ -251,7 +250,7 @@ export class PipelinesController { async update( @Language() language: LanguageEnum, @Body() updatePipelineDto, - @Param('id') id, + @Param('id') id: string, @User() user: RequestUser, ) { this.logger.info('PipelinesController - update', { user }); @@ -290,7 +289,7 @@ export class PipelinesController { async updateDeprecated( @Language() language: LanguageEnum, @Body() updatePipelineDto, - @Param('id') id, + @Param('id') id: string, @User() user: RequestUser, ) { this.logger.info('PipelinesController - put', { user }); @@ -302,9 +301,8 @@ export class PipelinesController { @Delete(':id') @ApiNoContentResponse() @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 }); - const { id } = params; const metadata = PackTheMetadata({ customer_id: user.customer_id, customer_name: user.customer_name, @@ -416,8 +414,7 @@ export class PipelinesController { @ApiInternalOnlyEndpoint() @Post('start/:id') - async activate(@Param() params, @Body() body) { - const { id } = params; + async activate(@Param('id') id: string, @Body() body) { const { info } = body; this.logger.info( diff --git a/src/modules/transformations/transformations.controller.ts b/src/modules/transformations/transformations.controller.ts index 4cedddb..8b844e7 100644 --- a/src/modules/transformations/transformations.controller.ts +++ b/src/modules/transformations/transformations.controller.ts @@ -72,8 +72,7 @@ export class TransformationsController { @Get('/:id') @RequireSomePermission(pipelinePermissions.GET) - async findOne(@Body() data, @Param() params) { - const { id } = params; + async findOne(@Body() data, @Param('id') id: string) { this.logger.info(`/transformation/${id} - ON Find One ROUTE`, { user: data.info.user_id, customer: data.info.customer,