Strengthen types of some endpoints
This commit is contained in:
parent
417040f2d5
commit
00359d8e06
|
@ -8,7 +8,7 @@ export const buildAIEndpoints = (API: BaseAPIClient): AIEndpoints => ({
|
||||||
/**
|
/**
|
||||||
* Generates a cron expression from a prompt
|
* Generates a cron expression from a prompt
|
||||||
*/
|
*/
|
||||||
generateCronExpression: async (prompt: string) => {
|
generateCronExpression: async prompt => {
|
||||||
return await API.post({
|
return await API.post({
|
||||||
url: "/api/ai/cron",
|
url: "/api/ai/cron",
|
||||||
body: { prompt },
|
body: { prompt },
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import { BaseAPIClient } from "./types"
|
import { BaseAPIClient } from "./types"
|
||||||
|
import { AnalyticsPingRequest } from "@budibase/types"
|
||||||
type AnalyticsPingRequest = {
|
|
||||||
source?: string
|
|
||||||
embedded?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AnalyticsEndpoints {
|
export interface AnalyticsEndpoints {
|
||||||
getAnalyticsStatus: () => Promise<{ enabled: boolean }>
|
getAnalyticsStatus: () => Promise<{ enabled: boolean }>
|
||||||
analyticsPing: (payload: AnalyticsPingRequest) => Promise<void>
|
analyticsPing: (
|
||||||
|
payload: Omit<AnalyticsPingRequest, "timezone">
|
||||||
|
) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildAnalyticsEndpoints = (
|
export const buildAnalyticsEndpoints = (
|
||||||
|
@ -21,14 +19,17 @@ export const buildAnalyticsEndpoints = (
|
||||||
url: "/api/bbtel",
|
url: "/api/bbtel",
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifies analytics of a certain environment
|
* Notifies analytics of a certain environment
|
||||||
*/
|
*/
|
||||||
analyticsPing: async (payload: AnalyticsPingRequest) => {
|
analyticsPing: async request => {
|
||||||
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
|
return await API.post<AnalyticsPingRequest>({
|
||||||
return await API.post({
|
|
||||||
url: "/api/bbtel/ping",
|
url: "/api/bbtel/ping",
|
||||||
body: { source: payload.source, embedded: payload.embedded, timezone },
|
body: {
|
||||||
|
...request,
|
||||||
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -234,7 +234,7 @@ export const buildAppEndpoints = (API: BaseAPIClient): AppEndpoints => ({
|
||||||
/**
|
/**
|
||||||
* Fetches the definitions for component library components. This includes
|
* Fetches the definitions for component library components. This includes
|
||||||
* their props and other metadata from components.json.
|
* their props and other metadata from components.json.
|
||||||
* @param {string} appId - ID of the currently running app
|
* @param appId ID of the currently running app
|
||||||
*/
|
*/
|
||||||
fetchComponentLibDefinitions: async appId => {
|
fetchComponentLibDefinitions: async appId => {
|
||||||
return await API.get({
|
return await API.get({
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
import {
|
||||||
|
LoginRequest,
|
||||||
|
PasswordResetRequest,
|
||||||
|
PasswordResetUpdateRequest,
|
||||||
|
} from "@budibase/types"
|
||||||
import { BaseAPIClient } from "./types"
|
import { BaseAPIClient } from "./types"
|
||||||
|
|
||||||
export interface AuthEndpoints {
|
export interface AuthEndpoints {
|
||||||
|
@ -26,7 +31,7 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
||||||
* @param password the password
|
* @param password the password
|
||||||
*/
|
*/
|
||||||
logIn: async (tenantId, username, password) => {
|
logIn: async (tenantId, username, password) => {
|
||||||
return await API.post({
|
return await API.post<LoginRequest>({
|
||||||
url: `/api/global/auth/${tenantId}/login`,
|
url: `/api/global/auth/${tenantId}/login`,
|
||||||
body: {
|
body: {
|
||||||
username,
|
username,
|
||||||
|
@ -70,7 +75,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({
|
return await API.post<PasswordResetRequest, { message: string }>({
|
||||||
url: `/api/global/auth/${tenantId}/reset`,
|
url: `/api/global/auth/${tenantId}/reset`,
|
||||||
body: {
|
body: {
|
||||||
email,
|
email,
|
||||||
|
@ -85,7 +90,7 @@ 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({
|
return await API.post<PasswordResetUpdateRequest, { message: string }>({
|
||||||
url: `/api/global/auth/${tenantId}/reset/update`,
|
url: `/api/global/auth/${tenantId}/reset/update`,
|
||||||
body: {
|
body: {
|
||||||
password,
|
password,
|
||||||
|
|
Loading…
Reference in New Issue