Update attachment and auth endpoints
This commit is contained in:
parent
65f37e046e
commit
f20c07a146
|
@ -1,5 +1,7 @@
|
||||||
import {
|
import {
|
||||||
DownloadAttachmentResponse,
|
DownloadAttachmentResponse,
|
||||||
|
GetSignedUploadUrlRequest,
|
||||||
|
GetSignedUploadUrlResponse,
|
||||||
ProcessAttachmentResponse,
|
ProcessAttachmentResponse,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { BaseAPIClient } from "./types"
|
import { BaseAPIClient } from "./types"
|
||||||
|
@ -10,13 +12,11 @@ export interface AttachmentEndpoints {
|
||||||
rowId: string,
|
rowId: string,
|
||||||
columnName: string
|
columnName: string
|
||||||
) => Promise<DownloadAttachmentResponse>
|
) => Promise<DownloadAttachmentResponse>
|
||||||
|
|
||||||
// Missing request or response types
|
|
||||||
getSignedDatasourceURL: (
|
getSignedDatasourceURL: (
|
||||||
datasourceId: string,
|
datasourceId: string,
|
||||||
bucket: string,
|
bucket: string,
|
||||||
key: string
|
key: string
|
||||||
) => Promise<{ signedUrl: string; publicUrl: string }>
|
) => Promise<GetSignedUploadUrlResponse>
|
||||||
uploadAttachment: (
|
uploadAttachment: (
|
||||||
tableId: string,
|
tableId: string,
|
||||||
data: any
|
data: any
|
||||||
|
@ -41,7 +41,10 @@ export const buildAttachmentEndpoints = (
|
||||||
* @param key the name of the file to upload to
|
* @param key the name of the file to upload to
|
||||||
*/
|
*/
|
||||||
getSignedDatasourceURL: async (datasourceId, bucket, key) => {
|
getSignedDatasourceURL: async (datasourceId, bucket, key) => {
|
||||||
return await API.post({
|
return await API.post<
|
||||||
|
GetSignedUploadUrlRequest,
|
||||||
|
GetSignedUploadUrlResponse
|
||||||
|
>({
|
||||||
url: `/api/attachments/${datasourceId}/url`,
|
url: `/api/attachments/${datasourceId}/url`,
|
||||||
body: { bucket, key },
|
body: { bucket, key },
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,26 +1,29 @@
|
||||||
import {
|
import {
|
||||||
|
GetInitInfoResponse,
|
||||||
LoginRequest,
|
LoginRequest,
|
||||||
|
LogoutResponse,
|
||||||
PasswordResetRequest,
|
PasswordResetRequest,
|
||||||
|
PasswordResetResponse,
|
||||||
PasswordResetUpdateRequest,
|
PasswordResetUpdateRequest,
|
||||||
|
PasswordResetUpdateResponse,
|
||||||
|
SetInitInfoRequest,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { BaseAPIClient } from "./types"
|
import { BaseAPIClient } from "./types"
|
||||||
|
|
||||||
export interface AuthEndpoints {
|
export interface AuthEndpoints {
|
||||||
logIn: (tenantId: string, username: string, password: string) => Promise<void>
|
logIn: (tenantId: string, username: string, password: string) => Promise<void>
|
||||||
|
logOut: () => Promise<LogoutResponse>
|
||||||
// Missing request or response types
|
|
||||||
logOut: () => Promise<{ message: string }>
|
|
||||||
requestForgotPassword: (
|
requestForgotPassword: (
|
||||||
tenantId: string,
|
tenantId: string,
|
||||||
email: string
|
email: string
|
||||||
) => Promise<{ message: string }>
|
) => Promise<PasswordResetResponse>
|
||||||
resetPassword: (
|
resetPassword: (
|
||||||
tenantId: string,
|
tenantId: string,
|
||||||
password: string,
|
password: string,
|
||||||
resetCode: string
|
resetCode: string
|
||||||
) => Promise<{ message: string }>
|
) => Promise<PasswordResetUpdateResponse>
|
||||||
setInitInfo: (info: any) => Promise<void>
|
setInitInfo: (info: SetInitInfoRequest) => Promise<void>
|
||||||
getInitInfo: () => Promise<any>
|
getInitInfo: () => Promise<GetInitInfoResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
||||||
|
@ -75,7 +78,7 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
||||||
* @param email the email address of the user
|
* @param email the email address of the user
|
||||||
*/
|
*/
|
||||||
requestForgotPassword: async (tenantId, email) => {
|
requestForgotPassword: async (tenantId, email) => {
|
||||||
return await API.post<PasswordResetRequest, { message: string }>({
|
return await API.post<PasswordResetRequest, PasswordResetResponse>({
|
||||||
url: `/api/global/auth/${tenantId}/reset`,
|
url: `/api/global/auth/${tenantId}/reset`,
|
||||||
body: {
|
body: {
|
||||||
email,
|
email,
|
||||||
|
@ -90,7 +93,10 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
||||||
* @param resetCode the reset code to authenticate the request
|
* @param resetCode the reset code to authenticate the request
|
||||||
*/
|
*/
|
||||||
resetPassword: async (tenantId, password, resetCode) => {
|
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`,
|
url: `/api/global/auth/${tenantId}/reset/update`,
|
||||||
body: {
|
body: {
|
||||||
password,
|
password,
|
||||||
|
|
Loading…
Reference in New Issue