diff --git a/packages/nocodb-sdk/src/lib/enums.ts b/packages/nocodb-sdk/src/lib/enums.ts index dd77534f27..85e2e6f8c9 100644 --- a/packages/nocodb-sdk/src/lib/enums.ts +++ b/packages/nocodb-sdk/src/lib/enums.ts @@ -296,3 +296,9 @@ export enum PlanLimitTypes { FILTER_LIMIT = 'FILTER_LIMIT', SORT_LIMIT = 'SORT_LIMIT', } + +export enum APIContext { + VIEW_COLUMNS = 'fields', + FILTERS = 'filters', + SORTS = 'sorts', +} diff --git a/packages/nocodb/src/controllers/view-columns.controller.ts b/packages/nocodb/src/controllers/view-columns.controller.ts index 5a27b27876..b331d4b630 100644 --- a/packages/nocodb/src/controllers/view-columns.controller.ts +++ b/packages/nocodb/src/controllers/view-columns.controller.ts @@ -9,7 +9,7 @@ import { Req, UseGuards, } from '@nestjs/common'; -import { ViewColumnReqType } from 'nocodb-sdk'; +import { APIContext, ViewColumnReqType } from 'nocodb-sdk' import { GlobalGuard } from '~/guards/global/global.guard'; import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { ViewColumnsService } from '~/services/view-columns.service'; @@ -79,7 +79,7 @@ export class ViewColumnsController { async viewColumnUpdate( @Req() req, @Param('viewId') viewId: string, - @Body() body: ViewColumnReqType[] | Record, + @Body() body: ViewColumnReqType[] | Record>, ) { return new PagedResponseImpl( await this.viewColumnsService.columnsUpdate({ @@ -93,9 +93,11 @@ export class ViewColumnsController { @Get('/api/v3/meta/views/:viewId/columns') @Acl('columnList') async viewColumnList(@Req() req, @Param('viewId') viewId: string) { - return await this.viewColumnsService.viewColumnList({ - viewId, - req, - }); + return { + [APIContext.VIEW_COLUMNS]: await this.viewColumnsService.viewColumnList({ + viewId, + req, + }) + }; } } diff --git a/packages/nocodb/src/schema/swagger-v3.json b/packages/nocodb/src/schema/swagger-v3.json index 03209c477c..8dfb714dfe 100644 --- a/packages/nocodb/src/schema/swagger-v3.json +++ b/packages/nocodb/src/schema/swagger-v3.json @@ -99,1035 +99,1196 @@ "application/json": { "schema": { "type": "object", - "additionalProperties": { - "oneOf": [ - { - "$ref": "#/components/schemas/GridColumnReq" - }, - { - "$ref": "#/components/schemas/GalleryColumnReq" - }, - { - "$ref": "#/components/schemas/FormColumnReq" - }, - { - "$ref": "#/components/schemas/KanbanColumnReq" - }, - { - "$ref": "#/components/schemas/MapColumnReq" - }, - { - "$ref": "#/components/schemas/CalendarColumnReq" + "properties": { + "fields": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/components/schemas/GridColumnReq" + }, + { + "$ref": "#/components/schemas/GalleryColumnReq" + }, + { + "$ref": "#/components/schemas/FormColumnReq" + }, + { + "$ref": "#/components/schemas/KanbanColumnReq" + }, + { + "$ref": "#/components/schemas/MapColumnReq" + }, + { + "$ref": "#/components/schemas/CalendarColumnReq" + } + ] } - ] + } } } } - } + }, + "description": "Copy links from the one cell and paste them into another cell or delete all records from cell", + "parameters": [ + { + "$ref": "#/components/parameters/xc-auth" + } + ] }, - "description": "Copy links from the one cell and paste them into another cell or delete all records from cell", - "parameters": [ - { - "$ref": "#/components/parameters/xc-auth" - } - ] - }, - "get": { - "summary": "Get view column metas", - "operationId": "db-view-columns-get", - "tags": [ - "DB View Columns" - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/json": { - "schema": { - "type": "object", - "additionalProperties": { - "oneOf": [ - { - "$ref": "#/components/schemas/GridColumn" - }, - { - "$ref": "#/components/schemas/GalleryColumn" - }, - { - "$ref": "#/components/schemas/FormColumn" - }, - { - "$ref": "#/components/schemas/KanbanColumn" - }, - { - "$ref": "#/components/schemas/MapColumn" - }, - { - "$ref": "#/components/schemas/CalendarColumn" + "get": { + "summary": "Get view column metas", + "operationId": "db-view-columns-get", + "tags": [ + "DB View Columns" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "fields": { + "type": "object", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/components/schemas/GridColumn" + }, + { + "$ref": "#/components/schemas/GalleryColumn" + }, + { + "$ref": "#/components/schemas/FormColumn" + }, + { + "$ref": "#/components/schemas/KanbanColumn" + }, + { + "$ref": "#/components/schemas/MapColumn" + }, + { + "$ref": "#/components/schemas/CalendarColumn" + } + ] + } } - ] + } } } + }, + "400": { + "$ref": "#/components/responses/BadRequest" } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - } - }, - "description": "Copy links from the one cell and paste them into another cell or delete all records from cell", - "parameters": [ - { - "$ref": "#/components/parameters/xc-auth" - } - ] - } - } - }, - "components": { - "schemas": { - "FormColumn": { - "description": "Model for Form Column", - "examples": [ - { - "id": "fvc_1m9b0aub791d4m", - "description": null, - "fk_column_id": "cl_ah9zavkn25ihyd", - "fk_view_id": "vw_6fqln9vdytdv8q", - "help": "This is a help text", - "label": "Form Label", - "meta": null, - "order": 1, - "required": 0, - "show": 0, - "uuid": null - } - ], - "title": "Form Column Model", - "type": "object", - "x-examples": { - "example-1": { - "_cn": "first_name", - "alias": "first_name", - "created_at": "2022-02-15 12:39:04", - "description": "dsdsdsdsd", - "fk_column_id": "cl_yvyhsl9u81tokc", - "fk_view_id": "vw_s1pf4umdnikoyn", - "help": null, - "id": "fvc_8z1i7t8aswkqxx", - "label": "dsdsds", - "order": 1, - "required": false, - "show": 1, - "enable_scanner": true, - "updated_at": "2022-02-15 12:39:16", - "uuid": null - } - }, - "properties": { - "id": { - "$ref": "#/components/schemas/Id", - "description": "Unique ID" - }, - "description": { - "$ref": "#/components/schemas/TextOrNull", - "description": "Form Column Description" - }, - "fk_column_id": { - "$ref": "#/components/schemas/Id", - "description": "Foreign Key to Column" - }, - "fk_view_id": { - "$ref": "#/components/schemas/Id", - "description": "Foreign Key to View" - }, - "help": { - "$ref": "#/components/schemas/TextOrNull", - "description": "Form Column Help Text (Not in use)" - }, - "label": { - "$ref": "#/components/schemas/TextOrNull", - "description": "Form Column Label" - }, - "meta": { - "$ref": "#/components/schemas/Meta", - "description": "Meta Info" - }, - "order": { - "type": "number", - "description": "The order among all the columns in the form", - "example": 1 - }, - "required": { - "$ref": "#/components/schemas/Bool", - "description": "Is this form column required in submission?" - }, - "show": { - "$ref": "#/components/schemas/Bool", - "description": "Is this column shown in Form?" - }, - "enable_scanner": { - "$ref": "#/components/schemas/Bool", - "description": "Indicates whether the 'Fill by scan' button is visible for this column or not.", - "example": true - }, - "uuid": { - "$ref": "#/components/schemas/StringOrNull", - "description": "Form Column UUID (Not in use)" - } - }, - "x-stoplight": { - "id": "rs2uh5opf10q6" - } - }, - "FormColumnReq": { - "description": "Model for Form Column Request", - "examples": [ - { - "description": null, - "help": "This is a help text", - "label": "Form Label", - "meta": null, - "order": 1, - "required": 0, - "show": 0 - } - ], - "title": "Form Column Request Model", - "type": "object", - "x-examples": { - "example-1": { - "_cn": "first_name", - "alias": "first_name", - "created_at": "2022-02-15 12:39:04", - "description": "dsdsdsdsd", - "fk_column_id": "cl_yvyhsl9u81tokc", - "fk_view_id": "vw_s1pf4umdnikoyn", - "help": null, - "id": "fvc_8z1i7t8aswkqxx", - "label": "dsdsds", - "order": 1, - "required": false, - "show": 1, - "updated_at": "2022-02-15 12:39:16", - "uuid": null - } - }, - "properties": { - "description": { - "$ref": "#/components/schemas/TextOrNull", - "description": "Form Column Description" - }, - "help": { - "$ref": "#/components/schemas/TextOrNull", - "description": "Form Column Help Text (Not in use)" - }, - "label": { - "$ref": "#/components/schemas/TextOrNull", - "description": "Form Column Label" - }, - "meta": { - "$ref": "#/components/schemas/Meta", - "description": "Meta Info" - }, - "order": { - "type": "number", - "description": "The order among all the columns in the form" - }, - "required": { - "$ref": "#/components/schemas/Bool", - "description": "Is this form column required in submission?" - }, - "show": { - "$ref": "#/components/schemas/Bool", - "description": "Is this column shown in Form?" - } - }, - "x-stoplight": { - "id": "a1vgymjna1ose" - } - }, - "GalleryColumn": { - "description": "Model for Gallery Column", - "examples": [ - { - "fk_col_id": "string", - "fk_gallery_id": "string", - "help": "string", - "id": "string", - "label": "string" - } - ], - "properties": { - "fk_col_id": { - "type": "string" - }, - "fk_gallery_id": { - "type": "string" - }, - "help": { - "type": "string" - }, - "id": { - "$ref": "#/components/schemas/Id", - "description": "Unique ID" - }, - "label": { - "type": "string" + }, + "description": "Copy links from the one cell and paste them into another cell or delete all records from cell", + "parameters": [ + { + "$ref": "#/components/parameters/xc-auth" + } + ] } - }, - "title": "Gallery Column Model", - "type": "object", - "x-stoplight": { - "id": "auloy6128iwh9" } }, - "GridColumn": { - "description": "Model for Grid Column", - "examples": [ - { - "id": "nc_c8jz4kxe6xvh11", - "fk_view_id": "vw_p2jcatxz4mvcfw", - "fk_column_id": "cl_c5knoi4xs4sfpt", - "base_id": "p_xm3thidrblw4n7", - "source_id": "ds_g4ccx6e77h1dmi", - "show": 0, - "order": 1, - "width": "200px", - "help": null, - "group_by": 0, - "group_by_order": null, - "group_by_sort": null - } - ], - "title": "Grid Column Model", - "type": "object", - "properties": { - "id": { - "$ref": "#/components/schemas/Id", - "description": "Unique ID", - "x-stoplight": { - "id": "jc14yojp52rqj" - } - }, - "fk_view_id": { - "$ref": "#/components/schemas/Id", - "description": "Foreign Key to View", + "components": { + "schemas": { + "FormColumn": { + "description": "Model for Form Column", + "examples": [ + { + "id": "fvc_1m9b0aub791d4m", + "description": null, + "fk_column_id": "cl_ah9zavkn25ihyd", + "fk_view_id": "vw_6fqln9vdytdv8q", + "help": "This is a help text", + "label": "Form Label", + "meta": null, + "order": 1, + "required": 0, + "show": 0, + "uuid": null + } + ], + "title": "Form Column Model", + "type": "object", + "x-examples": { + "example-1": { + "_cn": "first_name", + "alias": "first_name", + "created_at": "2022-02-15 12:39:04", + "description": "dsdsdsdsd", + "fk_column_id": "cl_yvyhsl9u81tokc", + "fk_view_id": "vw_s1pf4umdnikoyn", + "help": null, + "id": "fvc_8z1i7t8aswkqxx", + "label": "dsdsds", + "order": 1, + "required": false, + "show": 1, + "enable_scanner": true, + "updated_at": "2022-02-15 12:39:16", + "uuid": null + } + }, + "properties": { + "id": { + "$ref": "#/components/schemas/Id", + "description": "Unique ID" + }, + "description": { + "$ref": "#/components/schemas/TextOrNull", + "description": "Form Column Description" + }, + "fk_column_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to Column" + }, + "fk_view_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to View" + }, + "help": { + "$ref": "#/components/schemas/TextOrNull", + "description": "Form Column Help Text (Not in use)" + }, + "label": { + "$ref": "#/components/schemas/TextOrNull", + "description": "Form Column Label" + }, + "meta": { + "$ref": "#/components/schemas/Meta", + "description": "Meta Info" + }, + "order": { + "type": "number", + "description": "The order among all the columns in the form", + "example": 1 + }, + "required": { + "$ref": "#/components/schemas/Bool", + "description": "Is this form column required in submission?" + }, + "show": { + "$ref": "#/components/schemas/Bool", + "description": "Is this column shown in Form?" + }, + "enable_scanner": { + "$ref": "#/components/schemas/Bool", + "description": "Indicates whether the 'Fill by scan' button is visible for this column or not.", + "example": true + }, + "uuid": { + "$ref": "#/components/schemas/StringOrNull", + "description": "Form Column UUID (Not in use)" + } + }, "x-stoplight": { - "id": "vl18dbt5c2r8r" + "id": "rs2uh5opf10q6" } }, - "fk_column_id": { - "$ref": "#/components/schemas/Id", - "description": "Foreign Key to Column", + "FormColumnReq": { + "description": "Model for Form Column Request", + "examples": [ + { + "description": null, + "help": "This is a help text", + "label": "Form Label", + "meta": null, + "order": 1, + "required": 0, + "show": 0 + } + ], + "title": "Form Column Request Model", + "type": "object", + "x-examples": { + "example-1": { + "_cn": "first_name", + "alias": "first_name", + "created_at": "2022-02-15 12:39:04", + "description": "dsdsdsdsd", + "fk_column_id": "cl_yvyhsl9u81tokc", + "fk_view_id": "vw_s1pf4umdnikoyn", + "help": null, + "id": "fvc_8z1i7t8aswkqxx", + "label": "dsdsds", + "order": 1, + "required": false, + "show": 1, + "updated_at": "2022-02-15 12:39:16", + "uuid": null + } + }, + "properties": { + "description": { + "$ref": "#/components/schemas/TextOrNull", + "description": "Form Column Description" + }, + "help": { + "$ref": "#/components/schemas/TextOrNull", + "description": "Form Column Help Text (Not in use)" + }, + "label": { + "$ref": "#/components/schemas/TextOrNull", + "description": "Form Column Label" + }, + "meta": { + "$ref": "#/components/schemas/Meta", + "description": "Meta Info" + }, + "order": { + "type": "number", + "description": "The order among all the columns in the form" + }, + "required": { + "$ref": "#/components/schemas/Bool", + "description": "Is this form column required in submission?" + }, + "show": { + "$ref": "#/components/schemas/Bool", + "description": "Is this column shown in Form?" + } + }, "x-stoplight": { - "id": "2drg88fmodf3v" + "id": "a1vgymjna1ose" } }, - "base_id": { - "$ref": "#/components/schemas/Id", - "description": "Base ID", + "GalleryColumn": { + "description": "Model for Gallery Column", + "examples": [ + { + "fk_col_id": "string", + "fk_gallery_id": "string", + "help": "string", + "id": "string", + "label": "string" + } + ], + "properties": { + "fk_col_id": { + "type": "string" + }, + "fk_gallery_id": { + "type": "string" + }, + "help": { + "type": "string" + }, + "id": { + "$ref": "#/components/schemas/Id", + "description": "Unique ID" + }, + "label": { + "type": "string" + } + }, + "title": "Gallery Column Model", + "type": "object", "x-stoplight": { - "id": "2drg88fmodf3v" + "id": "auloy6128iwh9" } }, - "source_id": { - "$ref": "#/components/schemas/Id", - "description": "Source ID", + "GridColumn": { + "description": "Model for Grid Column", + "examples": [ + { + "id": "nc_c8jz4kxe6xvh11", + "fk_view_id": "vw_p2jcatxz4mvcfw", + "fk_column_id": "cl_c5knoi4xs4sfpt", + "base_id": "p_xm3thidrblw4n7", + "source_id": "ds_g4ccx6e77h1dmi", + "show": 0, + "order": 1, + "width": "200px", + "help": null, + "group_by": 0, + "group_by_order": null, + "group_by_sort": null + } + ], + "title": "Grid Column Model", + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/Id", + "description": "Unique ID", + "x-stoplight": { + "id": "jc14yojp52rqj" + } + }, + "fk_view_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to View", + "x-stoplight": { + "id": "vl18dbt5c2r8r" + } + }, + "fk_column_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to Column", + "x-stoplight": { + "id": "2drg88fmodf3v" + } + }, + "base_id": { + "$ref": "#/components/schemas/Id", + "description": "Base ID", + "x-stoplight": { + "id": "2drg88fmodf3v" + } + }, + "source_id": { + "$ref": "#/components/schemas/Id", + "description": "Source ID", + "x-stoplight": { + "id": "2drg88fmodf3v" + } + }, + "show": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "d47eer13oa8yr" + } + }, + "order": { + "type": "number", + "x-stoplight": { + "id": "d47eer13oa8yr" + }, + "example": 1, + "description": "Grid Column Order" + }, + "width": { + "type": "string", + "description": "Column Width", + "example": "200px" + }, + "help": { + "$ref": "#/components/schemas/StringOrNull", + "description": "Column Help Text", + "x-stoplight": { + "id": "azwh6zn37qzkc" + } + }, + "group_by": { + "$ref": "#/components/schemas/Bool", + "description": "Group By" + }, + "group_by_order": { + "type": "number", + "description": "Group By Order", + "example": 1 + }, + "group_by_sort": { + "$ref": "#/components/schemas/StringOrNull", + "description": "Group By Sort", + "example": "asc" + } + }, "x-stoplight": { - "id": "2drg88fmodf3v" + "id": "195gzd7s6p7nv" } }, - "show": { - "$ref": "#/components/schemas/Bool", + "GridColumnReq": { + "description": "Model for Grid Column Request", + "examples": [ + { + "fk_column_id": "cl_c5knoi4xs4sfpt", + "label": "My Column", + "width": "200px" + } + ], + "properties": { + "fk_column_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to Column" + }, + "help": { + "maxLength": 255, + "type": "string" + }, + "label": { + "description": "The label of the column", + "example": "My Column", + "maxLength": 255, + "type": "string" + }, + "width": { + "description": "The width of the column", + "example": "200px", + "maxLength": 255, + "pattern": "^[0-9]+(px|%)$", + "type": "string" + }, + "group_by": { + "$ref": "#/components/schemas/Bool", + "description": "Group By" + }, + "group_by_order": { + "type": "number", + "description": "Group By Order", + "example": 1 + }, + "group_by_sort": { + "$ref": "#/components/schemas/StringOrNull", + "description": "Group By Sort", + "example": "asc" + }, + "show": { + "$ref": "#/components/schemas/Bool", + "description": "Show" + }, + "order": { + "type": "number", + "description": "Order", + "example": 1 + } + }, + "title": "Grid Column Request Model", + "type": "object", "x-stoplight": { - "id": "d47eer13oa8yr" + "id": "9yhalgmix6d0m" } }, - "order": { - "type": "number", - "x-stoplight": { - "id": "d47eer13oa8yr" + "KanbanColumn": { + "description": "Model for Kanban Column", + "examples": [ + { + "id": "kvc_2skkg5mi1eb37f", + "fk_column_id": "cl_hzos4ghyncqi4k", + "fk_view_id": "vw_wqs4zheuo5lgdy", + "source_id": "ds_hd4ojj0xpquaam", + "base_id": "p_kzfl5lb0t3tcok", + "title": "string", + "show": 0, + "order": "1" + } + ], + "title": "Kanban Column Model", + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/Id", + "description": "Unique ID" + }, + "fk_column_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to Column" + }, + "fk_view_id": { + "$ref": "#/components/schemas/Id", + "x-stoplight": { + "id": "t1fy4zy561ih8" + }, + "description": "Foreign Key to View" + }, + "source_id": { + "$ref": "#/components/schemas/Id", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Baes ID\n" + }, + "base_id": { + "$ref": "#/components/schemas/Id", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Base ID" + }, + "title": { + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Base ID", + "type": "string" + }, + "show": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown?" + }, + "order": { + "type": "number", + "x-stoplight": { + "id": "pbnchzgci5dwa" + }, + "example": 1, + "description": "Column Order" + } }, - "example": 1, - "description": "Grid Column Order" - }, - "width": { - "type": "string", - "description": "Column Width", - "example": "200px" - }, - "help": { - "$ref": "#/components/schemas/StringOrNull", - "description": "Column Help Text", "x-stoplight": { - "id": "azwh6zn37qzkc" + "id": "psbv6c6y9qvbu" } }, - "group_by": { - "$ref": "#/components/schemas/Bool", - "description": "Group By" - }, - "group_by_order": { - "type": "number", - "description": "Group By Order", - "example": 1 - }, - "group_by_sort": { - "$ref": "#/components/schemas/StringOrNull", - "description": "Group By Sort", - "example": "asc" - } - }, - "x-stoplight": { - "id": "195gzd7s6p7nv" - } - }, - "GridColumnReq": { - "description": "Model for Grid Column Request", - "examples": [ - { - "fk_column_id": "cl_c5knoi4xs4sfpt", - "label": "My Column", - "width": "200px" - } - ], - "properties": { - "fk_column_id": { - "$ref": "#/components/schemas/Id", - "description": "Foreign Key to Column" - }, - "help": { - "maxLength": 255, - "type": "string" - }, - "label": { - "description": "The label of the column", - "example": "My Column", - "maxLength": 255, - "type": "string" - }, - "width": { - "description": "The width of the column", - "example": "200px", - "maxLength": 255, - "pattern": "^[0-9]+(px|%)$", - "type": "string" - }, - "group_by": { - "$ref": "#/components/schemas/Bool", - "description": "Group By" - }, - "group_by_order": { - "type": "number", - "description": "Group By Order", - "example": 1 - }, - "group_by_sort": { - "$ref": "#/components/schemas/StringOrNull", - "description": "Group By Sort", - "example": "asc" - }, - "show": { - "$ref": "#/components/schemas/Bool", - "description": "Show" - }, - "order": { - "type": "number", - "description": "Order", - "example": 1 - } - }, - "title": "Grid Column Request Model", - "type": "object", - "x-stoplight": { - "id": "9yhalgmix6d0m" - } - }, - "KanbanColumn": { - "description": "Model for Kanban Column", - "examples": [ - { - "id": "kvc_2skkg5mi1eb37f", - "fk_column_id": "cl_hzos4ghyncqi4k", - "fk_view_id": "vw_wqs4zheuo5lgdy", - "source_id": "ds_hd4ojj0xpquaam", - "base_id": "p_kzfl5lb0t3tcok", - "title": "string", - "show": 0, - "order": "1" - } - ], - "title": "Kanban Column Model", - "type": "object", - "properties": { - "id": { - "$ref": "#/components/schemas/Id", - "description": "Unique ID" - }, - "fk_column_id": { - "$ref": "#/components/schemas/Id", - "description": "Foreign Key to Column" - }, - "fk_view_id": { - "$ref": "#/components/schemas/Id", - "x-stoplight": { - "id": "t1fy4zy561ih8" - }, - "description": "Foreign Key to View" + "KanbanColumnReq": { + "description": "Model for Kanban Column Request", + "examples": [ + { + "title": "string", + "show": 0, + "order": "1" + } + ], + "title": "Kanban Column Model Request", + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "Title" + }, + "show": { + "$ref": "#/components/schemas/Bool", + "description": "Is this column shown?" + }, + "order": { + "type": "number", + "example": 1, + "description": "Column Order" + } + } }, - "source_id": { - "$ref": "#/components/schemas/Id", - "x-stoplight": { - "id": "uqq8xmyz97t1u" - }, - "description": "Baes ID\n" + "GalleryColumnReq": { + "description": "Model for Gallery Column Request", + "examples": [ + { + "label": "My Column", + "width": "200px" + } + ], + "properties": { + "show": { + "$ref": "#/components/schemas/Bool", + "description": "Show" + }, + "order": { + "type": "number", + "description": "Order", + "example": 1 + } + } }, - "base_id": { - "$ref": "#/components/schemas/Id", - "x-stoplight": { - "id": "uqq8xmyz97t1u" + "CalendarColumn": { + "description": "Model for Calendar Column", + "examples": [ + { + "id": "kvc_2skkg5mi1eb37f", + "fk_column_id": "cl_hzos4ghyncqi4k", + "fk_view_id": "vw_wqs4zheuo5lgdy", + "source_id": "ds_hd4ojj0xpquaam", + "base_id": "p_kzfl5lb0t3tcok", + "title": "string", + "show": 0, + "bold": 0, + "italic": 0, + "underline": 0, + "order": "1" + } + ], + "title": "Calendar Column Model", + "type": "object", + "properties": { + "id": { + "$ref": "#/components/schemas/Id", + "description": "Unique ID" + }, + "fk_column_id": { + "$ref": "#/components/schemas/Id", + "description": "Foreign Key to Column" + }, + "fk_view_id": { + "$ref": "#/components/schemas/Id", + "x-stoplight": { + "id": "t1fy4zy561ih8" + }, + "description": "Foreign Key to View" + }, + "source_id": { + "$ref": "#/components/schemas/Id", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Baes ID\n" + }, + "base_id": { + "$ref": "#/components/schemas/Id", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Base ID" + }, + "title": { + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Base ID", + "type": "string" + }, + "show": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown?" + }, + "bold": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown as bold?" + }, + "italic": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown as italic?" + }, + "underline": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown underlines?" + }, + "order": { + "type": "number", + "x-stoplight": { + "id": "pbnchzgci5dwa" + }, + "example": 1, + "description": "Column Order" + } }, - "description": "Base ID" - }, - "title": { "x-stoplight": { - "id": "uqq8xmyz97t1u" - }, - "description": "Base ID", - "type": "string" + "id": "psbv6c6y9qvbu" + } }, - "show": { - "$ref": "#/components/schemas/Bool", - "x-stoplight": { - "id": "uqq8xmyz97t1u" + "CalendarColumnReq": { + "description": "Model for Calendar Column Request", + "examples": [ + { + "title": "string", + "show": 0, + "bold": 0, + "italic": 0, + "underline": 0, + "order": "1" + } + ], + "title": "Calendar Column Model", + "type": "object", + "properties": { + "show": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown?" + }, + "bold": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown as bold?" + }, + "italic": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown as italic?" + }, + "underline": { + "$ref": "#/components/schemas/Bool", + "x-stoplight": { + "id": "uqq8xmyz97t1u" + }, + "description": "Is this column shown underlines?" + }, + "order": { + "type": "number", + "x-stoplight": { + "id": "pbnchzgci5dwa" + }, + "example": 1, + "description": "Column Order" + } }, - "description": "Is this column shown?" - }, - "order": { - "type": "number", "x-stoplight": { - "id": "pbnchzgci5dwa" - }, - "example": 1, - "description": "Column Order" + "id": "psbv6c6y9qvbu" + } } }, - "x-stoplight": { - "id": "psbv6c6y9qvbu" - } - }, - "KanbanColumnReq": { - "description": "Model for Kanban Column Request", - "examples": [ - { - "title": "string", - "show": 0, - "order": "1" - } - ], - "title": "Kanban Column Model Request", - "type": "object", - "properties": { - "title": { - "type": "string", - "description": "Title" - }, - "show": { - "$ref": "#/components/schemas/Bool", - "description": "Is this column shown?" - }, - "order": { - "type": "number", - "example": 1, - "description": "Column Order" - } - } - }, - "GalleryColumnReq": { - "description": "Model for Gallery Column Request", - "examples": [ - { - "label": "My Column", - "width": "200px" - } - ], - "properties": { - "show": { - "$ref": "#/components/schemas/Bool", - "description": "Show" - }, - "order": { - "type": "number", - "description": "Order", - "example": 1 - } - } - } - }, - "responses": { - "ProjectList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ProjectList" - }, - "examples": { - "example-1": { - "value": { - "list": [ - { - "sources": [ + "responses": { + "ProjectList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProjectList" + }, + "examples": { + "example-1": { + "value": { + "list": [ { - "alias": "string", - "config": null, + "sources": [ + { + "alias": "string", + "config": null, + "created_at": "2023-03-01 14:27:36", + "enabled": true, + "id": "string", + "inflection_column": "camelize", + "inflection_table": "camelize", + "is_meta": true, + "order": 1, + "base_id": "string", + "type": "mysql2", + "updated_at": "2023-03-01 14:27:36" + } + ], + "color": "#24716E", "created_at": "2023-03-01 14:27:36", - "enabled": true, - "id": "string", - "inflection_column": "camelize", - "inflection_table": "camelize", + "deleted": true, + "description": "This is my base description", + "id": "p_124hhlkbeasewh", "is_meta": true, - "order": 1, - "base_id": "string", - "type": "mysql2", + "meta": {}, + "order": 0, + "prefix": "nc_vm5q__", + "status": "string", + "title": "my-base", "updated_at": "2023-03-01 14:27:36" } ], - "color": "#24716E", - "created_at": "2023-03-01 14:27:36", - "deleted": true, - "description": "This is my base description", - "id": "p_124hhlkbeasewh", - "is_meta": true, - "meta": {}, - "order": 0, - "prefix": "nc_vm5q__", - "status": "string", - "title": "my-base", - "updated_at": "2023-03-01 14:27:36" + "pageInfo": { + "isFirstPage": true, + "isLastPage": true, + "page": 1, + "pageSize": 10, + "totalRows": 1 + } } - ], - "pageInfo": { - "isFirstPage": true, - "isLastPage": true, - "page": 1, - "pageSize": 10, - "totalRows": 1 } } } } - } - } - }, - "BaseList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BaseList" - }, - "examples": { - "example-1": { - "value": { - "list": [ - { - "id": "ds_krsappzu9f8vmo", - "base_id": "p_01clqvzik3izk6", - "alias": null, - "config": "", - "meta": null, - "is_meta": 1, - "type": "mysql2", - "inflection_column": "camelize", - "inflection_table": "camelize", - "created_at": "2023-03-01 16:31:49", - "updated_at": "2023-03-02 11:28:17", - "enabled": 1, - "order": 1 - }, - { - "id": "ds_btbdt19zde0gj9", - "base_id": "p_01clqvzik3izk6", - "alias": "sakila", - "config": "", - "meta": null, - "is_meta": null, - "type": "mysql2", - "inflection_column": "camelize", - "inflection_table": "camelize", - "created_at": "2023-03-02 11:28:17", - "updated_at": "2023-03-02 11:28:17", - "enabled": 1, - "order": 2 + }, + "BaseList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BaseList" + }, + "examples": { + "example-1": { + "value": { + "list": [ + { + "id": "ds_krsappzu9f8vmo", + "base_id": "p_01clqvzik3izk6", + "alias": null, + "config": "", + "meta": null, + "is_meta": 1, + "type": "mysql2", + "inflection_column": "camelize", + "inflection_table": "camelize", + "created_at": "2023-03-01 16:31:49", + "updated_at": "2023-03-02 11:28:17", + "enabled": 1, + "order": 1 + }, + { + "id": "ds_btbdt19zde0gj9", + "base_id": "p_01clqvzik3izk6", + "alias": "sakila", + "config": "", + "meta": null, + "is_meta": null, + "type": "mysql2", + "inflection_column": "camelize", + "inflection_table": "camelize", + "created_at": "2023-03-02 11:28:17", + "updated_at": "2023-03-02 11:28:17", + "enabled": 1, + "order": 2 + } + ], + "pageInfo": { + "totalRows": 2, + "page": 1, + "pageSize": 2, + "isFirstPage": true, + "isLastPage": true + } } - ], - "pageInfo": { - "totalRows": 2, - "page": 1, - "pageSize": 2, - "isFirstPage": true, - "isLastPage": true } } } } - } - } - }, - "TableList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TableList" - }, - "examples": { - "Example 1": { - "value": { - "list": [ - { - "id": "md_5hua2iqloqirhd", - "source_id": "ds_jxuewivwbxeum2", - "base_id": "p_tbhl1hnycvhe5l", - "table_name": "nc_b84e___Sheet-1", - "title": "Sheet-1", - "type": "table", - "meta": null, - "schema": null, - "enabled": true, - "mm": false, - "tags": null, - "pinned": null, - "deleted": null, - "order": 1, - "created_at": "2023-03-11T09:11:45.907Z", - "updated_at": "2023-03-11T09:11:45.907Z" + }, + "TableList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TableList" + }, + "examples": { + "Example 1": { + "value": { + "list": [ + { + "id": "md_5hua2iqloqirhd", + "source_id": "ds_jxuewivwbxeum2", + "base_id": "p_tbhl1hnycvhe5l", + "table_name": "nc_b84e___Sheet-1", + "title": "Sheet-1", + "type": "table", + "meta": null, + "schema": null, + "enabled": true, + "mm": false, + "tags": null, + "pinned": null, + "deleted": null, + "order": 1, + "created_at": "2023-03-11T09:11:45.907Z", + "updated_at": "2023-03-11T09:11:45.907Z" + } + ], + "pageInfo": { + "isFirstPage": true, + "isLastPage": true, + "page": 1, + "pageSize": 10, + "totalRows": 1 + } } - ], - "pageInfo": { - "isFirstPage": true, - "isLastPage": true, - "page": 1, - "pageSize": 10, - "totalRows": 1 } } } } - } - } - }, - "ColumnList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ColumnList" + }, + "ColumnList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ColumnList" + } + } } - } - } - }, - "FilterList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FilterList" + }, + "FilterList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FilterList" + } + } } - } - } - }, - "SortList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SortList" - }, - "examples": {} - } - } - }, - "ViewList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ViewList" - }, - "examples": { - "Example 1": { - "value": { - "list": [ - { - "alias": "string", - "column": [ + }, + "SortList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SortList" + }, + "examples": {} + } + } + }, + "ViewList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ViewList" + }, + "examples": { + "Example 1": { + "value": { + "list": [ { "alias": "string", - "auto_increment": true, - "auto_update_timestamp": true, - "source_id": "string", - "character_maximum_length": "string", - "character_set_name": "string", - "colOptions": { - "deleted": "string", - "dr": "string", - "fk_child_column_id": "string", - "fk_column_id": "string", - "fk_index_name": "string", - "fk_mm_child_column_id": "string", - "fk_mm_model_id": "string", - "fk_mm_parent_column_id": "string", - "fk_parent_column_id": "string", - "id": "string", - "order": "string", - "type": "string", - "ur": "string", - "virtual": true - }, - "column_comment": "string", - "column_default": "string", - "column_ordinal_position": "string", - "column_type": "string", - "data_type": "string", - "data_type_x": "string", - "data_type_x_precision": "string", - "data_type_x_scale": "string", + "column": [ + { + "alias": "string", + "auto_increment": true, + "auto_update_timestamp": true, + "source_id": "string", + "character_maximum_length": "string", + "character_set_name": "string", + "colOptions": { + "deleted": "string", + "dr": "string", + "fk_child_column_id": "string", + "fk_column_id": "string", + "fk_index_name": "string", + "fk_mm_child_column_id": "string", + "fk_mm_model_id": "string", + "fk_mm_parent_column_id": "string", + "fk_parent_column_id": "string", + "id": "string", + "order": "string", + "type": "string", + "ur": "string", + "virtual": true + }, + "column_comment": "string", + "column_default": "string", + "column_ordinal_position": "string", + "column_type": "string", + "data_type": "string", + "data_type_x": "string", + "data_type_x_precision": "string", + "data_type_x_scale": "string", + "deleted": true, + "fk_model_id": "string", + "id": "string", + "numeric_precision": "string", + "numeric_scale": "string", + "order": 0, + "primary_key": true, + "primary_value": true, + "rqd": "string", + "title": "string", + "ui_data_type": "string", + "un": "string", + "unique": true, + "visible": true + } + ], + "columnByIds": {}, "deleted": true, - "fk_model_id": "string", + "enabled": true, + "fk_base_id": "string", + "fk_project_id": "string", "id": "string", - "numeric_precision": "string", - "numeric_scale": "string", "order": 0, - "primary_key": true, - "primary_value": true, - "rqd": "string", + "parent_id": "string", + "pinned": true, + "show_as": "string", + "tags": "string", "title": "string", - "ui_data_type": "string", - "un": "string", - "unique": true, - "visible": true + "type": "string" } ], - "columnByIds": {}, - "deleted": true, - "enabled": true, - "fk_base_id": "string", - "fk_project_id": "string", - "id": "string", - "order": 0, - "parent_id": "string", - "pinned": true, - "show_as": "string", - "tags": "string", - "title": "string", - "type": "string" + "pageInfo": { + "isFirstPage": true, + "isLastPage": true, + "page": 1, + "pageSize": 10, + "totalRows": 1 + } } - ], - "pageInfo": { - "isFirstPage": true, - "isLastPage": true, - "page": 1, - "pageSize": 10, - "totalRows": 1 } } } } - } - } - }, - "SharedViewList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/SharedViewList" - }, - "examples": { - "Example 1": { - "value": { - "list": [ - { - "source_id": "ds_g4ccx6e77h1dmi", - "created_at": "2023-03-02 17:46:31", - "fk_model_id": "md_mhs9z4r2ak98x0", - "id": "vw_lg052cnc1c26kf", - "is_default": 1, - "lock_type": "collaborative", - "meta": {}, - "order": 1, - "password": null, - "base_id": "p_xm3thidrblw4n7", - "show": 1, - "show_system_fields": null, - "title": "Sheet-1", - "type": 3, - "updated_at": "2023-03-02 17:46:31", - "uuid": null, - "view": { - "source_id": "ds_g4ccx6e77h1dmi", - "created_at": "2023-03-02 17:46:31", - "fk_view_id": "vw_lg052cnc1c26kf", - "meta": null, - "base_id": "p_xm3thidrblw4n7", - "row_height": null, - "updated_at": "2023-03-02 17:46:31", - "uuid": null + }, + "SharedViewList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SharedViewList" + }, + "examples": { + "Example 1": { + "value": { + "list": [ + { + "source_id": "ds_g4ccx6e77h1dmi", + "created_at": "2023-03-02 17:46:31", + "fk_model_id": "md_mhs9z4r2ak98x0", + "id": "vw_lg052cnc1c26kf", + "is_default": 1, + "lock_type": "collaborative", + "meta": {}, + "order": 1, + "password": null, + "base_id": "p_xm3thidrblw4n7", + "show": 1, + "show_system_fields": null, + "title": "Sheet-1", + "type": 3, + "updated_at": "2023-03-02 17:46:31", + "uuid": null, + "view": { + "source_id": "ds_g4ccx6e77h1dmi", + "created_at": "2023-03-02 17:46:31", + "fk_view_id": "vw_lg052cnc1c26kf", + "meta": null, + "base_id": "p_xm3thidrblw4n7", + "row_height": null, + "updated_at": "2023-03-02 17:46:31", + "uuid": null + } + } + ], + "pageInfo": { + "isFirstPage": true, + "isLastPage": true, + "page": 1, + "pageSize": 10, + "totalRows": 1 } } - ], - "pageInfo": { - "isFirstPage": true, - "isLastPage": true, - "page": 1, - "pageSize": 10, - "totalRows": 1 } } } } - } - } - }, - "HookList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/HookList" + }, + "HookList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HookList" + } + } } - } - } - }, - "UserList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserList" - }, - "examples": { - "Example 1": { - "value": { - "list": [ - { - "email": "user@example.com", - "email_verified": true, - "firstname": "Alice", - "id": "us_8kugj628ebjngs", - "lastname": "Smith", - "roles": "org-level-viewer" + }, + "UserList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserList" + }, + "examples": { + "Example 1": { + "value": { + "list": [ + { + "email": "user@example.com", + "email_verified": true, + "firstname": "Alice", + "id": "us_8kugj628ebjngs", + "lastname": "Smith", + "roles": "org-level-viewer" + } + ], + "pageInfo": { + "isFirstPage": true, + "isLastPage": true, + "page": 1, + "pageSize": 10, + "totalRows": 1 + } } - ], - "pageInfo": { - "isFirstPage": true, - "isLastPage": true, - "page": 1, - "pageSize": 10, - "totalRows": 1 } } } } - } - } - }, - "APITokenList": { - "description": "Example response", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiTokenList" - }, - "examples": {} - } - }, - "type": "object", - "properties": { - "list": { - "type": "array", - "x-stoplight": { - "id": "uukp6v55zfp7i" - }, - "items": { - "$ref": "#/components/schemas/ApiToken", - "x-stoplight": { - "id": "9zqpoqfkdxy0y" - } - } }, - "pageInfo": { - "$ref": "#/components/schemas/Paginated", - "x-stoplight": { - "id": "6unr17jyisial" - } - } - } - }, - "BadRequest": { - "description": "BadReqeust", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "msg": { - "type": "string", + "APITokenList": { + "description": "Example response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiTokenList" + }, + "examples": {} + } + }, + "type": "object", + "properties": { + "list": { + "type": "array", + "x-stoplight": { + "id": "uukp6v55zfp7i" + }, + "items": { + "$ref": "#/components/schemas/ApiToken", "x-stoplight": { - "id": "p9mk4oi0hbihm" - }, - "example": "BadRequest [Error]: " + "id": "9zqpoqfkdxy0y" + } } }, - "required": [ - "msg" - ] - }, - "examples": { - "Example 1": { - "value": { - "msg": "BadRequest [Error]: " + "pageInfo": { + "$ref": "#/components/schemas/Paginated", + "x-stoplight": { + "id": "6unr17jyisial" } } } + }, + "BadRequest": { + "description": "BadReqeust", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "msg": { + "type": "string", + "x-stoplight": { + "id": "p9mk4oi0hbihm" + }, + "example": "BadRequest [Error]: " + } + }, + "required": [ + "msg" + ] + }, + "examples": { + "Example 1": { + "value": { + "msg": "BadRequest [Error]: " + } + } + } + } + }, + "headers": {} } }, - "headers": {} - } - }, - "securitySchemes": { - "xc-auth": { - "name": "Auth Token ", - "type": "apiKey", - "in": "header", - "description": "Auth Token is a JWT Token generated based on the logged-in user. By default, the token is only valid for 10 hours. However, you can change the value by defining it using environment variable `NC_JWT_EXPIRES_IN`." - }, - "xc-shared-base-id": { - "name": "Shared Base ID", - "type": "apiKey", - "in": "header", - "description": "Shared base uuid" - }, - "xc-shared-erd-id": { - "name": "Shared ERD ID", - "type": "apiKey", - "in": "header", - "description": "Shared ERD uuid" - } - }, - "parameters": { - "xc-auth": { - "name": "xc-auth", - "in": "header", - "required": false, - "schema": { - "type": "string" + "securitySchemes": { + "xc-auth": { + "name": "Auth Token ", + "type": "apiKey", + "in": "header", + "description": "Auth Token is a JWT Token generated based on the logged-in user. By default, the token is only valid for 10 hours. However, you can change the value by defining it using environment variable `NC_JWT_EXPIRES_IN`." + }, + "xc-shared-base-id": { + "name": "Shared Base ID", + "type": "apiKey", + "in": "header", + "description": "Shared base uuid" + }, + "xc-shared-erd-id": { + "name": "Shared ERD ID", + "type": "apiKey", + "in": "header", + "description": "Shared ERD uuid" + } }, - "description": "Auth Token is a JWT Token generated based on the logged-in user. By default, the token is only valid for 10 hours. However, you can change the value by defining it using environment variable NC_JWT_EXPIRES_IN." + "parameters": { + "xc-auth": { + "name": "xc-auth", + "in": "header", + "required": false, + "schema": { + "type": "string" + }, + "description": "Auth Token is a JWT Token generated based on the logged-in user. By default, the token is only valid for 10 hours. However, you can change the value by defining it using environment variable NC_JWT_EXPIRES_IN." + } + } } } - } -} diff --git a/packages/nocodb/src/services/view-columns.service.ts b/packages/nocodb/src/services/view-columns.service.ts index 625654d8f6..7a44fac319 100644 --- a/packages/nocodb/src/services/view-columns.service.ts +++ b/packages/nocodb/src/services/view-columns.service.ts @@ -1,5 +1,5 @@ import { Injectable } from '@nestjs/common'; -import { AppEvents, ViewTypes } from 'nocodb-sdk'; +import { APIContext, AppEvents, ViewTypes } from 'nocodb-sdk'; import GridViewColumn from '../models/GridViewColumn'; import GalleryViewColumn from '../models/GalleryViewColumn'; import KanbanViewColumn from '../models/KanbanViewColumn'; @@ -74,10 +74,16 @@ export class ViewColumnsService { async columnsUpdate(param: { viewId: string; - columns: ViewColumnReqType[] | Record; + columns: + | ViewColumnReqType[] + | Record>; req: any; }) { - const { viewId, columns } = param; + const { viewId } = param; + + const columns = Array.isArray(param.columns) + ? param.columns + : param.columns[APIContext.VIEW_COLUMNS]; const view = await View.get(viewId); @@ -120,7 +126,7 @@ export class ViewColumnsService { ), ); } - break + break; case ViewTypes.GALLERY: if (existingCol) { updateOrInsertOptions.push( diff --git a/packages/nocodb/tests/unit/factory/viewColumns.ts b/packages/nocodb/tests/unit/factory/viewColumns.ts index db9ed97277..444963cd87 100644 --- a/packages/nocodb/tests/unit/factory/viewColumns.ts +++ b/packages/nocodb/tests/unit/factory/viewColumns.ts @@ -1,5 +1,6 @@ import request from 'supertest'; import type View from '../../../src/models/View'; +import { APIContext } from 'nocodb-sdk' const updateViewColumns = async ( context, @@ -23,7 +24,7 @@ const updateViewColumns = async ( await request(context.app) .patch(`/api/v3/meta/views/${view.id}/columns`) .set('xc-auth', context.token) - .send(fields) + .send({ [APIContext.VIEW_COLUMNS]: fields }) .expect(200); }; diff --git a/packages/nocodb/tests/unit/rest/tests/viewRow.test.ts b/packages/nocodb/tests/unit/rest/tests/viewRow.test.ts index 7d2da08c5a..67f0fe3a41 100644 --- a/packages/nocodb/tests/unit/rest/tests/viewRow.test.ts +++ b/packages/nocodb/tests/unit/rest/tests/viewRow.test.ts @@ -2,7 +2,7 @@ import 'mocha'; // @ts-ignore import assert from 'assert'; import request from 'supertest'; -import { UITypes, ViewTypes } from 'nocodb-sdk'; +import { APIContext, UITypes, ViewTypes } from 'nocodb-sdk'; import { expect } from 'chai'; import init from '../../init'; import { createProject, createSakilaProject } from '../../factory/base'; @@ -1766,14 +1766,20 @@ function viewRowTests() { } // get view columns and verify hidden columns - const viewColumnsViaApi: any = await getViewColumns(context, { + const viewColApiRes: any = await getViewColumns(context, { view, }); - for (const colId of Object.keys(viewColumnsViaApi)) { + for (const colId of Object.keys(viewColApiRes[APIContext.VIEW_COLUMNS])) { const column = columns.find((c) => c.id === colId); - if (columnsToHide.includes(column.title)) - expect(!!viewColumnsViaApi[colId]).to.have.property('show', false); + if (columnsToHide.includes(column.title)) { + expect(viewColApiRes[APIContext.VIEW_COLUMNS][colId]).to.have.property( + 'show', + ); + expect(!!viewColApiRes[APIContext.VIEW_COLUMNS][colId].show).to.be.eq( + false, + ); + } } }); }