π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
snake case properties
Fendy Heryantoa5918a05c286
diff --git a/packages/nocodb/src/helpers/ncErrorV3.ts b/packages/nocodb/src/helpers/ncErrorV3.tsindex b2f0dfd536..cfe4191cfd 100644--- a/packages/nocodb/src/helpers/ncErrorV3.ts+++ b/packages/nocodb/src/helpers/ncErrorV3.ts@@ -51,6 +51,7 @@ export class NcErrorV3 extends NcErrorV1 {errors: ErrorObject[];humanReadableError: boolean;}): never {+ console.log(JSON.stringify( param.errors))throw new AjvErrorV3(param);}diff --git a/packages/nocodb/src/schema/swagger-v3-validation-patch.json b/packages/nocodb/src/schema/swagger-v3-validation-patch.jsonindex db7c7960ef..f0cb92d4ed 100644--- a/packages/nocodb/src/schema/swagger-v3-validation-patch.json+++ b/packages/nocodb/src/schema/swagger-v3-validation-patch.json@@ -26,20 +26,20 @@"type": {"type": "string","enum": [- "GRID",- "GALLERY",- "KANBAN",- "CALENDAR",- "FORM"+ "grid",+ "gallery",+ "kanban",+ "calendar",+ "form"],"description": "Type of the view."},- "orderedFields": {+ "ordered_fields": {"type": "array","items": {"type": "object","properties": {- "fieldId": {+ "field_id": {"type": "string"},"show": {@@ -50,7 +50,7 @@}},"required": [- "fieldId"+ "field_id"]}}@@ -72,7 +72,6 @@"properties": {"id": {"type": "string",- "format": "uuid","description": "Unique identifier for the view."}}diff --git a/packages/nocodb/src/schema/swagger-v3.json b/packages/nocodb/src/schema/swagger-v3.jsonindex aa14629172..a330fca36b 100644--- a/packages/nocodb/src/schema/swagger-v3.json+++ b/packages/nocodb/src/schema/swagger-v3.json@@ -2290,12 +2290,12 @@"list": [{"id": "so3o7c6po0tktghc",- "fieldId": "c580jyan91qwrbx",+ "field_id": "c580jyan91qwrbx","order": "asc"},{"id": "so1n4x4w7dou8p0v",- "fieldId": "caymvuj3az60wyk",+ "field_id": "caymvuj3az60wyk","order": "desc"}]@@ -2350,7 +2350,7 @@"examples": {"Example 1": {"value": {- "fieldId": "c580jyan91qwrbx",+ "field_id": "c580jyan91qwrbx","order": "asc"}}@@ -5131,7 +5131,7 @@"description": "Unique identifier for the sort.","readOnly": true},- "fieldId": {+ "field_id": {"type": "string","format": "uuid","description": "Identifier for the field being sorted."@@ -5147,14 +5147,14 @@},"required": ["id",- "fieldId",+ "field_id","direction"]},"SortCreate": {"type": "object","properties": {- "fieldId": {+ "field_id": {"type": "string","description": "Identifier for the field being sorted."},@@ -5168,7 +5168,7 @@}},"required": [- "fieldId"+ "field_id"]},"SortUpdate": {@@ -5178,7 +5178,7 @@"type": "string","description": "Unique identifier for the sort."},- "fieldId": {+ "field_id": {"type": "string","format": "uuid","description": "Identifier for the field being sorted."@@ -5211,11 +5211,11 @@"view_type": {"type": "string","enum": [- "GRID",- "GALLERY",- "KANBAN",- "CALENDAR",- "FORM"+ "grid",+ "gallery",+ "kanban",+ "calendar",+ "form"],"description": "Type of the view."}@@ -5267,7 +5267,7 @@"ViewColumnOption": {"type": "object","properties": {- "fieldsById": {+ "fields_by_id": {"type": "object","additionalProperties": {"type": "object",@@ -5281,13 +5281,13 @@"required": {"type": "boolean"},- "allowScannerInput": {+ "allow_scanner_input": {"type": "boolean"},- "isList": {+ "is_list": {"type": "boolean"},- "isLimitOption": {+ "is_limit_option": {"type": "boolean"},"validators": {@@ -5327,7 +5327,7 @@"type": {"type": "string","enum": [- "GRID"+ "grid"]},"options": {@@ -5341,7 +5341,7 @@"type": {"type": "string","enum": [- "KANBAN"+ "kanban"]},"options": {@@ -5355,7 +5355,7 @@"type": {"type": "string","enum": [- "CALENDAR"+ "calendar"]},"options": {@@ -5369,7 +5369,7 @@"type": {"type": "string","enum": [- "GALLERY"+ "gallery"]},"options": {@@ -5383,7 +5383,7 @@"type": {"type": "string","enum": [- "FORM"+ "form"]},"options": {@@ -5409,20 +5409,20 @@"type": {"type": "string","enum": [- "GRID",- "GALLERY",- "KANBAN",- "CALENDAR",- "FORM"+ "grid",+ "gallery",+ "kanban",+ "calendar",+ "form"],"description": "Type of the view."},- "orderedFields": {+ "ordered_fields": {"type": "array","items": {"type": "object","properties": {- "fieldId": {+ "field_id": {"type": "string"},"show": {@@ -5433,7 +5433,7 @@}},"required": [- "fieldId"+ "field_id"]}}@@ -5484,11 +5484,11 @@"type": {"type": "string","enum": [- "GRID",- "GALLERY",- "KANBAN",- "CALENDAR",- "FORM"+ "grid",+ "gallery",+ "kanban",+ "calendar",+ "form"],"description": "Type of the view."},@@ -5545,7 +5545,7 @@"items": {"type": "object","properties": {- "fieldId": {+ "field_id": {"type": "string"},"direction": {@@ -5557,7 +5557,7 @@}},"required": [- "fieldId"+ "field_id"]}}@@ -5566,18 +5566,18 @@"ViewOptionsKanban": {"type": "object","properties": {- "stackBy": {+ "stack_by": {"type": "object","properties": {- "fieldId": {+ "field_id": {"type": "string"}}},- "coverFieldId": {+ "cover_field_id": {"type": "string"},- "stackOrder": {+ "stack_order": {"type": "array","items": {"type": "string"@@ -5585,38 +5585,38 @@}},"required": [- "stackBy"+ "stack_by"]},"ViewOptionsCalendar": {"type": "object","properties": {- "dateRanges": {+ "date_ranges": {"type": "array","items": {"type": "object","properties": {- "startDateFieldId": {+ "start_date_field_id": {"type": "string"},- "endDateFieldId": {+ "end_date_field_id": {"type": "string"}},"required": [- "startDateFieldId"+ "start_date_field_id"]}}},"required": [- "dateRanges"+ "date_ranges"]},"ViewOptionsGallery": {"type": "object","properties": {- "coverFieldId": {+ "cover_field_id": {"type": "string"}}@@ -5624,15 +5624,15 @@"ViewOptionsForm": {"type": "object","properties": {- "formTitle": {+ "form_title": {"type": "string","description": "Heading for the form."},- "formDescription": {+ "form_description": {"type": "string","description": "Subheading for the form."},- "thankYouMessage": {+ "thank_you_message": {"type": "string","description": "Success message shown after form submission."},@@ -5644,11 +5644,11 @@"type": "boolean","description": "Whether to send a response email."},- "submitAnotherForm": {+ "submit_another_form": {"type": "boolean","description": "Whether to show another form after submission."},- "showBlankForm": {+ "show_blank_form": {"type": "boolean","description": "Whether to show a blank form after submission."},@@ -5675,7 +5675,7 @@"description": "Background color for the form.","pattern": "^#[0-9A-Fa-f]{6}$"},- "redirectOnSubmit": {+ "redirect_on_submit": {"type": "object","properties": {"url": {diff --git a/packages/nocodb/src/services/v3/sorts-v3.service.ts b/packages/nocodb/src/services/v3/sorts-v3.service.tsindex 4346f8f462..df631b7349 100644--- a/packages/nocodb/src/services/v3/sorts-v3.service.ts+++ b/packages/nocodb/src/services/v3/sorts-v3.service.ts@@ -22,9 +22,9 @@ export class SortsV3Service {SortCreateV3Type | SortUpdateV3Type,SortType>({- allowed: ['id', 'fieldId', 'direction'],+ allowed: ['id', 'field_id', 'direction'],mappings: {- fieldId: 'fk_column_id',+ field_id: 'fk_column_id',},});@@ -69,7 +69,7 @@ export class SortsV3Service {sort = await Sort.get(context, param.sortId);} else {const sorts = await Sort.list(context, { viewId: param.viewId });- sort = sorts.find((s) => s.fk_column_id === param.sort.fieldId);+ sort = sorts.find((s) => s.fk_column_id === param.sort.field_id);}if (!sort || sort.fk_view_id !== param.viewId) {@@ -99,7 +99,7 @@ export class SortsV3Service {// check for existing filter with same fieldconst sorts = await Sort.list(context, { viewId: param.viewId }, ncMeta);const existingSort = sorts.find(- (s) => s.fk_column_id === param.sort.fieldId,+ (s) => s.fk_column_id === param.sort.field_id,);if (existingSort) {NcError.badRequest('Sort already exists for this field');@@ -108,7 +108,7 @@ export class SortsV3Service {// check column existsconst column = await Column.get(context,- { colId: param.sort.fieldId },+ { colId: param.sort.field_id },ncMeta,);diff --git a/packages/nocodb/src/services/v3/views-v3.service.ts b/packages/nocodb/src/services/v3/views-v3.service.tsindex 9d5548b3bf..807dc9973e 100644--- a/packages/nocodb/src/services/v3/views-v3.service.ts+++ b/packages/nocodb/src/services/v3/views-v3.service.ts@@ -1,5 +1,10 @@import { Injectable, Logger } from '@nestjs/common';-import { ncIsNullOrUndefined, parseProp, ViewTypes } from 'nocodb-sdk';+import {+ ncIsNullOrUndefined,+ parseProp,+ viewTypeAlias,+ ViewTypes,+} from 'nocodb-sdk';import { GridsService } from '../grids.service';import { CalendarsService } from '../calendars.service';import { KanbansService } from '../kanbans.service';@@ -25,18 +30,13 @@ import { SortsV3Service } from '~/services/v3/sorts-v3.service';import { validatePayload } from '~/helpers';import { FormColumnsService } from '~/services/form-columns.service';-// cannot use viewTypeAlias due to uppercaseconst viewTypeMap = {- GRID: ViewTypes.GRID,- GALLERY: ViewTypes.GALLERY,- KANBAN: ViewTypes.KANBAN,- CALENDAR: ViewTypes.CALENDAR,- FORM: ViewTypes.FORM,- [ViewTypes.GRID]: 'GRID',- [ViewTypes.GALLERY]: 'GALLERY',- [ViewTypes.KANBAN]: 'KANBAN',- [ViewTypes.CALENDAR]: 'CALENDAR',- [ViewTypes.FORM]: 'FORM',+ grid: ViewTypes.GRID,+ gallery: ViewTypes.GALLERY,+ kanban: ViewTypes.KANBAN,+ calendar: ViewTypes.CALENDAR,+ form: ViewTypes.FORM,+ ...viewTypeAlias,};@Injectable()@@ -171,13 +171,13 @@ export class ViewsV3Service {'fk_grp_col_id',],mappings: {- heading: 'formTitle',- subheading: 'formDescription',- success_msg: 'thankYouMessage',+ heading: 'form_title',+ subheading: 'form_description',+ success_msg: 'thank_you_message',redirect_after_secs: 'form_redirect_after_secs',email: 'form_send_response_email',- submit_another_form: 'submitAnotherForm',- show_blank_form: 'showBlankForm',+ submit_another_form: 'submit_another_form',+ show_blank_form: 'show_blank_form',hide_banner: 'form_hide_banner',hide_branding: 'form_hide_branding',banner_image_url: 'form_banner_image_url',@@ -197,18 +197,18 @@ export class ViewsV3Service {const formattedData = viewData;if (formattedData?.calendar_range?.length) {- formattedData.dateRanges = formattedData.calendar_range.map(+ formattedData.date_ranges = formattedData.calendar_range.map((range) => ({- startDateFieldId: range.fk_from_column_id ?? undefined,- endDateFieldId: range.fk_to_column_id ?? undefined,+ start_date_field_id: range.fk_from_column_id ?? undefined,+ end_date_field_id: range.fk_to_column_id ?? undefined,}),);formattedData.calendar_range = undefined;}if (formattedData.kanban_stack_by_field_id) {- formattedData.stackBy = {- fieldId: formattedData.kanban_stack_by_field_id,- stackOrder: (+ formattedData.stack_by = {+ field_id: formattedData.kanban_stack_by_field_id,+ stack_order: (parseProp(formattedData.meta ?? {})?.[formattedData.kanban_stack_by_field_id] ?? []@@ -227,7 +227,7 @@ export class ViewsV3Service {formattedData.meta = undefined;if (formattedData.redirect_url) {- formattedData.redirectOnSubmit = {+ formattedData.redirect_on_submit = {url: formattedData.redirect_url,};formattedData.redirect_url = undefined;@@ -268,38 +268,38 @@ export class ViewsV3Service {this.v3Tov2ViewBuilders.options = builderGenerator<any, any>({allowed: [// calendar- 'dateRanges',+ 'date_ranges',// kanban- 'stackBy',+ 'stack_by',// gallery- 'coverFieldId',+ 'cover_field_id',// form specific for now- 'fieldsById',+ 'fields_by_id',// form- 'formTitle',- 'formDescription',- 'submitButtonLabel',- 'thankYouMessage',- 'redirectOnSubmit',- 'submitAnotherForm',- 'showBlankForm',+ 'form_title',+ 'form_description',+ 'submit_button_label',+ 'thank_you_message',+ 'redirect_on_submit',+ 'submit_another_form',+ 'show_blank_form',],mappings: {// calendar- dateRanges: 'calendar_range',+ date_ranges: 'calendar_range',// gallery- coverFieldId: 'fk_cover_image_col_id',+ cover_field_id: 'fk_cover_image_col_id',// form- formTitle: 'heading',- formDescription: 'subheading',- thankYouMessage: 'success_msg',- submitAnotherForm: 'submit_another_form',- showBlankForm: 'show_blank_form',+ form_title: 'heading',+ form_description: 'subheading',+ thank_you_message: 'success_msg',+ submit_another_form: 'submit_another_form',+ show_blank_form: 'show_blank_form',},transformFn: (options) => {const result = {@@ -308,14 +308,14 @@ export class ViewsV3Service {...(options.calendar_range?.length ?? 0 > 0? {calendar_range: options.calendar_range.map((range) => ({- fk_from_column_id: range.startDateFieldId,- fk_to_column_id: range.endDateFieldId,+ fk_from_column_id: range.start_date_field_id,+ fk_to_column_id: range.end_date_field_id,})),}: {}),// kanban- ...(options.stackBy?.fieldId- ? { fk_grp_col_id: options.stackBy.fieldId }+ ...(options.stack_by?.field_id+ ? { fk_grp_col_id: options.stack_by.field_id }: {}),};@@ -328,25 +328,25 @@ export class ViewsV3Service {'alias','description','required',- 'allowScannerInput',- 'isList',- 'isLimitOption',+ 'allow_scanner_input',+ 'is_list',+ 'is_limit_option','validators',],mappings: {alias: 'label',- allowScannerInput: 'enable_scanner',+ allow_scanner_input: 'enable_scanner',},transformFn: (field) => {- if (!ncIsNullOrUndefined(field.isList)) {+ if (!ncIsNullOrUndefined(field.is_list)) {field.meta = field.meta ?? {};- field.meta.isList = field.isList;- field.isList = undefined;+ field.meta.is_list = field.is_list;+ field.is_list = undefined;}- if (!ncIsNullOrUndefined(field.isLimitOption)) {+ if (!ncIsNullOrUndefined(field.is_limit_option)) {field.meta = field.meta ?? {};- field.meta.isLimitOption = field.isLimitOption;- field.isLimitOption = undefined;+ field.meta.is_limit_option = field.is_limit_option;+ field.is_limit_option = undefined;}if (!ncIsNullOrUndefined(field.validators)) {field.meta = field.meta ?? {};@@ -361,12 +361,12 @@ export class ViewsV3Service {allowed: ['label', 'description', 'required', 'enable_scanner', 'meta'],mappings: {label: 'alias',- enable_scanner: 'allowScannerInput',+ enable_scanner: 'allow_scanner_input',},transformFn: (field) => {if (!ncIsNullOrUndefined(field.meta)) {- field.isList = field.meta.isList;- field.isLimitOption = field.meta.isLimitOption;+ field.is_list = field.meta.is_list;+ field.is_limit_option = field.meta.is_limit_option;field.validators = field.meta.validators;delete field.meta;}@@ -439,7 +439,7 @@ export class ViewsV3Service {((c2 as GridViewColumn).group_by_order || Infinity),).map((c) => ({- fieldId: c.fk_column_id,+ field_id: c.fk_column_id,direction: (c as GridViewColumn).group_by_sort,}));if (group && group.length > 0) {@@ -459,7 +459,7 @@ export class ViewsV3Service {case ViewTypes.FORM:{formattedView.options = formattedView.options ?? {};- formattedView.options.fieldByIds = viewColumnList.reduce(+ formattedView.options.field_by_ids = viewColumnList.reduce((acc, cur) => {acc[cur.fk_column_id] = this.v2Tov3ViewBuilders.formFieldByIds()@@ -494,7 +494,9 @@ export class ViewsV3Service {);if (body.options) {const optionsSchemaName =- 'ViewOptions' + body.type[0] + body.type.substring(1).toLowerCase();+ 'ViewOptions' ++ body.type[0].toUpperCase() ++ body.type.substring(1).toLowerCase();validatePayload(`swagger-v3.json#/components/schemas/${optionsSchemaName}`,body.options,@@ -503,7 +505,7 @@ export class ViewsV3Service {);if (viewTypeMap[body.type] === ViewTypes.FORM &&- body.options.fieldsById+ body.options.fields_by_id) {validatePayload(`swagger-v3.json#/components/schemas/ViewColumnOption`,@@ -515,7 +517,7 @@ export class ViewsV3Service {}const viewTypeCode =- viewTypeMap[(body.type as any as string).toUpperCase()];+ viewTypeMap[(body.type as any as string).toLowerCase()];const { modelColumns } = await this.validateFieldIds(context,@@ -547,8 +549,8 @@ export class ViewsV3Service {req,tableId,modelColumns,- orderedFields: body.orderedFields,- fieldsById: body.options?.fieldsById,+ orderedFields: body.ordered_fields,+ fieldsById: body.options?.fields_by_id,},ncMeta,);@@ -595,7 +597,7 @@ export class ViewsV3Service {group_by_sort: group.direction,},gridViewColumnId: gridColumns.find(- (col) => col.fk_column_id === group.fieldId,+ (col) => col.fk_column_id === group.field_id,).id,req,},@@ -633,13 +635,13 @@ export class ViewsV3Service {context,{kanbanViewId: insertedV2View.id,- optionsOrder: requestBody.options.stackBy.stackOrder ?? [],+ optionsOrder: requestBody.options.stack_by.stack_order ?? [],req,},trxNcMeta,);- requestBody.options.stackBy = undefined;+ requestBody.options.stack_by = undefined;break;}@@ -726,40 +728,42 @@ export class ViewsV3Service {const { body, viewTypeCode, isCreate } = param;const fieldIdToVerify = [];- fieldIdToVerify.push(...Object.keys(body.options?.fieldsById ?? {}));+ fieldIdToVerify.push(...Object.keys(body.options?.fields_by_id ?? {}));if (![ViewTypes.FORM].includes(viewTypeCode) && body.sorts) {- fieldIdToVerify.push(...body.sorts.map((sort) => sort.fieldId));+ fieldIdToVerify.push(...body.sorts.map((sort) => sort.field_id));}if (isCreate && body.orderedFields) {- fieldIdToVerify.push(...body.orderedFields.map((field) => field.fieldId));+ fieldIdToVerify.push(+ ...body.orderedFields.map((field) => field.field_id),+ );}if (!isCreate && body.fields) {- fieldIdToVerify.push(...body.fields.map((field) => field.fieldId));+ fieldIdToVerify.push(...body.fields.map((field) => field.field_id));}if ([ViewTypes.GRID].includes(viewTypeCode) && body.options?.groups) {fieldIdToVerify.push(- ...body.options.groups.map((field) => field.fieldId),+ ...body.options.groups.map((field) => field.field_id),);}if ([ViewTypes.KANBAN].includes(viewTypeCode) &&- body.options?.stackBy?.fieldId+ body.options?.stack_by?.field_id) {- fieldIdToVerify.push(body.options?.stackBy?.fieldId);+ fieldIdToVerify.push(body.options?.stack_by?.field_id);}if ([ViewTypes.CALENDAR].includes(viewTypeCode) &&- body.options?.dateRanges+ body.options?.date_ranges) {fieldIdToVerify.push(- ...(body.options?.dateRanges?.reduce((acc, cur) => {- return [...acc, cur.startDateFieldId, cur.endDateFieldId];+ ...(body.options?.date_ranges?.reduce((acc, cur) => {+ return [...acc, cur.start_date_field_id, cur.end_date_field_id];}, []) ?? []),);}- if (body.options?.coverFieldId) {- fieldIdToVerify.push(body.options?.coverFieldId);+ if (body.options?.cover_field_id) {+ fieldIdToVerify.push(body.options?.cover_field_id);}// remove undefinedreturn fieldIdToVerify.filter((k) => k);@@ -800,8 +804,8 @@ export class ViewsV3Service {req: NcRequest;tableId: string;modelColumns?: { id: string; order: number }[];- orderedFields?: ViewCreateV3Type['orderedFields'];- fieldsById?: ViewColumnOptionV3Type['fieldsById'];+ orderedFields?: ViewCreateV3Type['ordered_fields'];+ fieldsById?: ViewColumnOptionV3Type['fields_by_id'];},ncMeta?: MetaService,) {@@ -828,7 +832,7 @@ export class ViewsV3Service {// we get the order by array indexconst orderedFieldMap = (param.orderedFields ?? []).reduce((acc, val, idx) => {- acc[val.fieldId] = { ...val, order: idx };+ acc[val.field_id] = { ...val, order: idx };return acc;},{},@@ -968,14 +972,16 @@ export class ViewsV3Service {if (body.options) {const viewTypeStr = viewTypeMap[existingView.type];const optionsSchemaName =- 'ViewOptions' + viewTypeStr[0] + viewTypeStr.substring(1).toLowerCase();+ 'ViewOptions' ++ viewTypeStr[0].toUpperCase() ++ viewTypeStr.substring(1).toLowerCase();validatePayload(`swagger-v3.json#/components/schemas/${optionsSchemaName}`,body.options,true,context,);- if (existingView.type === ViewTypes.FORM && body.options.fieldsById) {+ if (existingView.type === ViewTypes.FORM && body.options.fields_by_id) {validatePayload(`swagger-v3.json#/components/schemas/ViewColumnOption`,body.options,@@ -1010,8 +1016,10 @@ export class ViewsV3Service {...this.v3Tov2ViewBuilders.options().build(requestBody.options),};const updateViewColumns: Record<string, any> = {};- // fieldsById for update- for (const [colId, col] of Object.entries(body.options?.fieldsById ?? {})) {+ // fields_by_id for update+ for (const [colId, col] of Object.entries(+ body.options?.fields_by_id ?? {},+ )) {updateViewColumns[colId] = {...updateViewColumns[colId],...this.v3Tov2ViewBuilders.formFieldByIds().build(col),@@ -1073,7 +1081,7 @@ export class ViewsV3Service {group_by_sort: group.direction,},gridViewColumnId: gridColumns.find(- (col) => col.fk_column_id === group.fieldId,+ (col) => col.fk_column_id === group.field_id,).id,req,},diff --git a/packages/nocodb/src/utils/api-v3-data-transformation.builder.ts b/packages/nocodb/src/utils/api-v3-data-transformation.builder.tsindex ef4dbeb41f..cbe3723a3b 100644--- a/packages/nocodb/src/utils/api-v3-data-transformation.builder.ts+++ b/packages/nocodb/src/utils/api-v3-data-transformation.builder.ts@@ -802,7 +802,7 @@ export const viewColumnBuilder = builderGenerator<'required',],mappings: {- fk_column_id: 'fieldId',+ fk_column_id: 'field_id',},excludeNullProps: true,booleanProps: ['show', 'required'],diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.tsindex 4b12d6ff80..32910a2092 100644--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/error-handling/view.test.ts@@ -107,7 +107,7 @@ export default function () {name: 'MyView',sorts: [{- fieldId: (+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},@@ -122,10 +122,10 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'NOGRID',+ type: 'nogrid',sorts: [{- fieldId: (+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},@@ -141,10 +141,10 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',sorts: [{- fieldIds: (+ field_ids: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},@@ -160,10 +160,10 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',sorts: [{- fieldId: (+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},@@ -179,11 +179,11 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',options: {groups: [{- fieldIds: 'asdmalmkdm',+ field_ids: 'asdmalmkdm',},],},@@ -198,11 +198,11 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',options: {groups: [{- fieldId: 'NOT_EXISTS',+ field_id: 'NOT_EXISTS',},],},@@ -217,7 +217,7 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',});expect(response.status).to.eq(422);expect(response.body.error).to.eq('VIEW_NOT_FOUND');diff --git a/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts b/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.tsindex a1397958cd..9ea0bdf9ad 100644--- a/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts+++ b/packages/nocodb/tests/unit/rest/tests/metaApiV3/view.test.ts@@ -88,16 +88,16 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',sorts: [{- fieldId: (+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},],});- expect(response.body.type).to.eq('GRID');+ expect(response.body.type).to.eq('grid');const updateResponse = await request(context.app).patch(`${API_PREFIX}/views/${response.body.id}`)@@ -106,7 +106,7 @@ export default function () {name: 'MyView32',sorts: [{- fieldId: (+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},@@ -124,22 +124,22 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',options: {groups: [{- fieldId: titleColumn.id,+ field_id: titleColumn.id,direction: 'asc',},],},sorts: [{- fieldId: titleColumn.id,+ field_id: titleColumn.id,},],});- expect(response.body.type).to.eq('GRID');+ expect(response.body.type).to.eq('grid');expect(response.body.options.groups.length).to.greaterThan(0);const updateResponse = await request(context.app)@@ -163,14 +163,14 @@ export default function () {options: {groups: [{- fieldId: titleColumn.id,+ field_id: titleColumn.id,direction: 'asc',},],},sorts: [{- fieldId: titleColumn.id,+ field_id: titleColumn.id,},],});@@ -193,25 +193,25 @@ export default function () {url: `${API_PREFIX}/tables/${table.id}/views`,body: {name: 'MyView',- type: 'GRID',+ type: 'grid',options: {groups: [{- fieldId: titleColumn.id,+ field_id: titleColumn.id,direction: 'asc',},],},- orderedFields: [+ ordered_fields: [{- fieldId: singleSelectColumn.id,+ field_id: singleSelectColumn.id,},{- fieldId: dateTimeColumn.id,+ field_id: dateTimeColumn.id,show: false,},{- fieldId: titleColumn.id,+ field_id: titleColumn.id,},],},@@ -220,10 +220,10 @@ export default function () {.post(requestPayload.url).set('xc-token', context.xc_token).send(requestPayload.body);- expect(response.body.type).to.eq('GRID');- expect(response.body.fields[0].fieldId).to.eq(singleSelectColumn.id);- expect(response.body.fields[1].fieldId).to.eq(dateTimeColumn.id);- expect(response.body.fields[2].fieldId).to.eq(titleColumn.id);+ expect(response.body.type).to.eq('grid');+ expect(response.body.fields[0].field_id).to.eq(singleSelectColumn.id);+ expect(response.body.fields[1].field_id).to.eq(dateTimeColumn.id);+ expect(response.body.fields[2].field_id).to.eq(titleColumn.id);});it(`will create kanban view`, async () => {@@ -231,17 +231,17 @@ export default function () {url: `${API_PREFIX}/tables/${table.id}/views`,body: {name: 'MyView',- type: 'KANBAN',+ type: 'kanban',options: {- stackBy: {- fieldId: (await table.getColumns(ctx)).find(+ stack_by: {+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'SingleSelect',).id,},},sorts: [{- fieldId: (await table.getColumns(ctx)).find(+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title',).id,},@@ -252,10 +252,10 @@ export default function () {.post(requestPayload.url).set('xc-token', context.xc_token).send(requestPayload.body);- expect(response.body.type).to.eq('KANBAN');- expect(response.body.options.stackBy.stackOrder.length).to.greaterThan(- 0,- );+ expect(response.body.type).to.eq('kanban');+ expect(+ response.body.options.stack_by.stack_order.length,+ ).to.greaterThan(0);});it(`will create calendar view`, async () => {@@ -263,11 +263,11 @@ export default function () {url: `${API_PREFIX}/tables/${table.id}/views`,body: {name: 'MyView',- type: 'CALENDAR',+ type: 'calendar',options: {- dateRanges: [+ date_ranges: [{- startDateFieldId: (await table.getColumns(ctx)).find(+ start_date_field_id: (await table.getColumns(ctx)).find((col) => col.title === 'DateTime',).id,},@@ -275,7 +275,7 @@ export default function () {},sorts: [{- fieldId: (await table.getColumns(ctx)).find(+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title',).id,},@@ -286,7 +286,7 @@ export default function () {.post(requestPayload.url).set('xc-token', context.xc_token).send(requestPayload.body);- expect(response.body.type).to.eq('CALENDAR');+ expect(response.body.type).to.eq('calendar');});it(`will create gallery view`, async () => {@@ -294,15 +294,15 @@ export default function () {url: `${API_PREFIX}/tables/${table.id}/views`,body: {name: 'MyView',- type: 'GALLERY',+ type: 'gallery',options: {- coverFieldId: (await table.getColumns(ctx)).find(+ cover_field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Attachment',).id,},sorts: [{- fieldId: (await table.getColumns(ctx)).find(+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title',).id,},@@ -313,7 +313,7 @@ export default function () {.post(requestPayload.url).set('xc-token', context.xc_token).send(requestPayload.body);- expect(response.body.type).to.eq('GALLERY');+ expect(response.body.type).to.eq('gallery');});it(`will create form view`, async () => {@@ -322,12 +322,12 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'FORM',+ type: 'form',options: {- formTitle: 'MyForm',+ form_title: 'MyForm',},});- expect(response.body.type).to.eq('FORM');+ expect(response.body.type).to.eq('form');});it(`will create + update form view with fieldsById`, async () => {@@ -344,10 +344,10 @@ export default function () {url: `${API_PREFIX}/tables/${table.id}/views`,body: {name: 'MyView',- type: 'FORM',+ type: 'form',options: {- formTitle: 'MyForm',- fieldsById: {+ form_title: 'MyForm',+ fields_by_id: {[singleSelectColumn.id]: {alias: 'select',},@@ -374,9 +374,9 @@ export default function () {.set('xc-token', context.xc_token).send(requestPayload.body);- expect(response.body.type).to.eq('FORM');+ expect(response.body.type).to.eq('form');expect(- response.body.options.fieldByIds[titleColumn.id].validators.length,+ response.body.options.field_by_ids[titleColumn.id].validators.length,).to.greaterThan(0);const updateResponse = await request(context.app)@@ -384,7 +384,7 @@ export default function () {.set('xc-token', context.xc_token).send({options: {- fieldsById: {+ fields_by_id: {[singleSelectColumn.id]: {alias: 'select32',},@@ -393,7 +393,7 @@ export default function () {});expect(- updateResponse.body.options.fieldByIds[singleSelectColumn.id].alias,+ updateResponse.body.options.field_by_ids[singleSelectColumn.id].alias,).to.eq('select32');});});@@ -405,16 +405,16 @@ export default function () {.set('xc-token', context.xc_token).send({name: 'MyView',- type: 'GRID',+ type: 'grid',sorts: [{- fieldId: (+ field_id: (await table.getColumns(ctx)).find((col) => col.title === 'Title').id,},],});- expect(response.body.type).to.eq('GRID');+ expect(response.body.type).to.eq('grid');const deleteResponse = await request(context.app).delete(`${API_PREFIX}/views/${response.body.id}`)