From 4de0373f71fb9fb1f08ab24189adf9166f206e86 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 20 Sep 2024 18:29:11 +0000 Subject: [PATCH] refactor: update swagger api and sdk methods --- packages/nc-gui/components/account/Token.vue | 3 ++- .../components/tabs/auth/ApiTokenManagement.vue | 2 +- packages/nocodb/src/schema/swagger-v2.json | 8 ++++---- packages/nocodb/src/schema/swagger.json | 14 +++++++------- packages/nocodb/src/services/org-tokens.service.ts | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/nc-gui/components/account/Token.vue b/packages/nc-gui/components/account/Token.vue index ec82567685..cbf49d9ed8 100644 --- a/packages/nc-gui/components/account/Token.vue +++ b/packages/nc-gui/components/account/Token.vue @@ -140,7 +140,8 @@ const isValidTokenName = ref(false) const deleteToken = async (token: string): Promise => { try { - await api.orgTokens.delete(token) + const id = allTokens.value.find((t) => t.token === token)?.id + await api.orgTokens.delete(id) // message.success(t('msg.success.tokenDeleted')) await loadTokens() diff --git a/packages/nc-gui/components/tabs/auth/ApiTokenManagement.vue b/packages/nc-gui/components/tabs/auth/ApiTokenManagement.vue index 35e12bb2a6..bc2f10b56e 100644 --- a/packages/nc-gui/components/tabs/auth/ApiTokenManagement.vue +++ b/packages/nc-gui/components/tabs/auth/ApiTokenManagement.vue @@ -67,7 +67,7 @@ const deleteToken = async () => { try { if (!base.value?.id || !selectedTokenData.value.token) return - await $api.apiToken.delete(base.value.id, selectedTokenData.value.token) + await $api.apiToken.delete(base.value.id, selectedTokenData.value.id) // Token deleted successfully message.success(t('msg.success.tokenDeleted')) diff --git a/packages/nocodb/src/schema/swagger-v2.json b/packages/nocodb/src/schema/swagger-v2.json index ebe7ae5ef3..8be7aca502 100644 --- a/packages/nocodb/src/schema/swagger-v2.json +++ b/packages/nocodb/src/schema/swagger-v2.json @@ -11544,7 +11544,7 @@ } ] }, - "/api/v2/meta/bases/{baseId}/api-tokens/{token}": { + "/api/v2/meta/bases/{baseId}/api-tokens/{tokenId}": { "delete": { "summary": "Delete API Token", "operationId": "api-token-delete", @@ -11594,12 +11594,12 @@ { "schema": { "type": "string", - "example": "DYh540o8hbWpUGdarekECKLdN5OhlgCUWutVJYX2" + "example": "DYh540o8hbWp" }, - "name": "token", + "name": "tokenId", "in": "path", "required": true, - "description": "API Token" + "description": "API Token ID" } ] }, diff --git a/packages/nocodb/src/schema/swagger.json b/packages/nocodb/src/schema/swagger.json index 621171a8a3..c0b31098db 100644 --- a/packages/nocodb/src/schema/swagger.json +++ b/packages/nocodb/src/schema/swagger.json @@ -819,16 +819,16 @@ "description": "Creat an organisation API token. Access with API tokens will be blocked." } }, - "/api/v1/tokens/{token}": { + "/api/v1/tokens/{tokenId}": { "parameters": [ { "schema": { "type": "string" }, - "name": "token", + "name": "tokenId", "in": "path", "required": true, - "description": "API Token" + "description": "API Token ID" } ], "delete": { @@ -16429,7 +16429,7 @@ } ] }, - "/api/v1/db/meta/projects/{baseId}/api-tokens/{token}": { + "/api/v1/db/meta/projects/{baseId}/api-tokens/{tokenId}": { "delete": { "summary": "Delete API Token", "operationId": "api-token-delete", @@ -16479,12 +16479,12 @@ { "schema": { "type": "string", - "example": "DYh540o8hbWpUGdarekECKLdN5OhlgCUWutVJYX2" + "example": "DYh540o8hbWpU" }, - "name": "token", + "name": "tokenId", "in": "path", "required": true, - "description": "API Token" + "description": "API Token ID" } ] }, diff --git a/packages/nocodb/src/services/org-tokens.service.ts b/packages/nocodb/src/services/org-tokens.service.ts index 4fd444a291..5872d882ea 100644 --- a/packages/nocodb/src/services/org-tokens.service.ts +++ b/packages/nocodb/src/services/org-tokens.service.ts @@ -73,7 +73,7 @@ export class OrgTokensService { const res = await ApiToken.delete(param.tokenId); this.appHooksService.emit(AppEvents.ORG_API_TOKEN_DELETE, { - tokenId: param.token, + tokenId: param.tokenId, userId: param.user?.id, req: param['req'], });