From 85f74cc572c3f15b7c0b1b5fe4708bb2cd950adb Mon Sep 17 00:00:00 2001 From: Pranav C Date: Tue, 28 Feb 2023 01:25:08 +0530 Subject: [PATCH] refactor: add generic types and add missing validations Signed-off-by: Pranav C --- packages/nocodb-sdk/src/lib/Api.ts | 377 +++++++++++-------- packages/nocodb/src/schema/swagger.json | 479 ++++++++++++++---------- 2 files changed, 492 insertions(+), 364 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/Api.ts b/packages/nocodb-sdk/src/lib/Api.ts index f89d2453e2..79fe024303 100644 --- a/packages/nocodb-sdk/src/lib/Api.ts +++ b/packages/nocodb-sdk/src/lib/Api.ts @@ -131,7 +131,7 @@ export interface ViewType { title: string; deleted?: BoolType; order?: number; - fk_model_id?: string; + fk_model_id?: IdType; slug?: string; uuid?: string; meta?: MetaType; @@ -149,8 +149,8 @@ export interface ViewType { export interface TableInfoType { id?: string; - fk_project_id?: string; - fk_base_id?: string; + fk_project_id?: IdType; + fk_base_id?: IdType; title: string; table_name: string; type?: string; @@ -189,8 +189,8 @@ export interface TableListType { export interface FilterType { id?: string; - fk_model_id?: string; - fk_column_id?: string; + fk_model_id?: IdType; + fk_column_id?: IdType; logical_op?: string; comparison_op?: string; value?: any; @@ -198,13 +198,13 @@ export interface FilterType { children?: FilterType[]; project_id?: string; base_id?: string; - fk_parent_id?: string; + fk_parent_id?: IdType; fk_view_id?: StringOrNullType; fk_hook_id?: StringOrNullType; } export interface FilterReqType { - fk_column_id?: string; + fk_column_id?: IdType; logical_op?: 'and' | 'or' | 'not'; comparison_op?: | 'checked' @@ -229,7 +229,7 @@ export interface FilterReqType { | 'notblank'; value?: any; is_group?: BoolType; - fk_parent_id?: string; + fk_parent_id?: IdType; } export interface FilterListType { @@ -240,8 +240,8 @@ export interface FilterListType { export interface SortType { id?: string; - fk_model_id?: string; - fk_column_id?: string; + fk_model_id?: IdType; + fk_column_id?: IdType; direction?: string; order?: number; project_id?: string; @@ -249,7 +249,7 @@ export interface SortType { } export interface SortReqType { - fk_column_id?: string; + fk_column_id?: IdType; direction?: 'asc' | 'desc'; } @@ -883,17 +883,17 @@ export interface LinkToAnotherColumnReqType { uidt: 'LinkToAnotherRecord'; title: string; virtual?: BoolType; - parentId: string; - childId: string; + parentId: IdType; + childId: IdType; type: 'hm' | 'bt' | 'mm'; } export interface RollupColumnReqType { - uidt?: 'Rollup'; - title?: string; - fk_relation_column_id?: string; - fk_rollup_column_id?: string; - rollup_function?: + uidt: 'Rollup'; + title: string; + fk_relation_column_id: IdType; + fk_rollup_column_id: IdType; + rollup_function: | 'count' | 'min' | 'max' @@ -905,10 +905,10 @@ export interface RollupColumnReqType { } export interface LookupColumnReqType { - uidt?: 'Lookup'; - title?: string; - fk_relation_column_id?: string; - fk_lookup_column_id?: string; + uidt: 'Lookup'; + title: string; + fk_relation_column_id: IdType; + fk_lookup_column_id: IdType; } export interface FormulaColumnReqType { @@ -961,6 +961,8 @@ export type VisibilityRuleReqType = { export type BoolType = boolean | number | null; +export type IdType = string; + export type PasswordType = string; export type StringOrNullType = string | null; @@ -988,18 +990,18 @@ export interface OrgUserReqType { export interface ProjectUserReqType { /** @format email */ - email?: string; - roles?: 'owner' | 'editor' | 'viewer' | 'commenter' | 'guest'; + email: string; + roles: 'owner' | 'editor' | 'viewer' | 'commenter' | 'guest'; } export interface SharedBaseReqType { - uuid?: StringOrNullType; - roles?: StringOrNullType; + roles?: 'editor' | 'viewer' | 'commenter'; + password?: string; } export interface PluginTestReqType { - title?: string; - input?: any; + title: string; + input: any; } export interface PluginReqType { @@ -1007,6 +1009,20 @@ export interface PluginReqType { input?: any; } +export interface ViewReqType { + /** @min 0 */ + order?: number; + meta?: MetaType; + title?: string; + show_system_fields?: BoolType; + lock_type?: 'collaborative' | 'locked' | 'personal'; +} + +export interface SharedViewReqType { + password?: string; + meta?: MetaType; +} + import axios, { AxiosInstance, AxiosRequestConfig, ResponseType } from 'axios'; export type QueryParamsType = Record; @@ -1371,18 +1387,27 @@ export class Api< }), /** - * No description - * - * @tags Auth - * @name TokenRefresh - * @summary Refresh token - * @request POST:/api/v1/auth/token/refresh - * @response `200` `void` OK - */ + * No description + * + * @tags Auth + * @name TokenRefresh + * @summary Refresh token + * @request POST:/api/v1/auth/token/refresh + * @response `200` `{ + token?: string, + +}` OK + */ tokenRefresh: (params: RequestParams = {}) => - this.request({ + this.request< + { + token?: string; + }, + any + >({ path: `/api/v1/auth/token/refresh`, method: 'POST', + format: 'json', ...params, }), @@ -1402,7 +1427,7 @@ export class Api< }` OK */ - projectUserList: (projectId: string, params: RequestParams = {}) => + projectUserList: (projectId: IdType, params: RequestParams = {}) => this.request< { users?: { @@ -1428,7 +1453,7 @@ export class Api< * @response `200` `any` OK */ projectUserAdd: ( - projectId: string, + projectId: IdType, data: ProjectUserReqType, params: RequestParams = {} ) => @@ -1451,8 +1476,8 @@ export class Api< * @response `200` `any` OK */ projectUserUpdate: ( - projectId: string, - userId: string, + projectId: IdType, + userId: IdType, data: ProjectUserReqType, params: RequestParams = {} ) => @@ -1475,8 +1500,8 @@ export class Api< * @response `200` `any` OK */ projectUserRemove: ( - projectId: string, - userId: string, + projectId: IdType, + userId: IdType, params: RequestParams = {} ) => this.request({ @@ -1495,8 +1520,8 @@ export class Api< * @response `200` `any` OK */ projectUserResendInvite: ( - projectId: string, - userId: string, + projectId: IdType, + userId: IdType, params: RequestParams = {} ) => this.request({ @@ -1731,7 +1756,7 @@ export class Api< * @response `200` `void` OK */ update: ( - userId: string, + userId: IdType, data: OrgUserReqType, params: RequestParams = {} ) => @@ -1752,7 +1777,7 @@ export class Api< * @request DELETE:/api/v1/users/{userId} * @response `200` `void` OK */ - delete: (userId: string, params: RequestParams = {}) => + delete: (userId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/users/${userId}`, method: 'DELETE', @@ -1768,7 +1793,7 @@ export class Api< * @request POST:/api/v1/users/{userId}/resend-invite * @response `200` `void` OK */ - resendInvite: (userId: string, params: RequestParams = {}) => + resendInvite: (userId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/users/${userId}/resend-invite`, method: 'POST', @@ -1788,7 +1813,7 @@ export class Api< }` OK */ - generatePasswordResetToken: (userId: string, params: RequestParams = {}) => + generatePasswordResetToken: (userId: IdType, params: RequestParams = {}) => this.request< { reset_password_token?: string; @@ -1822,7 +1847,7 @@ export class Api< }` OK */ - metaGet: (projectId: string, params: RequestParams = {}, query: object) => + metaGet: (projectId: IdType, params: RequestParams = {}) => this.request< { Node?: string; @@ -1838,7 +1863,6 @@ export class Api< >({ path: `/api/v1/db/meta/projects/${projectId}/info`, method: 'GET', - query: query, format: 'json', ...params, }), @@ -1853,7 +1877,7 @@ export class Api< * @response `200` `(any)[]` OK */ modelVisibilityList: ( - projectId: string, + projectId: IdType, query?: { includeM2M?: boolean; }, @@ -1876,7 +1900,7 @@ export class Api< * @response `200` `VisibilityRuleReqType` OK */ modelVisibilitySet: ( - projectId: string, + projectId: IdType, data: any, params: RequestParams = {} ) => @@ -1946,7 +1970,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId} * @response `200` `object` OK */ - read: (projectId: string, params: RequestParams = {}) => + read: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}`, method: 'GET', @@ -1963,7 +1987,7 @@ export class Api< * @request DELETE:/api/v1/db/meta/projects/{projectId} * @response `200` `void` OK */ - delete: (projectId: string, params: RequestParams = {}) => + delete: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}`, method: 'DELETE', @@ -1979,7 +2003,7 @@ export class Api< * @request PATCH:/api/v1/db/meta/projects/{projectId} * @response `200` `void` OK */ - update: (projectId: string, data: any, params: RequestParams = {}) => + update: (projectId: IdType, data: any, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}`, method: 'PATCH', @@ -2001,7 +2025,7 @@ export class Api< }` OK */ - sharedBaseGet: (projectId: string, params: RequestParams = {}) => + sharedBaseGet: (projectId: IdType, params: RequestParams = {}) => this.request< { uuid?: string; @@ -2024,7 +2048,7 @@ export class Api< * @request DELETE:/api/v1/db/meta/projects/{projectId}/shared * @response `200` `void` OK */ - sharedBaseDisable: (projectId: string, params: RequestParams = {}) => + sharedBaseDisable: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/shared`, method: 'DELETE', @@ -2032,22 +2056,29 @@ export class Api< }), /** - * No description - * - * @tags Project - * @name SharedBaseCreate - * @request POST:/api/v1/db/meta/projects/{projectId}/shared - * @response `200` `SharedBaseReqType` OK - */ + * No description + * + * @tags Project + * @name SharedBaseCreate + * @request POST:/api/v1/db/meta/projects/{projectId}/shared + * @response `200` `{ + uuid?: StringOrNullType, + roles?: StringOrNullType, + +}` OK + */ sharedBaseCreate: ( - projectId: string, - data: { - roles?: string; - password?: string; - }, + projectId: IdType, + data: SharedBaseReqType, params: RequestParams = {} ) => - this.request({ + this.request< + { + uuid?: StringOrNullType; + roles?: StringOrNullType; + }, + any + >({ path: `/api/v1/db/meta/projects/${projectId}/shared`, method: 'POST', body: data, @@ -2070,11 +2101,8 @@ export class Api< }` OK */ sharedBaseUpdate: ( - projectId: string, - data: { - roles?: string; - password?: string; - }, + projectId: IdType, + data: SharedBaseReqType, params: RequestParams = {} ) => this.request< @@ -2102,7 +2130,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId}/cost * @response `200` `object` OK */ - cost: (projectId: string, params: RequestParams = {}) => + cost: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/cost`, method: 'GET', @@ -2118,7 +2146,7 @@ export class Api< * @request POST:/api/v1/db/meta/projects/{projectId}/meta-diff * @response `200` `any` OK */ - metaDiffSync: (projectId: string, params: RequestParams = {}) => + metaDiffSync: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/meta-diff`, method: 'POST', @@ -2134,7 +2162,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId}/meta-diff * @response `200` `any` OK */ - metaDiffGet: (projectId: string, params: RequestParams = {}) => + metaDiffGet: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/meta-diff`, method: 'GET', @@ -2150,7 +2178,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId}/has-empty-or-null-filters * @response `200` `any` OK */ - hasEmptyOrNullFilters: (projectId: string, params: RequestParams = {}) => + hasEmptyOrNullFilters: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/has-empty-or-null-filters`, method: 'GET', @@ -2171,10 +2199,12 @@ export class Api< }` OK */ auditList: ( - projectId: string, + projectId: IdType, query?: { - offset?: string; - limit?: string; + /** @min 0 */ + offset?: number; + /** @max 1 */ + limit?: number; }, params: RequestParams = {} ) => @@ -2202,7 +2232,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId}/bases/{baseId} * @response `200` `object` OK */ - read: (projectId: string, baseId: string, params: RequestParams = {}) => + read: (projectId: IdType, baseId: string, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/bases/${baseId}`, method: 'GET', @@ -2219,7 +2249,7 @@ export class Api< * @request DELETE:/api/v1/db/meta/projects/{projectId}/bases/{baseId} * @response `200` `void` OK */ - delete: (projectId: string, baseId: string, params: RequestParams = {}) => + delete: (projectId: IdType, baseId: string, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/bases/${baseId}`, method: 'DELETE', @@ -2236,7 +2266,7 @@ export class Api< * @response `200` `void` OK */ update: ( - projectId: string, + projectId: IdType, baseId: string, data: any, params: RequestParams = {} @@ -2258,7 +2288,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId}/bases/ * @response `200` `object` OK */ - list: (projectId: string, params: RequestParams = {}) => + list: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/bases/`, method: 'GET', @@ -2276,7 +2306,7 @@ export class Api< * @response `200` `BaseType` OK */ create: ( - projectId: string, + projectId: IdType, data: BaseType & { external?: boolean; }, @@ -2300,7 +2330,7 @@ export class Api< * @response `200` `TableListType` */ tableList: ( - projectId: string, + projectId: IdType, baseId: string, query?: { page?: number; @@ -2326,7 +2356,7 @@ export class Api< * @response `200` `TableType` OK */ tableCreate: ( - projectId: string, + projectId: IdType, baseId: string, data: TableReqType, params: RequestParams = {} @@ -2349,7 +2379,7 @@ export class Api< * @response `200` `any` OK */ metaDiffSync: ( - projectId: string, + projectId: IdType, baseId: string, params: RequestParams = {} ) => @@ -2369,7 +2399,7 @@ export class Api< * @response `200` `any` OK */ metaDiffGet: ( - projectId: string, + projectId: IdType, baseId: string, params: RequestParams = {} ) => @@ -2390,7 +2420,7 @@ export class Api< * @response `200` `TableType` OK */ create: ( - projectId: string, + projectId: IdType, data: TableReqType, params: RequestParams = {} ) => @@ -2412,7 +2442,7 @@ export class Api< * @response `200` `TableListType` */ list: ( - projectId: string, + projectId: IdType, query?: { page?: number; pageSize?: number; @@ -2436,7 +2466,7 @@ export class Api< * @request GET:/api/v1/db/meta/tables/{tableId} * @response `200` `TableInfoType` OK */ - read: (tableId: string, params: RequestParams = {}) => + read: (tableId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/tables/${tableId}`, method: 'GET', @@ -2453,7 +2483,7 @@ export class Api< * @response `200` `any` OK */ update: ( - tableId: string, + tableId: IdType, data: { table_name?: string; title?: string; @@ -2479,7 +2509,7 @@ export class Api< * @request DELETE:/api/v1/db/meta/tables/{tableId} * @response `200` `void` OK */ - delete: (tableId: string, params: RequestParams = {}) => + delete: (tableId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/tables/${tableId}`, method: 'DELETE', @@ -2495,7 +2525,7 @@ export class Api< * @response `200` `void` OK */ reorder: ( - tableId: string, + tableId: IdType, data: { order?: number; }, @@ -2520,7 +2550,7 @@ export class Api< * @response `200` `void` OK */ create: ( - tableId: string, + tableId: IdType, data: ColumnReqType, params: RequestParams = {} ) => @@ -2611,7 +2641,7 @@ export class Api< * @request GET:/api/v1/db/meta/tables/{tableId}/views * @response `200` `ViewListType` */ - list: (tableId: string, params: RequestParams = {}) => + list: (tableId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/tables/${tableId}/views`, method: 'GET', @@ -2626,17 +2656,7 @@ export class Api< * @request PATCH:/api/v1/db/meta/views/{viewId} * @response `200` `void` OK */ - update: ( - viewId: string, - data: { - order?: number; - meta?: MetaType; - title?: string; - show_system_fields?: boolean; - lock_type?: 'collaborative' | 'locked' | 'personal'; - }, - params: RequestParams = {} - ) => + update: (viewId: string, data: ViewReqType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/views/${viewId}`, method: 'PATCH', @@ -2713,7 +2733,7 @@ export class Api< * @response `200` `GridType` OK */ gridCreate: ( - tableId: string, + tableId: IdType, data: GridReqType, params: RequestParams = {} ) => @@ -2735,7 +2755,7 @@ export class Api< * @response `200` `FormType` OK */ formCreate: ( - tableId: string, + tableId: IdType, data: FormCreateReqType, params: RequestParams = {} ) => @@ -2791,14 +2811,14 @@ export class Api< * @tags DB view * @name FormColumnUpdate * @request PATCH:/api/v1/db/meta/form-columns/{formViewColumnId} - * @response `200` `any` OK + * @response `200` `FormColumnReqType` OK */ formColumnUpdate: ( - formViewColumnId: string, + formViewColumnId: IdType, data: FormColumnReqType, params: RequestParams = {} ) => - this.request({ + this.request({ path: `/api/v1/db/meta/form-columns/${formViewColumnId}`, method: 'PATCH', body: data, @@ -2850,7 +2870,7 @@ export class Api< * @response `200` `any` OK */ gridColumnUpdate: ( - columnId: string, + columnId: IdType, data: GridColumnReqType, params: RequestParams = {} ) => @@ -2872,7 +2892,7 @@ export class Api< * @response `200` `object` OK */ galleryCreate: ( - tableId: string, + tableId: IdType, data: GalleryReqType, params: RequestParams = {} ) => @@ -2931,7 +2951,7 @@ export class Api< * @response `200` `object` OK */ kanbanCreate: ( - tableId: string, + tableId: IdType, data: KanbanReqType, params: RequestParams = {} ) => @@ -2989,7 +3009,7 @@ export class Api< * @request POST:/api/v1/db/meta/tables/{tableId}/maps * @response `200` `object` OK */ - mapCreate: (tableId: string, data: MapType, params: RequestParams = {}) => + mapCreate: (tableId: IdType, data: MapType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/tables/${tableId}/maps`, method: 'POST', @@ -3042,7 +3062,7 @@ export class Api< * @request GET:/api/v1/db/meta/tables/{tableId}/share * @response `200` `(any)[]` OK */ - list: (tableId: string, params: RequestParams = {}) => + list: (tableId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/tables/${tableId}/share`, method: 'GET', @@ -3084,10 +3104,7 @@ export class Api< */ update: ( viewId: string, - data: { - password?: string; - meta?: MetaType; - }, + data: SharedViewReqType, params: RequestParams = {} ) => this.request({ @@ -3155,8 +3172,8 @@ export class Api< * @response `200` `void` OK */ update: ( - viewId: string, - columnId: string, + viewId: IdType, + columnId: IdType, data: any, params: RequestParams = {} ) => @@ -3208,7 +3225,7 @@ export class Api< */ create: ( viewId: string, - data: SortType & { + data: SortReqType & { push_to_top?: boolean; }, params: RequestParams = {} @@ -3245,7 +3262,7 @@ export class Api< * @request PATCH:/api/v1/db/meta/sorts/{sortId} * @response `200` `void` OK */ - update: (sortId: string, data: SortType, params: RequestParams = {}) => + update: (sortId: string, data: SortReqType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/sorts/${sortId}`, method: 'PATCH', @@ -3421,10 +3438,18 @@ export class Api< tableName: string, query?: { fields?: any[]; - sort?: any[]; + sort?: string[] | string; where?: string; - offset?: string; - limit?: string; + /** + * Offset in rows + * @min 0 + */ + offset?: number; + /** + * Limit in rows + * @min 1 + */ + limit?: number; }, params: RequestParams = {} ) => @@ -3507,7 +3532,9 @@ export class Api< column_name?: string; sort?: any[]; where?: string; + /** @min 1 */ limit?: number; + /** @min 0 */ offset?: number; }, params: RequestParams = {} @@ -3533,7 +3560,7 @@ export class Api< orgs: string, projectName: string, tableName: string, - columnId: string, + columnId: IdType, query?: { fields?: any[]; sort?: any[]; @@ -3819,8 +3846,10 @@ export class Api< relationType: 'mm' | 'hm' | 'bt', columnName: string, query?: { - limit?: string | number; - offset?: string | number; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; where?: string; }, params: RequestParams = {} @@ -3851,8 +3880,10 @@ export class Api< columnName: string, refRowId: string, query?: { - limit?: string; - offset?: string; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; }, params: RequestParams = {} ) => @@ -3907,8 +3938,10 @@ export class Api< relationType: 'mm' | 'hm' | 'bt', columnName: string, query?: { - limit?: string | number; - offset?: string | number; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; where?: string; }, params: RequestParams = {} @@ -3932,11 +3965,11 @@ export class Api< * @response `200` `any` OK */ groupedDataList: ( - orgs: string, + orgs: IdType, projectName: string, tableName: string, viewName: string, - columnId: string, + columnId: IdType, query?: { fields?: any[]; sort?: any[]; @@ -4062,7 +4095,9 @@ export class Api< column_name?: string; sort?: any[]; where?: string; + /** @min 1 */ limit?: number; + /** @min 0 */ offset?: number; }, params: RequestParams = {} @@ -4237,10 +4272,12 @@ export class Api< */ groupedDataList: ( sharedViewUuid: string, - columnId: string, + columnId: IdType, query?: { - limit?: string; - offset?: string; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; }, params: RequestParams = {} ) => @@ -4263,8 +4300,10 @@ export class Api< dataList: ( sharedViewUuid: string, query?: { - limit?: string; - offset?: string; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; }, params: RequestParams = {} ) => @@ -4312,8 +4351,10 @@ export class Api< relationType: 'mm' | 'hm' | 'bt', columnName: string, query?: { - limit?: string; - offset?: string; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; }, params: RequestParams = {} ) => @@ -4357,8 +4398,10 @@ export class Api< sharedViewUuid: string, columnName: string, query?: { - limit?: string; - offset?: string; + /** @min 1 */ + limit?: number; + /** @min 0 */ + offset?: number; }, params: RequestParams = {} ) => @@ -4453,7 +4496,7 @@ export class Api< commentList: ( query: { row_id: string; - fk_model_id: string; + fk_model_id: IdType; comments_only?: boolean; }, params: RequestParams = {} @@ -4494,7 +4537,7 @@ export class Api< commentCount: ( query: { ids: any; - fk_model_id: string; + fk_model_id: IdType; }, params: RequestParams = {} ) => @@ -4766,7 +4809,7 @@ export class Api< }` OK */ - list: (tableId: string, params: RequestParams = {}) => + list: (tableId: IdType, params: RequestParams = {}) => this.request< { list: HookType[]; @@ -4788,7 +4831,7 @@ export class Api< * @request POST:/api/v1/db/meta/tables/{tableId}/hooks * @response `200` `AuditType` OK */ - create: (tableId: string, data: AuditType, params: RequestParams = {}) => + create: (tableId: IdType, data: AuditType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/tables/${tableId}/hooks`, method: 'POST', @@ -4807,7 +4850,7 @@ export class Api< * @response `200` `any` OK */ test: ( - tableId: string, + tableId: IdType, data: HookTestReqType, params: RequestParams = {} ) => @@ -4836,7 +4879,7 @@ export class Api< }` OK */ samplePayloadGet: ( - tableId: string, + tableId: IdType, operation: 'update' | 'delete' | 'insert', params: RequestParams = {} ) => @@ -4957,10 +5000,14 @@ export class Api< * @tags Plugin * @name Update * @request PATCH:/api/v1/db/meta/plugins/{pluginId} - * @response `200` `PluginReqType` OK + * @response `200` `any` OK */ - update: (pluginId: string, data: PluginType, params: RequestParams = {}) => - this.request({ + update: ( + pluginId: string, + data: PluginReqType, + params: RequestParams = {} + ) => + this.request({ path: `/api/v1/db/meta/plugins/${pluginId}`, method: 'PATCH', body: data, @@ -4995,7 +5042,7 @@ export class Api< * @request GET:/api/v1/db/meta/projects/{projectId}/api-tokens * @response `200` `(ApiTokenType)[]` OK */ - list: (projectId: string, params: RequestParams = {}) => + list: (projectId: IdType, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/api-tokens`, method: 'GET', @@ -5010,13 +5057,11 @@ export class Api< * @name Create * @request POST:/api/v1/db/meta/projects/{projectId}/api-tokens * @response `200` `void` OK - * @response `201` `ApiTokenReqType` Created + * @response `201` `any` Created */ create: ( - projectId: string, - data: { - description?: string; - }, + projectId: IdType, + data: ApiTokenReqType, params: RequestParams = {} ) => this.request({ @@ -5035,7 +5080,7 @@ export class Api< * @request DELETE:/api/v1/db/meta/projects/{projectId}/api-tokens/{token} * @response `200` `void` OK */ - delete: (projectId: string, token: string, params: RequestParams = {}) => + delete: (projectId: IdType, token: string, params: RequestParams = {}) => this.request({ path: `/api/v1/db/meta/projects/${projectId}/api-tokens/${token}`, method: 'DELETE', diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index accde20a4f..0bce9bf798 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -328,7 +328,8 @@ "parameters": [ { "schema": { - "type": "string" + "type": "string", + "format": "uuid" }, "name": "token", "in": "path", @@ -353,7 +354,8 @@ "parameters": [ { "schema": { - "type": "string" + "type": "string", + "format": "uuid" }, "name": "token", "in": "path", @@ -387,7 +389,8 @@ "parameters": [ { "schema": { - "type": "string" + "type": "string", + "format": "uuid" }, "name": "token", "in": "path", @@ -401,7 +404,19 @@ "operationId": "auth-token-refresh", "responses": { "200": { - "description": "OK" + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + } + } + } + } + } } }, "description": "", @@ -690,7 +705,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "userId", "in": "path", @@ -738,7 +753,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "userId", "in": "path", @@ -762,7 +777,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "userId", "in": "path", @@ -843,7 +858,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -882,7 +897,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -932,16 +947,6 @@ }, "tags": [ "Project" - ], - "parameters": [ - { - "schema": { - "type": "number", - "minimum": 1, - "multipleOf": 1 - }, - "in": "query" - } ] } }, @@ -949,7 +954,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -957,8 +962,7 @@ }, { "schema": { - "type": "string", - "maxLength": 20 + "$ref": "#/components/schemas/Id" }, "name": "userId", "in": "path", @@ -1043,7 +1047,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1169,7 +1173,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1243,7 +1247,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1325,7 +1329,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1409,7 +1413,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1478,7 +1482,15 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SharedBaseReq" + "type": "object", + "properties": { + "uuid": { + "$ref": "#/components/schemas/StringOrNull" + }, + "roles": { + "$ref": "#/components/schemas/StringOrNull" + } + } } } } @@ -1491,15 +1503,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "roles": { - "type": "string" - }, - "password": { - "type": "string" - } - } + "$ref": "#/components/schemas/SharedBaseReq" } } } @@ -1535,15 +1539,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "roles": { - "type": "string" - }, - "password": { - "type": "string" - } - } + "$ref": "#/components/schemas/SharedBaseReq" } } } @@ -1558,7 +1554,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1601,7 +1597,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1690,7 +1686,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -1787,7 +1783,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -1961,7 +1958,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -1999,7 +1997,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -2120,7 +2119,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -2164,29 +2164,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "order": { - "type": "number" - }, - "meta": { - "$ref": "#/components/schemas/Meta" - }, - "title": { - "type": "string" - }, - "show_system_fields": { - "type": "boolean" - }, - "lock_type": { - "type": "string", - "enum": [ - "collaborative", - "locked", - "personal" - ] - } - } + "$ref": "#/components/schemas/ViewReq" } } } @@ -2280,7 +2258,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -2363,15 +2342,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "password": { - "type": "string" - }, - "meta": { - "$ref": "#/components/schemas/Meta" - } - } + "$ref": "#/components/schemas/SharedViewReq" } } }, @@ -2438,7 +2409,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "viewId", "in": "path", @@ -2446,7 +2418,8 @@ }, { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "columnId", "in": "path", @@ -2533,7 +2506,7 @@ "schema": { "allOf": [ { - "$ref": "#/components/schemas/Sort" + "$ref": "#/components/schemas/SortReq" }, { "type": "object", @@ -2595,7 +2568,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Sort" + "$ref": "#/components/schemas/SortReq" } } } @@ -2823,7 +2796,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -2863,7 +2837,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -2956,7 +2931,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "formViewColumnId", "in": "path", @@ -2972,7 +2948,7 @@ "content": { "application/json": { "schema": { - "$ref": "" + "$ref": "#/components/schemas/FormColumnReq" } } } @@ -3068,7 +3044,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "columnId", "in": "path", @@ -3106,7 +3083,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -3199,7 +3177,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -3292,7 +3271,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -3385,7 +3365,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -3432,7 +3412,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -3462,7 +3442,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -3557,7 +3537,17 @@ }, { "schema": { - "type": "array" + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + } + }, + { + "type": "string" + } + ] }, "in": "query", "name": "sort" @@ -3571,17 +3561,21 @@ }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", - "name": "offset" + "name": "offset", + "description": "Offset in rows" }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 1 }, "in": "query", - "name": "limit" + "name": "limit", + "description": "Limit in rows" } ], "responses": { @@ -3748,14 +3742,16 @@ }, { "schema": { - "type": "number" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "number" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -3777,7 +3773,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "orgs", "in": "path", @@ -3809,7 +3806,8 @@ }, { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "columnId", "in": "path", @@ -3892,7 +3890,8 @@ }, { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "columnId", "in": "path", @@ -4211,14 +4210,16 @@ }, { "schema": { - "type": "number" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "number" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5016,20 +5017,16 @@ "parameters": [ { "schema": { - "type": [ - "string", - "number" - ] + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": [ - "string", - "number" - ] + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5127,14 +5124,16 @@ "parameters": [ { "schema": { - "type": "string" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5235,20 +5234,16 @@ "parameters": [ { "schema": { - "type": [ - "string", - "number" - ] + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": [ - "string", - "number" - ] + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5275,7 +5270,8 @@ }, { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "columnId", "in": "path", @@ -5309,14 +5305,16 @@ "parameters": [ { "schema": { - "type": "string" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5362,14 +5360,16 @@ "parameters": [ { "schema": { - "type": "string" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5471,14 +5471,16 @@ "parameters": [ { "schema": { - "type": "string" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5579,14 +5581,16 @@ "parameters": [ { "schema": { - "type": "string" + "type": "integer", + "minimum": 1 }, "in": "query", "name": "limit" }, { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" @@ -5764,7 +5768,8 @@ }, { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "in": "query", "name": "fk_model_id", @@ -5828,7 +5833,8 @@ }, { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "in": "query", "name": "fk_model_id", @@ -5844,7 +5850,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -5887,14 +5893,16 @@ "parameters": [ { "schema": { - "type": "string" + "type": "integer", + "minimum": 0 }, "in": "query", "name": "offset" }, { "schema": { - "type": "string" + "type": "integer", + "maximum": 1 }, "in": "query", "name": "limit" @@ -5942,7 +5950,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -6021,7 +6029,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -6059,7 +6067,8 @@ "parameters": [ { "schema": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "name": "tableId", "in": "path", @@ -6301,9 +6310,7 @@ "description": "OK", "content": { "application/json": { - "schema": { - "$ref": "#/components/schemas/PluginReq" - } + "schema": {} } } } @@ -6315,7 +6322,8 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Plugin" + + "$ref": "#/components/schemas/PluginReq" } } } @@ -6886,7 +6894,6 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiTokenReq" } } } @@ -6896,12 +6903,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "description": { - "type": "string" - } - } + "$ref": "#/components/schemas/ApiTokenReq" } } } @@ -6913,7 +6915,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -6937,7 +6939,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -7039,7 +7041,7 @@ "parameters": [ { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "projectId", "in": "path", @@ -7047,7 +7049,7 @@ }, { "schema": { - "type": "string" + "$ref": "#/components/schemas/Id" }, "name": "userId", "in": "path", @@ -7648,7 +7650,8 @@ "type": "number" }, "fk_model_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "slug": { "type": "string" @@ -7793,10 +7796,12 @@ "type": "string" }, "fk_project_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "fk_base_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "title": { "type": "string" @@ -7867,6 +7872,7 @@ "type": "string", "description": "Table title", "example": "Table title", + "minLength": 1, "maxLength": 255 }, "order": { @@ -7945,10 +7951,12 @@ "type": "string" }, "fk_model_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "fk_column_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "logical_op": { "type": "string" @@ -7985,7 +7993,8 @@ "readOnly": true }, "fk_parent_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "fk_view_id": { "$ref": "#/components/schemas/StringOrNull" @@ -8001,8 +8010,8 @@ "title": "Filter", "properties": { "fk_column_id": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" }, "logical_op": { "type": "string", @@ -8042,8 +8051,8 @@ "$ref": "#/components/schemas/Bool" }, "fk_parent_id": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" } }, "readOnly": true @@ -8110,10 +8119,12 @@ "type": "string" }, "fk_model_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "fk_column_id": { - "type": "string" + + "$ref": "#/components/schemas/Id" }, "direction": { "type": "string" @@ -8136,8 +8147,7 @@ "type": "object", "properties": { "fk_column_id": { - "type": "string", - "maxLength": 20 + "$ref": "#/components/schemas/Id" }, "direction": { "type": "string", @@ -10177,12 +10187,12 @@ "$ref": "#/components/schemas/Bool" }, "parentId": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" }, "childId": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" }, "type": { "type": "string", @@ -10215,12 +10225,12 @@ "maxLength": 255 }, "fk_relation_column_id": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" }, "fk_rollup_column_id": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" }, "rollup_function": { "type": "string", @@ -10235,7 +10245,14 @@ "avgDistinct" ] } - } + }, + "required": [ + "uidt", + "title", + "fk_relation_column_id", + "fk_rollup_column_id", + "rollup_function" + ] }, "LookupColumnReq": { "properties": { @@ -10250,14 +10267,20 @@ "maxLength": 255 }, "fk_relation_column_id": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" }, "fk_lookup_column_id": { - "type": "string", - "maxLength": 20 + + "$ref": "#/components/schemas/Id" } - } + }, + "required": [ + "uidt", + "title", + "fk_relation_column_id", + "fk_lookup_column_id" + ] }, "FormulaColumnReq": { "properties": { @@ -10402,6 +10425,11 @@ } ] }, + "Id": { + "type": "string", + "minLength": 1, + "maxLength": 20 + }, "Password": { "type": "string", "minLength": 8 @@ -10493,16 +10521,26 @@ "guest" ] } - } + }, + "required": [ + "email", + "roles" + ] }, "SharedBaseReq": { "type": "object", "properties": { - "uuid": { - "$ref": "#/components/schemas/StringOrNull" - }, "roles": { - "$ref": "#/components/schemas/StringOrNull" + "type": "string", + "enum": [ + "editor", + "viewer", + "commenter" + ] + }, + "password": { + "type": "string", + "minLength": 8 } } }, @@ -10510,10 +10548,15 @@ "type": "object", "properties": { "title": { - "type": "string" + "type": "string", + "maxLength": 45 }, "input": {} - } + }, + "required": [ + "title", + "input" + ] }, "PluginReq": { "type": "object", @@ -10523,6 +10566,46 @@ }, "input": {} } + }, + "ViewReq": { + "type": "object", + "properties": { + "order": { + "type": "number", + "minimum": 0, + "exclusiveMinimum": true + }, + "meta": { + "$ref": "#/components/schemas/Meta" + }, + "title": { + "type": "string", + "maxLength": 255 + }, + "show_system_fields": { + "$ref": "#/components/schemas/Bool" + }, + "lock_type": { + "type": "string", + "enum": [ + "collaborative", + "locked", + "personal" + ] + } + } + }, + "SharedViewReq":{ + "type": "object", + "properties": { + "password": { + "type": "string", + "minLength": 8 + }, + "meta": { + "$ref": "#/components/schemas/Meta" + } + } } }, "responses": {