Browse Source

Merge pull request #5253 from nocodb/refactor/api

refactor(nocodb): APIs
pull/5261/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
9d8a5b7815
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 118
      packages/nocodb-sdk/src/lib/Api.ts
  2. 5
      packages/nocodb/src/lib/models/GridView.ts
  3. 4
      packages/nocodb/src/lib/models/KanbanView.ts
  4. 4
      packages/nocodb/src/lib/models/KanbanViewColumn.ts
  5. 945
      packages/nocodb/src/schema/swagger.json

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

@ -307,7 +307,7 @@ export interface ColumnType {
/** Column Comment */ /** Column Comment */
cc?: string; cc?: string;
/** Column Default */ /** Column Default */
cdf?: string; cdf?: StringOrNullType;
/** Character Maximum Length */ /** Character Maximum Length */
clen?: number | null | string; clen?: number | null | string;
/** Column Options */ /** Column Options */
@ -331,11 +331,8 @@ export interface ColumnType {
column_name?: string; column_name?: string;
/** Column Ordinal Position */ /** Column Ordinal Position */
cop?: string; cop?: string;
/** /** Character Set Name */
* Character Set Name csn?: StringOrNullType;
* @example utf8mb4
*/
csn?: string;
/** /**
* Column Type * Column Type
* @example varchar(45) * @example varchar(45)
@ -965,28 +962,53 @@ export interface GeoLocationType {
* Model for Grid * Model for Grid
*/ */
export interface GridType { export interface GridType {
alias?: string;
/** Model for Bool */
deleted?: BoolType;
/** Unique ID */ /** Unique ID */
id?: IdType; id?: IdType;
lock_type?: 'collaborative' | 'locked' | 'personal'; /** Project ID */
order?: number; project_id?: IdType;
/** Base ID */
base_id?: IdType;
/** Foreign Key to View */
fk_view_id?: IdType;
/**
* Row Height
* @example 1
*/
row_height?: number; row_height?: number;
title?: string; /** Meta info for Grid Model */
meta?: MetaType;
/** Grid View Columns */
columns?: GridColumnType[];
} }
/** /**
* Model for Grid Column * Model for Grid Column
*/ */
export interface GridColumnType { export interface GridColumnType {
/** Unique ID */
id?: IdType;
/** Foreign Key to View */
fk_view_id?: IdType;
/** Foreign Key to Column */ /** Foreign Key to Column */
fk_column_id?: IdType; fk_column_id?: IdType;
help?: string; /** Project ID */
/** Unique ID of Grid Column */ project_id?: IdType;
id?: string; /** Base ID */
label?: string; base_id?: IdType;
/** Model for Bool */
show?: BoolType;
/**
* Grid Column Order
* @example 1
*/
order?: number;
/**
* Column Width
* @example 200px
*/
width?: string; width?: string;
/** Column Help Text */
help?: StringOrNullType;
} }
/** /**
@ -1206,16 +1228,22 @@ export type IdType = string;
* Model for Kanban * Model for Kanban
*/ */
export interface KanbanType { export interface KanbanType {
alias?: string;
columns?: KanbanColumnType[];
fk_cover_image_col_id?: string;
/** Model for StringOrNull */
fk_grp_col_id?: StringOrNullType;
fk_model_id?: string;
/** Unique ID */ /** Unique ID */
id?: IdType; id?: IdType;
/** Model for Meta */ /** Grouping Field Column ID */
fk_grp_col_id?: StringOrNullType;
/** View ID */
fk_view_id?: IdType;
/** Cover Image Column ID */
fk_cover_image_col_id?: IdType;
/** Kanban Columns */
columns?: KanbanColumnType[];
/** Meta Info for Kanban */
meta?: MetaType; meta?: MetaType;
/**
* Kanban Title
* @example My Kanban
*/
title?: string; title?: string;
} }
@ -1223,13 +1251,28 @@ export interface KanbanType {
* Model for Kanban Column * Model for Kanban Column
*/ */
export interface KanbanColumnType { export interface KanbanColumnType {
/** Foreign Key to Column */
fk_column_id?: IdType;
fk_kanban_id?: string;
help?: string;
/** Unique ID */ /** Unique ID */
id?: IdType; id?: IdType;
label?: string; /** Foreign Key to Column */
fk_column_id?: IdType;
/** Foreign Key to View */
fk_view_id?: IdType;
/**
* Baes ID
*
*/
base_id?: IdType;
/** Project ID */
project_id?: IdType;
/** Project ID */
title?: string;
/** Is this column shown? */
show?: BoolType;
/**
* Column Order
* @example 1
*/
order?: number;
} }
/** /**
@ -1885,11 +1928,8 @@ export interface SharedViewListType {
export interface SharedViewReqType { export interface SharedViewReqType {
/** Meta data passing to Shared View such as if download is allowed or not. */ /** Meta data passing to Shared View such as if download is allowed or not. */
meta?: MetaType; meta?: MetaType;
/** /** Password to restrict access */
* Password to restrict access password?: StringOrNullType;
* @example 123456789
*/
password?: string;
} }
/** /**
@ -2004,7 +2044,7 @@ export interface TableType {
/** Table Name. Prefix will be added for XCDB projects. */ /** Table Name. Prefix will be added for XCDB projects. */
table_name: string; table_name: string;
/** Currently not in use */ /** Currently not in use */
tags?: string; tags?: StringOrNullType;
/** Table Title */ /** Table Title */
title: string; title: string;
/** Table Type */ /** Table Type */
@ -2142,7 +2182,7 @@ export interface ViewType {
/** View Type */ /** View Type */
type: number; type: number;
/** UUID of the view */ /** UUID of the view */
uuid?: string; uuid?: StringOrNullType;
/** Associated View Model */ /** Associated View Model */
view?: view?:
| FormType | FormType
@ -3320,10 +3360,10 @@ export class Api<
* @name Read * @name Read
* @summary Get Project * @summary Get Project
* @request GET:/api/v1/db/meta/projects/{projectId} * @request GET:/api/v1/db/meta/projects/{projectId}
* @response `200` `object` OK * @response `200` `ProjectType` OK
*/ */
read: (projectId: IdType, params: RequestParams = {}) => read: (projectId: IdType, params: RequestParams = {}) =>
this.request<object, any>({ this.request<ProjectType, any>({
path: `/api/v1/db/meta/projects/${projectId}`, path: `/api/v1/db/meta/projects/${projectId}`,
method: 'GET', method: 'GET',
format: 'json', format: 'json',
@ -3620,10 +3660,10 @@ export class Api<
* @name Read * @name Read
* @summary Get Base * @summary Get Base
* @request GET:/api/v1/db/meta/projects/{projectId}/bases/{baseId} * @request GET:/api/v1/db/meta/projects/{projectId}/bases/{baseId}
* @response `200` `object` OK * @response `200` `BaseType` OK
*/ */
read: (projectId: IdType, baseId: string, params: RequestParams = {}) => read: (projectId: IdType, baseId: string, params: RequestParams = {}) =>
this.request<object, any>({ this.request<BaseType, any>({
path: `/api/v1/db/meta/projects/${projectId}/bases/${baseId}`, path: `/api/v1/db/meta/projects/${projectId}/bases/${baseId}`,
method: 'GET', method: 'GET',
format: 'json', format: 'json',

5
packages/nocodb/src/lib/models/GridView.ts

@ -4,13 +4,14 @@ import GridViewColumn from './GridViewColumn';
import View from './View'; import View from './View';
import NocoCache from '../cache/NocoCache'; import NocoCache from '../cache/NocoCache';
import { extractProps } from '../meta/helpers/extractProps'; import { extractProps } from '../meta/helpers/extractProps';
import type { GridType, MetaType } from 'nocodb-sdk';
export default class GridView { export default class GridView implements GridType {
fk_view_id: string; fk_view_id: string;
project_id?: string; project_id?: string;
base_id?: string; base_id?: string;
meta?: string; meta?: MetaType;
row_height?: number; row_height?: number;
columns?: GridViewColumn[]; columns?: GridViewColumn[];

4
packages/nocodb/src/lib/models/KanbanView.ts

@ -1,5 +1,5 @@
import Noco from '../Noco'; import Noco from '../Noco';
import { BoolType, KanbanType, UITypes } from 'nocodb-sdk'; import { BoolType, KanbanType, MetaType, UITypes } from 'nocodb-sdk';
import { CacheGetType, CacheScope, MetaTable } from '../utils/globals'; import { CacheGetType, CacheScope, MetaTable } from '../utils/globals';
import View from './View'; import View from './View';
import NocoCache from '../cache/NocoCache'; import NocoCache from '../cache/NocoCache';
@ -12,7 +12,7 @@ export default class KanbanView implements KanbanType {
base_id?: string; base_id?: string;
fk_grp_col_id?: string; fk_grp_col_id?: string;
fk_cover_image_col_id?: string; fk_cover_image_col_id?: string;
meta?: string | Record<string, any>; meta?: MetaType;
// below fields are not in use at this moment // below fields are not in use at this moment
// keep them for time being // keep them for time being

4
packages/nocodb/src/lib/models/KanbanViewColumn.ts

@ -3,9 +3,9 @@ import { CacheGetType, CacheScope, MetaTable } from '../utils/globals';
import View from './View'; import View from './View';
import NocoCache from '../cache/NocoCache'; import NocoCache from '../cache/NocoCache';
import { extractProps } from '../meta/helpers/extractProps'; import { extractProps } from '../meta/helpers/extractProps';
import { BoolType } from 'nocodb-sdk'; import { BoolType, KanbanColumnType } from 'nocodb-sdk';
export default class KanbanViewColumn { export default class KanbanViewColumn implements KanbanColumnType {
id: string; id: string;
title?: string; title?: string;
show?: BoolType; show?: BoolType;

945
packages/nocodb/src/schema/swagger.json

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save