FIX: send token by storage

This commit is contained in:
marcos-silva-rodrigues
2026-02-02 15:37:13 -03:00
parent 0e038d0b12
commit cd4382c1ff
3 changed files with 192 additions and 6 deletions
+152 -4
View File
@@ -7865,7 +7865,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_validateTableName", "operationId": "StorageExplorerController_validateTableName",
"summary": "Validate table name in PostgreSQL and Snowflake", "summary": "Validate table name in PostgreSQL and Snowflake",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -7895,7 +7904,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_createTable", "operationId": "StorageExplorerController_createTable",
"summary": "Create a new table", "summary": "Create a new table",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -7931,6 +7949,14 @@
"schema": { "schema": {
"type": "number" "type": "number"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -7970,6 +7996,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8017,6 +8051,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8056,6 +8098,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8095,6 +8145,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8142,6 +8200,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8189,6 +8255,14 @@
"schema": { "schema": {
"type": "number" "type": "number"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8236,6 +8310,14 @@
"schema": { "schema": {
"type": "boolean" "type": "boolean"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8275,6 +8357,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8314,6 +8404,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8369,6 +8467,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8408,6 +8514,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8439,7 +8553,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_batchUpload", "operationId": "StorageExplorerController_batchUpload",
"summary": "Upload multiple files to storage", "summary": "Upload multiple files to storage",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -8469,7 +8592,16 @@
"post": { "post": {
"operationId": "StorageExplorerController_createFolder", "operationId": "StorageExplorerController_createFolder",
"summary": "Create a new folder in storage", "summary": "Create a new folder in storage",
"parameters": [], "parameters": [
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
}
],
"responses": { "responses": {
"201": { "201": {
"description": "", "description": "",
@@ -8507,6 +8639,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -8546,6 +8686,14 @@
"schema": { "schema": {
"type": "string" "type": "string"
} }
},
{
"name": "Authorization",
"required": true,
"in": "header",
"schema": {
"type": "string"
}
} }
], ],
"responses": { "responses": {
@@ -3,13 +3,13 @@ import {
Get, Get,
Post, Post,
Put, Put,
Delete,
Param, Param,
Body, Body,
Query, Query,
Inject, Inject,
UseInterceptors, UseInterceptors,
UploadedFiles, UploadedFiles,
Headers,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiConsumes } from '@nestjs/swagger'; import { ApiTags, ApiOperation, ApiConsumes } from '@nestjs/swagger';
import { FilesInterceptor } from '@nestjs/platform-express'; import { FilesInterceptor } from '@nestjs/platform-express';
@@ -47,11 +47,13 @@ export class StorageExplorerController {
async validateTableName( async validateTableName(
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
'/tables/validate-name', '/tables/validate-name',
user, user,
token,
body, body,
); );
} }
@@ -62,11 +64,13 @@ export class StorageExplorerController {
async createTable( async createTable(
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
'/tables/', '/tables/',
user, user,
token,
body, body,
); );
} }
@@ -77,11 +81,13 @@ export class StorageExplorerController {
async listTables( async listTables(
@Query('page') page: number, @Query('page') page: number,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/tables/', '/tables/',
user, user,
token,
undefined, undefined,
{ page }, { page },
); );
@@ -93,11 +99,13 @@ export class StorageExplorerController {
async getTable( async getTable(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/tables/${tableId}`, `/tables/${tableId}`,
user, user,
token
); );
} }
@@ -108,11 +116,13 @@ export class StorageExplorerController {
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
`/tables/${tableId}/datasets/${datasetId}`, `/tables/${tableId}/datasets/${datasetId}`,
user, user,
token
); );
} }
@@ -122,11 +132,13 @@ export class StorageExplorerController {
async getTableDatasets( async getTableDatasets(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/tables/${tableId}/datasets`, `/tables/${tableId}/datasets`,
user, user,
token
); );
} }
@@ -136,11 +148,13 @@ export class StorageExplorerController {
async getTableSchema( async getTableSchema(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/tables/${tableId}/schema`, `/tables/${tableId}/schema`,
user, user,
token
); );
} }
@@ -151,11 +165,13 @@ export class StorageExplorerController {
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
`/tables/${tableId}/validate-compatibility/${datasetId}`, `/tables/${tableId}/validate-compatibility/${datasetId}`,
user, user,
token
); );
} }
@@ -170,11 +186,13 @@ export class StorageExplorerController {
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@Query('limit') limit: number, @Query('limit') limit: number,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/datasets/${datasetId}/preview`, `/datasets/${datasetId}/preview`,
user, user,
token,
undefined, undefined,
{ limit }, { limit },
); );
@@ -187,11 +205,13 @@ export class StorageExplorerController {
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@Query('force_refresh') forceRefresh: boolean, @Query('force_refresh') forceRefresh: boolean,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/datasets/${datasetId}/schema`, `/datasets/${datasetId}/schema`,
user, user,
token,
undefined, undefined,
{ force_refresh: forceRefresh }, { force_refresh: forceRefresh },
); );
@@ -203,11 +223,13 @@ export class StorageExplorerController {
async listDatasetsByUpload( async listDatasetsByUpload(
@Param('uploadId') uploadId: string, @Param('uploadId') uploadId: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
`/datasets/upload/${uploadId}`, `/datasets/upload/${uploadId}`,
user, user,
token
); );
} }
@@ -218,11 +240,13 @@ export class StorageExplorerController {
@Param('datasetId') datasetId: string, @Param('datasetId') datasetId: string,
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'PUT', 'PUT',
`/datasets/${datasetId}/refresh-schema`, `/datasets/${datasetId}/refresh-schema`,
user, user,
token,
body, body,
); );
} }
@@ -239,11 +263,13 @@ export class StorageExplorerController {
@Query('limit') limit: number, @Query('limit') limit: number,
@Query('folder_path') folderPath: string, @Query('folder_path') folderPath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/uploads/history', '/storage/uploads/history',
user, user,
token,
undefined, undefined,
{ page, limit, folder_path: folderPath }, { page, limit, folder_path: folderPath },
); );
@@ -255,11 +281,13 @@ export class StorageExplorerController {
async browseStorage( async browseStorage(
@Query('path') path: string, @Query('path') path: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/browse', '/storage/browse',
user, user,
token,
undefined, undefined,
{ path }, { path },
); );
@@ -274,6 +302,7 @@ export class StorageExplorerController {
@UploadedFiles() files: Array<Express.Multer.File>, @UploadedFiles() files: Array<Express.Multer.File>,
@Body('folder_path') folderPath: string, @Body('folder_path') folderPath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
// Create FormData to forward files to storage-explorer API // Create FormData to forward files to storage-explorer API
const formData = new FormData(); const formData = new FormData();
@@ -297,6 +326,7 @@ export class StorageExplorerController {
'POST', 'POST',
'/storage/upload/batch', '/storage/upload/batch',
user, user,
token,
formData, formData,
); );
} }
@@ -307,11 +337,13 @@ export class StorageExplorerController {
async createFolder( async createFolder(
@Body() body: any, @Body() body: any,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'POST', 'POST',
'/storage/folder/create', '/storage/folder/create',
user, user,
token,
body, body,
); );
} }
@@ -322,11 +354,13 @@ export class StorageExplorerController {
async downloadFile( async downloadFile(
@Query('file_path') filePath: string, @Query('file_path') filePath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/download', '/storage/download',
user, user,
token,
undefined, undefined,
{ file_path: filePath }, { file_path: filePath },
); );
@@ -338,11 +372,13 @@ export class StorageExplorerController {
async getFileMetadata( async getFileMetadata(
@Query('file_path') filePath: string, @Query('file_path') filePath: string,
@User() user: RequestUser, @User() user: RequestUser,
@Headers('Authorization') token: string
) { ) {
return this.storageExplorerService.proxy( return this.storageExplorerService.proxy(
'GET', 'GET',
'/storage/metadata', '/storage/metadata',
user, user,
token,
undefined, undefined,
{ file_path: filePath }, { file_path: filePath },
); );
@@ -19,8 +19,9 @@ export class StorageExplorerService {
method: string, method: string,
path: string, path: string,
user: RequestUser, user: RequestUser,
token: string,
body?: any, body?: any,
query?: Record<string, any>, query?: Record<string, any>
): Promise<any> { ): Promise<any> {
// Validate customer_id is present for multi-tenant isolation // Validate customer_id is present for multi-tenant isolation
if (!user.customer_id) { if (!user.customer_id) {
@@ -41,6 +42,7 @@ export class StorageExplorerService {
} }
const headers: Record<string, string> = { const headers: Record<string, string> = {
'Authorization': token,
'content-type': 'application/json', 'content-type': 'application/json',
}; };