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 {
// todo typing issues, order and id do not exist on all members of ViewTypes (Kanban, Gallery, Form, Grid)
await api.dbView.update(view.id!, {
title: view.title,
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
// 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: {
limit,
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 {
if (!project.value.id) return
// todo: result is missing roles in return-type
const res: any = await $api.project.sharedBaseGet(project.value.id)
const res = await $api.project.sharedBaseGet(project.value.id)
base = {
uuid: res.uuid,
url: res.url,
@ -50,8 +49,7 @@ const createShareBase = async (role = ShareBaseRole.Viewer) => {
try {
if (!project.value.id) return
// todo: returns void?
const res: any = await $api.project.sharedBaseUpdate(project.value.id, {
const res = await $api.project.sharedBaseUpdate(project.value.id, {
roles: role,
})

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

@ -1,11 +1,11 @@
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 type { ComputedRef, Ref } from 'vue'
import { useNuxtApp } from '#app'
export function useViewColumns(
view: Ref<(GridType | FormType | GalleryType) & { id?: string }> | undefined,
view: Ref<ViewType> | undefined,
meta: ComputedRef<TableType>,
isPublic = false,
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)
if (_meta && _meta.id) {
// todo: swagger type correction
const response = (await $api.dbView.list(_meta.id)).list as any[]
const response = (await $api.dbView.list(_meta.id)).list
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 {
/** Unique identifier for the given user. */
id: number;
id: string;
firstname: string;
lastname: string;
/** @format email */
email: string;
/** @format email */
roles?: string;
/**
* @format date
* @example 1997-10-31
@ -127,6 +130,7 @@ export interface ViewType {
order?: number;
fk_model_id?: string;
slug?: string;
show_system_fields?: boolean;
lock_type?: 'collaborative' | 'locked' | 'personal';
}
@ -436,7 +440,7 @@ export interface SharedViewListType {
}
export interface ViewListType {
list?: GridType | FormType | KanbanType | GalleryType;
list?: ViewType[];
pageInfo?: PaginatedType;
}
@ -661,10 +665,7 @@ export interface FullRequestParams
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'> {
@ -1271,10 +1272,10 @@ export class Api<
* @tags Project
* @name SharedBaseGet
* @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 = {}) =>
this.request<{ uuid?: string; url?: string }, any>({
this.request<{ uuid?: string; url?: string; roles?: string }, any>({
path: `/api/v1/db/meta/projects/${projectId}/shared`,
method: 'GET',
format: 'json',
@ -1302,14 +1303,14 @@ export class Api<
* @tags Project
* @name SharedBaseCreate
* @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: (
projectId: string,
data: { roles?: string; password?: string },
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`,
method: 'POST',
body: data,
@ -1324,18 +1325,19 @@ export class Api<
* @tags Project
* @name SharedBaseUpdate
* @request PATCH:/api/v1/db/meta/projects/{projectId}/shared
* @response `200` `void` OK
* @response `200` `{ uuid?: string, url?: string, roles?: string }` OK
*/
sharedBaseUpdate: (
projectId: string,
data: { roles?: string; password?: string },
params: RequestParams = {}
) =>
this.request<void, any>({
this.request<{ uuid?: string; url?: string; roles?: string }, any>({
path: `/api/v1/db/meta/projects/${projectId}/shared`,
method: 'PATCH',
body: data,
type: ContentType.Json,
format: 'json',
...params,
}),

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

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

82
scripts/sdk/swagger.json

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

Loading…
Cancel
Save