Update self endpoints

This commit is contained in:
Andrew Kingston 2024-12-10 13:00:51 +00:00
parent cee53540a4
commit 610133551e
No known key found for this signature in database
2 changed files with 9 additions and 12 deletions

View File

@ -5,7 +5,6 @@ import {
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface RouteEndpoints { export interface RouteEndpoints {
// Missing request or response types
fetchClientAppRoutes: () => Promise<FetchClientScreenRoutingResponse> fetchClientAppRoutes: () => Promise<FetchClientScreenRoutingResponse>
fetchAppRoutes: () => Promise<FetchScreenRoutingResponse> fetchAppRoutes: () => Promise<FetchScreenRoutingResponse>
} }

View File

@ -1,21 +1,19 @@
import { import {
ContextUser, AppSelfResponse,
FetchAPIKeyResponse,
GenerateAPIKeyResponse,
GetGlobalSelfResponse,
UpdateSelfRequest, UpdateSelfRequest,
UpdateSelfResponse, UpdateSelfResponse,
User,
} from "@budibase/types" } from "@budibase/types"
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface SelfEndpoints { export interface SelfEndpoints {
updateSelf: (user: UpdateSelfRequest) => Promise<UpdateSelfResponse> updateSelf: (user: UpdateSelfRequest) => Promise<UpdateSelfResponse>
generateAPIKey: () => Promise<string | undefined>
// Missing request or response types fetchDeveloperInfo: () => Promise<FetchAPIKeyResponse>
generateAPIKey: () => Promise<any> fetchBuilderSelf: () => Promise<GetGlobalSelfResponse>
fetchDeveloperInfo: () => Promise<any> fetchSelf: () => Promise<AppSelfResponse>
// There are flags and session attributes mixed in to the user
fetchBuilderSelf: () => Promise<User & { [key: string]: any }>
fetchSelf: () => Promise<(ContextUser | {}) & { [key: string]: any }>
} }
export const buildSelfEndpoints = (API: BaseAPIClient): SelfEndpoints => ({ export const buildSelfEndpoints = (API: BaseAPIClient): SelfEndpoints => ({
@ -24,7 +22,7 @@ export const buildSelfEndpoints = (API: BaseAPIClient): SelfEndpoints => ({
* assuming the user is a builder. * assuming the user is a builder.
*/ */
generateAPIKey: async () => { generateAPIKey: async () => {
const response = await API.post<null, any>({ const response = await API.post<null, GenerateAPIKeyResponse>({
url: "/api/global/self/api_key", url: "/api/global/self/api_key",
}) })
return response?.apiKey return response?.apiKey