Browse Source

fix: column api type corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5174/head
Pranav C 2 years ago
parent
commit
90fe5ef1fc
  1. 116
      packages/nocodb-sdk/src/lib/Api.ts
  2. 2
      packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts
  3. 13
      packages/nocodb/src/lib/meta/api/tableApis.ts
  4. 29
      scripts/sdk/swagger.json

116
packages/nocodb-sdk/src/lib/Api.ts

@ -176,7 +176,7 @@ export interface TableReqType {
deleted?: boolean;
order?: number;
mm?: boolean;
columns: ColumnType[];
columns: NormalColumnRequestType[];
meta?: any;
}
@ -244,17 +244,17 @@ export interface ColumnType {
base_id?: string;
fk_model_id?: string;
title?: string;
uidt: string;
uidt?: string;
dt?: string;
np?: string;
ns?: string;
clen?: string | number;
np?: string | number | null;
ns?: string | number | null;
clen?: string | number | null;
cop?: string;
pk?: boolean;
pv?: boolean;
rqd?: boolean;
rqd?: boolean | number | null;
column_name?: string;
un?: boolean;
un?: boolean | number | null;
ct?: string;
ai?: boolean;
unique?: boolean;
@ -359,6 +359,13 @@ export interface GridType {
row_height?: number;
}
export interface GridReqType {
title: string;
order?: number;
lock_type?: 'collaborative' | 'locked' | 'personal';
row_height?: number;
}
export interface GalleryType {
fk_view_id?: string;
title?: string;
@ -378,6 +385,19 @@ export interface GalleryType {
lock_type?: 'collaborative' | 'locked' | 'personal';
}
export interface GalleryReqType {
title: string;
next_enabled?: boolean;
prev_enabled?: boolean;
cover_image_idx?: number;
cover_image?: string;
restrict_types?: string;
restrict_size?: string;
restrict_number?: string;
fk_cover_image_col_id?: string;
lock_type?: 'collaborative' | 'locked' | 'personal';
}
export interface GalleryColumnType {
id?: string;
label?: string;
@ -441,6 +461,15 @@ export interface MapColumnType {
fk_gallery_id?: string;
}
export interface KanbanReqType {
title: string;
fk_grp_col_id?: string | null;
}
export interface KanbanUpdateReqType {
fk_grp_col_id?: string | null;
}
export interface FormType {
id?: string;
title?: string;
@ -460,6 +489,23 @@ export interface FormType {
meta?: any;
}
export interface FormReqType {
title: string;
heading?: string;
subheading?: string;
success_msg?: string;
redirect_url?: string;
redirect_after_secs?: string;
email?: string;
banner_image_url?: string;
logo_url?: string;
submit_another_form?: boolean;
show_blank_form?: boolean;
fk_model_id?: string;
lock_type?: 'collaborative' | 'locked' | 'personal';
meta?: any;
}
export interface FormColumnType {
fk_column_id?: string;
id?: string;
@ -584,6 +630,33 @@ export interface HookTestReqType {
hook: HookReqType;
}
export interface SignUpReqType {
email: string;
password: string;
}
export interface SignInReqType {
email: string;
password: string;
}
export interface ForgotPasswordReqType {
email: string;
}
export interface PasswordResetReqType {
password: string;
}
export interface PasswordChangeReqType {
currentPassword: string;
newPassword: string;
}
export interface ApiTokenReqType {
description?: string;
}
export interface PluginType {
id?: string;
title?: string;
@ -684,24 +757,22 @@ export interface NormalColumnRequestType {
fk_model_id?: string;
title?: string;
dt?: string;
np?: string;
ns?: string;
clen?: string | number;
cop?: string;
np?: string | number | null;
ns?: string | number | null;
pk?: boolean;
pv?: boolean;
rqd?: boolean;
rqd?: number | null | boolean;
column_name?: string;
un?: boolean;
un?: boolean | number | null;
ct?: string;
ai?: boolean;
unique?: boolean;
cdf?: string;
cdf?: string | null;
cc?: string;
csn?: string;
dtx?: string;
dtxp?: string;
dtxs?: string;
dtxp?: string | null;
dtxs?: string | null;
au?: boolean;
}
@ -760,6 +831,17 @@ export interface UserInfoType {
roles?: any;
}
export type VisibilityRuleReqType = {
disabled?: {
commenter?: boolean;
creator?: boolean;
editor?: boolean;
guest?: boolean;
owner?: boolean;
viewer?: boolean;
};
}[];
import axios, { AxiosInstance, AxiosRequestConfig, ResponseType } from 'axios';
export type QueryParamsType = Record<string | number, any>;
@ -4804,7 +4886,7 @@ export class Api<
* @name Create
* @request POST:/api/v1/db/meta/projects/{projectId}/api-tokens
* @response `200` `void` OK
* @response `201` `ApiTokenType` Created
* @response `201` `ApiTokenReqType` Created
*/
create: (
projectId: string,

2
packages/nocodb/src/lib/meta/api/helpers/apiHelpers.ts

@ -8,7 +8,7 @@ export function parseHrtimeToSeconds(hrtime) {
return seconds;
}
const ajv = new Ajv({ strictSchema: false }); // Initialize AJV
const ajv = new Ajv({ strictSchema: false, strict: false }); // Initialize AJV
ajv.addSchema(swagger, 'swagger.json');

13
packages/nocodb/src/lib/meta/api/tableApis.ts

@ -6,8 +6,10 @@ import DOMPurify from 'isomorphic-dompurify';
import {
AuditOperationSubTypes,
AuditOperationTypes,
ColumnType,
isVirtualCol,
ModelTypes,
NormalColumnRequestType,
TableListType,
TableReqType,
TableType,
@ -17,7 +19,7 @@ import ProjectMgrv2 from '../../db/sql-mgr/v2/ProjectMgrv2';
import Project from '../../models/Project';
import Audit from '../../models/Audit';
import ncMetaAclMw from '../helpers/ncMetaAclMw';
import { getAjvValidatorMw } from './helpers'
import { getAjvValidatorMw } from './helpers';
import { xcVisibilityMetaGet } from './modelVisibilityApis';
import View from '../../models/View';
import getColumnPropsFromUIDT from '../helpers/getColumnPropsFromUIDT';
@ -217,10 +219,13 @@ export async function tableCreate(req: Request<any, any, TableReqType>, res) {
columns: columns.map((c, i) => {
const colMetaFromReq = req.body?.columns?.find(
(c1) => c.cn === c1.column_name
);
) as NormalColumnRequestType;
return {
...colMetaFromReq,
uidt: colMetaFromReq?.uidt || c.uidt || getColumnUiType(base, c),
uidt:
(colMetaFromReq?.uidt as string) ||
c.uidt ||
getColumnUiType(base, c),
...c,
dtxp: [UITypes.MultiSelect, UITypes.SingleSelect].includes(
colMetaFromReq.uidt as any
@ -230,7 +235,7 @@ export async function tableCreate(req: Request<any, any, TableReqType>, res) {
title: colMetaFromReq?.title || getColumnNameAlias(c.cn, base),
column_name: c.cn,
order: i + 1,
};
} as NormalColumnRequestType;
}),
order: +(tables?.pop()?.order ?? 0) + 1,
})

29
scripts/sdk/swagger.json

@ -8396,13 +8396,33 @@
"type": "boolean"
},
"rqd": {
"type": "boolean"
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "null"
}
]
},
"column_name": {
"type": "string"
},
"un": {
"type": "boolean"
"oneOf": [
{
"type": "boolean"
},
{
"type": "integer"
},
{
"type": "null"
}
]
},
"ct": {
"type": "string"
@ -8472,10 +8492,7 @@
}
]
}
},
"required": [
"uidt"
]
}
},
"ColumnList": {
"description": "",

Loading…
Cancel
Save