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. 25
      scripts/sdk/swagger.json

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

@ -176,7 +176,7 @@ export interface TableReqType {
deleted?: boolean; deleted?: boolean;
order?: number; order?: number;
mm?: boolean; mm?: boolean;
columns: ColumnType[]; columns: NormalColumnRequestType[];
meta?: any; meta?: any;
} }
@ -244,17 +244,17 @@ export interface ColumnType {
base_id?: string; base_id?: string;
fk_model_id?: string; fk_model_id?: string;
title?: string; title?: string;
uidt: string; uidt?: string;
dt?: string; dt?: string;
np?: string; np?: string | number | null;
ns?: string; ns?: string | number | null;
clen?: string | number; clen?: string | number | null;
cop?: string; cop?: string;
pk?: boolean; pk?: boolean;
pv?: boolean; pv?: boolean;
rqd?: boolean; rqd?: boolean | number | null;
column_name?: string; column_name?: string;
un?: boolean; un?: boolean | number | null;
ct?: string; ct?: string;
ai?: boolean; ai?: boolean;
unique?: boolean; unique?: boolean;
@ -359,6 +359,13 @@ export interface GridType {
row_height?: number; row_height?: number;
} }
export interface GridReqType {
title: string;
order?: number;
lock_type?: 'collaborative' | 'locked' | 'personal';
row_height?: number;
}
export interface GalleryType { export interface GalleryType {
fk_view_id?: string; fk_view_id?: string;
title?: string; title?: string;
@ -378,6 +385,19 @@ export interface GalleryType {
lock_type?: 'collaborative' | 'locked' | 'personal'; 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 { export interface GalleryColumnType {
id?: string; id?: string;
label?: string; label?: string;
@ -441,6 +461,15 @@ export interface MapColumnType {
fk_gallery_id?: string; 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 { export interface FormType {
id?: string; id?: string;
title?: string; title?: string;
@ -460,6 +489,23 @@ export interface FormType {
meta?: any; 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 { export interface FormColumnType {
fk_column_id?: string; fk_column_id?: string;
id?: string; id?: string;
@ -584,6 +630,33 @@ export interface HookTestReqType {
hook: HookReqType; 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 { export interface PluginType {
id?: string; id?: string;
title?: string; title?: string;
@ -684,24 +757,22 @@ export interface NormalColumnRequestType {
fk_model_id?: string; fk_model_id?: string;
title?: string; title?: string;
dt?: string; dt?: string;
np?: string; np?: string | number | null;
ns?: string; ns?: string | number | null;
clen?: string | number;
cop?: string;
pk?: boolean; pk?: boolean;
pv?: boolean; pv?: boolean;
rqd?: boolean; rqd?: number | null | boolean;
column_name?: string; column_name?: string;
un?: boolean; un?: boolean | number | null;
ct?: string; ct?: string;
ai?: boolean; ai?: boolean;
unique?: boolean; unique?: boolean;
cdf?: string; cdf?: string | null;
cc?: string; cc?: string;
csn?: string; csn?: string;
dtx?: string; dtx?: string;
dtxp?: string; dtxp?: string | null;
dtxs?: string; dtxs?: string | null;
au?: boolean; au?: boolean;
} }
@ -760,6 +831,17 @@ export interface UserInfoType {
roles?: any; 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'; import axios, { AxiosInstance, AxiosRequestConfig, ResponseType } from 'axios';
export type QueryParamsType = Record<string | number, any>; export type QueryParamsType = Record<string | number, any>;
@ -4804,7 +4886,7 @@ export class Api<
* @name Create * @name Create
* @request POST:/api/v1/db/meta/projects/{projectId}/api-tokens * @request POST:/api/v1/db/meta/projects/{projectId}/api-tokens
* @response `200` `void` OK * @response `200` `void` OK
* @response `201` `ApiTokenType` Created * @response `201` `ApiTokenReqType` Created
*/ */
create: ( create: (
projectId: string, projectId: string,

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

@ -8,7 +8,7 @@ export function parseHrtimeToSeconds(hrtime) {
return seconds; 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'); ajv.addSchema(swagger, 'swagger.json');

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

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

25
scripts/sdk/swagger.json

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

Loading…
Cancel
Save