Browse Source

fix(swagger): type corrections

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3065/head
Pranav C 2 years ago
parent
commit
db9e029ca2
  1. 1
      packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue
  2. 2
      packages/nc-gui-v2/components/tabs/auth/UserManagement.vue
  3. 6
      packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue
  4. 4
      packages/nc-gui-v2/composables/useViewColumns.ts
  5. 5
      packages/nc-gui-v2/composables/useViews.ts
  6. 26
      packages/nocodb-sdk/src/lib/Api.ts
  7. 2
      packages/nocodb/src/lib/models/User.ts
  8. 82
      scripts/sdk/swagger.json
  9. 2
      scripts/sdk/templates/http-clients/axios-http-client.eta
  10. 2
      scripts/sdk/templates/http-clients/fetch-http-client.eta

1
packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue

@ -151,7 +151,6 @@ async function onRename(view: ViewType) {
} }
try { try {
// todo typing issues, order and id do not exist on all members of ViewTypes (Kanban, Gallery, Form, Grid)
await api.dbView.update(view.id!, { await api.dbView.update(view.id!, {
title: view.title, title: view.title,
order: view.order, order: view.order,

2
packages/nc-gui-v2/components/tabs/auth/UserManagement.vue

@ -39,7 +39,7 @@ const loadUsers = async (page = currentPage, limit = currentLimit) => {
if (!project.value?.id) return if (!project.value?.id) return
// TODO: Types of api is not correct // TODO: Types of api is not correct
const response = await $api.auth.projectUserList(project.value?.id, { const response: any = await $api.auth.projectUserList(project.value?.id, {
query: { query: {
limit, limit,
offset: searchText.value.length === 0 ? (page - 1) * limit : 0, offset: searchText.value.length === 0 ? (page - 1) * limit : 0,

6
packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue

@ -32,8 +32,7 @@ const loadBase = async () => {
try { try {
if (!project.value.id) return if (!project.value.id) return
// todo: result is missing roles in return-type const res = await $api.project.sharedBaseGet(project.value.id)
const res: any = await $api.project.sharedBaseGet(project.value.id)
base = { base = {
uuid: res.uuid, uuid: res.uuid,
url: res.url, url: res.url,
@ -50,8 +49,7 @@ const createShareBase = async (role = ShareBaseRole.Viewer) => {
try { try {
if (!project.value.id) return if (!project.value.id) return
// todo: returns void? const res = await $api.project.sharedBaseUpdate(project.value.id, {
const res: any = await $api.project.sharedBaseUpdate(project.value.id, {
roles: role, roles: role,
}) })

4
packages/nc-gui-v2/composables/useViewColumns.ts

@ -1,11 +1,11 @@
import { isSystemColumn } from 'nocodb-sdk' import { isSystemColumn } from 'nocodb-sdk'
import type { ColumnType, FormType, GalleryType, GridType, TableType } from 'nocodb-sdk' import type { ColumnType, FormType, GalleryType, GridType, TableType, ViewType } from 'nocodb-sdk'
import { watch } from 'vue' import { watch } from 'vue'
import type { ComputedRef, Ref } from 'vue' import type { ComputedRef, Ref } from 'vue'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
export function useViewColumns( export function useViewColumns(
view: Ref<(GridType | FormType | GalleryType) & { id?: string }> | undefined, view: Ref<ViewType> | undefined,
meta: ComputedRef<TableType>, meta: ComputedRef<TableType>,
isPublic = false, isPublic = false,
reloadData?: () => void, reloadData?: () => void,

5
packages/nc-gui-v2/composables/useViews.ts

@ -10,10 +10,9 @@ export function useViews(meta: MaybeRef<TableType | undefined>) {
const _meta = unref(meta) const _meta = unref(meta)
if (_meta && _meta.id) { if (_meta && _meta.id) {
// todo: swagger type correction const response = (await $api.dbView.list(_meta.id)).list
const response = (await $api.dbView.list(_meta.id)).list as any[]
if (response) { if (response) {
views = response.sort((a, b) => a.order - b.order) views = response.sort((a, b) => a.order! - b.order!)
} }
} }
} }

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

@ -11,13 +11,16 @@
export interface UserType { export interface UserType {
/** Unique identifier for the given user. */ /** Unique identifier for the given user. */
id: number; id: string;
firstname: string; firstname: string;
lastname: string; lastname: string;
/** @format email */ /** @format email */
email: string; email: string;
/** @format email */
roles?: string;
/** /**
* @format date * @format date
* @example 1997-10-31 * @example 1997-10-31
@ -127,6 +130,7 @@ export interface ViewType {
order?: number; order?: number;
fk_model_id?: string; fk_model_id?: string;
slug?: string; slug?: string;
show_system_fields?: boolean;
lock_type?: 'collaborative' | 'locked' | 'personal'; lock_type?: 'collaborative' | 'locked' | 'personal';
} }
@ -436,7 +440,7 @@ export interface SharedViewListType {
} }
export interface ViewListType { export interface ViewListType {
list?: GridType | FormType | KanbanType | GalleryType; list?: ViewType[];
pageInfo?: PaginatedType; pageInfo?: PaginatedType;
} }
@ -661,10 +665,7 @@ export interface FullRequestParams
body?: unknown; body?: unknown;
} }
export type RequestParams = Omit< export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'path'>;
FullRequestParams,
'body' | 'method' | 'query' | 'path'
>;
export interface ApiConfig<SecurityDataType = unknown> export interface ApiConfig<SecurityDataType = unknown>
extends Omit<AxiosRequestConfig, 'data' | 'cancelToken'> { extends Omit<AxiosRequestConfig, 'data' | 'cancelToken'> {
@ -1271,10 +1272,10 @@ export class Api<
* @tags Project * @tags Project
* @name SharedBaseGet * @name SharedBaseGet
* @request GET:/api/v1/db/meta/projects/{projectId}/shared * @request GET:/api/v1/db/meta/projects/{projectId}/shared
* @response `200` `{ uuid?: string, url?: string }` OK * @response `200` `{ uuid?: string, url?: string, roles?: string }` OK
*/ */
sharedBaseGet: (projectId: string, params: RequestParams = {}) => sharedBaseGet: (projectId: string, params: RequestParams = {}) =>
this.request<{ uuid?: string; url?: string }, any>({ this.request<{ uuid?: string; url?: string; roles?: string }, any>({
path: `/api/v1/db/meta/projects/${projectId}/shared`, path: `/api/v1/db/meta/projects/${projectId}/shared`,
method: 'GET', method: 'GET',
format: 'json', format: 'json',
@ -1302,14 +1303,14 @@ export class Api<
* @tags Project * @tags Project
* @name SharedBaseCreate * @name SharedBaseCreate
* @request POST:/api/v1/db/meta/projects/{projectId}/shared * @request POST:/api/v1/db/meta/projects/{projectId}/shared
* @response `200` `{ url?: string, uuid?: string }` OK * @response `200` `{ uuid?: string, url?: string, roles?: string }` OK
*/ */
sharedBaseCreate: ( sharedBaseCreate: (
projectId: string, projectId: string,
data: { roles?: string; password?: string }, data: { roles?: string; password?: string },
params: RequestParams = {} params: RequestParams = {}
) => ) =>
this.request<{ url?: string; uuid?: string }, any>({ this.request<{ uuid?: string; url?: string; roles?: string }, any>({
path: `/api/v1/db/meta/projects/${projectId}/shared`, path: `/api/v1/db/meta/projects/${projectId}/shared`,
method: 'POST', method: 'POST',
body: data, body: data,
@ -1324,18 +1325,19 @@ export class Api<
* @tags Project * @tags Project
* @name SharedBaseUpdate * @name SharedBaseUpdate
* @request PATCH:/api/v1/db/meta/projects/{projectId}/shared * @request PATCH:/api/v1/db/meta/projects/{projectId}/shared
* @response `200` `void` OK * @response `200` `{ uuid?: string, url?: string, roles?: string }` OK
*/ */
sharedBaseUpdate: ( sharedBaseUpdate: (
projectId: string, projectId: string,
data: { roles?: string; password?: string }, data: { roles?: string; password?: string },
params: RequestParams = {} params: RequestParams = {}
) => ) =>
this.request<void, any>({ this.request<{ uuid?: string; url?: string; roles?: string }, any>({
path: `/api/v1/db/meta/projects/${projectId}/shared`, path: `/api/v1/db/meta/projects/${projectId}/shared`,
method: 'PATCH', method: 'PATCH',
body: data, body: data,
type: ContentType.Json, type: ContentType.Json,
format: 'json',
...params, ...params,
}), }),

2
packages/nocodb/src/lib/models/User.ts

@ -4,7 +4,7 @@ import Noco from '../Noco';
import extractProps from '../meta/helpers/extractProps'; import extractProps from '../meta/helpers/extractProps';
import NocoCache from '../cache/NocoCache'; import NocoCache from '../cache/NocoCache';
export default class User implements UserType { export default class User implements UserType {
id: number; id: string;
/** @format email */ /** @format email */
email: string; email: string;

82
scripts/sdk/swagger.json

@ -916,6 +916,9 @@
}, },
"url": { "url": {
"type": "string" "type": "string"
},
"roles": {
"type": "string"
} }
} }
} }
@ -939,25 +942,27 @@
"post": { "post": {
"summary": "", "summary": "",
"operationId": "project-shared-base-create", "operationId": "project-shared-base-create",
"responses": { "responses": { "200": {
"200": { "description": "OK",
"description": "OK", "content": {
"content": { "application/json": {
"application/json": { "schema": {
"schema": { "type": "object",
"type": "object", "properties": {
"properties": { "uuid": {
"url": { "type": "string"
"type": "string" },
}, "url": {
"uuid": { "type": "string"
"type": "string" },
} "roles": {
"type": "string"
} }
} }
} }
} }
} }
}
}, },
"tags": [ "tags": [
"Project" "Project"
@ -985,7 +990,25 @@
"operationId": "project-shared-base-update", "operationId": "project-shared-base-update",
"responses": { "responses": {
"200": { "200": {
"description": "OK" "description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"uuid": {
"type": "string"
},
"url": {
"type": "string"
},
"roles": {
"type": "string"
}
}
}
}
}
} }
}, },
"requestBody": { "requestBody": {
@ -5444,7 +5467,7 @@
"description": "", "description": "",
"examples": [ "examples": [
{ {
"id": 142, "id": "142",
"firstName": "Alice", "firstName": "Alice",
"lastName": "Smith", "lastName": "Smith",
"email": "alice.smith@gmail.com", "email": "alice.smith@gmail.com",
@ -5456,7 +5479,7 @@
"x-internal": false, "x-internal": false,
"properties": { "properties": {
"id": { "id": {
"type": "integer", "type": "string",
"description": "Unique identifier for the given user." "description": "Unique identifier for the given user."
}, },
"firstname": { "firstname": {
@ -5469,6 +5492,10 @@
"type": "string", "type": "string",
"format": "email" "format": "email"
}, },
"roles": {
"type": "string",
"format": "email"
},
"date_of_birth": { "date_of_birth": {
"type": "string", "type": "string",
"format": "date", "format": "date",
@ -6026,6 +6053,9 @@
"slug": { "slug": {
"type": "string" "type": "string"
}, },
"show_system_fields": {
"type": "boolean"
},
"lock_type": { "lock_type": {
"type": "string", "type": "string",
"enum": [ "enum": [
@ -7356,20 +7386,10 @@
}, },
"properties": { "properties": {
"list": { "list": {
"oneOf": [ "type": "array",
{ "items": {
"$ref": "#/components/schemas/Grid" "$ref": "#/components/schemas/View"
}, }
{
"$ref": "#/components/schemas/Form"
},
{
"$ref": "#/components/schemas/Kanban"
},
{
"$ref": "#/components/schemas/Gallery"
}
]
}, },
"pageInfo": { "pageInfo": {
"$ref": "#/components/schemas/Paginated" "$ref": "#/components/schemas/Paginated"

2
scripts/sdk/templates/http-clients/axios-http-client.eta

@ -23,7 +23,7 @@ export interface FullRequestParams extends Omit<AxiosRequestConfig, "data" | "pa
body?: unknown; body?: unknown;
} }
export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path">; export type RequestParams = Omit<FullRequestParams, "body" | "method" | "path">;
export interface ApiConfig<SecurityDataType = unknown> extends Omit<AxiosRequestConfig, "data" | "cancelToken"> { export interface ApiConfig<SecurityDataType = unknown> extends Omit<AxiosRequestConfig, "data" | "cancelToken"> {
securityWorker?: (securityData: SecurityDataType | null) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void; securityWorker?: (securityData: SecurityDataType | null) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;

2
scripts/sdk/templates/http-clients/fetch-http-client.eta

@ -24,7 +24,7 @@ export interface FullRequestParams extends Omit<RequestInit, "body"> {
cancelToken?: CancelToken; cancelToken?: CancelToken;
} }
export type RequestParams = Omit<FullRequestParams, "body" | "method" | "query" | "path"> export type RequestParams = Omit<FullRequestParams, "body" | "method" | "path">
export interface ApiConfig<SecurityDataType = unknown> { export interface ApiConfig<SecurityDataType = unknown> {

Loading…
Cancel
Save