Update attachment and auth endpoints

This commit is contained in:
Andrew Kingston 2024-12-10 12:47:27 +00:00
parent 65f37e046e
commit f20c07a146
No known key found for this signature in database
2 changed files with 22 additions and 13 deletions

View File

@ -1,5 +1,7 @@
import {
DownloadAttachmentResponse,
GetSignedUploadUrlRequest,
GetSignedUploadUrlResponse,
ProcessAttachmentResponse,
} from "@budibase/types"
import { BaseAPIClient } from "./types"
@ -10,13 +12,11 @@ export interface AttachmentEndpoints {
rowId: string,
columnName: string
) => Promise<DownloadAttachmentResponse>
// Missing request or response types
getSignedDatasourceURL: (
datasourceId: string,
bucket: string,
key: string
) => Promise<{ signedUrl: string; publicUrl: string }>
) => Promise<GetSignedUploadUrlResponse>
uploadAttachment: (
tableId: string,
data: any
@ -41,7 +41,10 @@ export const buildAttachmentEndpoints = (
* @param key the name of the file to upload to
*/
getSignedDatasourceURL: async (datasourceId, bucket, key) => {
return await API.post({
return await API.post<
GetSignedUploadUrlRequest,
GetSignedUploadUrlResponse
>({
url: `/api/attachments/${datasourceId}/url`,
body: { bucket, key },
})

View File

@ -1,26 +1,29 @@
import {
GetInitInfoResponse,
LoginRequest,
LogoutResponse,
PasswordResetRequest,
PasswordResetResponse,
PasswordResetUpdateRequest,
PasswordResetUpdateResponse,
SetInitInfoRequest,
} from "@budibase/types"
import { BaseAPIClient } from "./types"
export interface AuthEndpoints {
logIn: (tenantId: string, username: string, password: string) => Promise<void>
// Missing request or response types
logOut: () => Promise<{ message: string }>
logOut: () => Promise<LogoutResponse>
requestForgotPassword: (
tenantId: string,
email: string
) => Promise<{ message: string }>
) => Promise<PasswordResetResponse>
resetPassword: (
tenantId: string,
password: string,
resetCode: string
) => Promise<{ message: string }>
setInitInfo: (info: any) => Promise<void>
getInitInfo: () => Promise<any>
) => Promise<PasswordResetUpdateResponse>
setInitInfo: (info: SetInitInfoRequest) => Promise<void>
getInitInfo: () => Promise<GetInitInfoResponse>
}
export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
@ -75,7 +78,7 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
* @param email the email address of the user
*/
requestForgotPassword: async (tenantId, email) => {
return await API.post<PasswordResetRequest, { message: string }>({
return await API.post<PasswordResetRequest, PasswordResetResponse>({
url: `/api/global/auth/${tenantId}/reset`,
body: {
email,
@ -90,7 +93,10 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
* @param resetCode the reset code to authenticate the request
*/
resetPassword: async (tenantId, password, resetCode) => {
return await API.post<PasswordResetUpdateRequest, { message: string }>({
return await API.post<
PasswordResetUpdateRequest,
PasswordResetUpdateResponse
>({
url: `/api/global/auth/${tenantId}/reset/update`,
body: {
password,