Update more endpoints with new response messages

This commit is contained in:
Andrew Kingston 2024-12-16 17:08:42 +00:00
parent 22d8994431
commit 4b499ca487
No known key found for this signature in database
4 changed files with 37 additions and 16 deletions

View File

@ -1,11 +1,15 @@
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
import { AnalyticsEnabledResponse, AnalyticsPingRequest } from "@budibase/types" import {
AnalyticsEnabledResponse,
AnalyticsPingRequest,
AnalyticsPingResponse,
} from "@budibase/types"
export interface AnalyticsEndpoints { export interface AnalyticsEndpoints {
getAnalyticsStatus: () => Promise<AnalyticsEnabledResponse> getAnalyticsStatus: () => Promise<AnalyticsEnabledResponse>
analyticsPing: ( analyticsPing: (
payload: Omit<AnalyticsPingRequest, "timezone"> payload: Omit<AnalyticsPingRequest, "timezone">
) => Promise<void> ) => Promise<AnalyticsPingResponse>
} }
export const buildAnalyticsEndpoints = ( export const buildAnalyticsEndpoints = (
@ -24,13 +28,12 @@ export const buildAnalyticsEndpoints = (
* Notifies analytics of a certain environment * Notifies analytics of a certain environment
*/ */
analyticsPing: async request => { analyticsPing: async request => {
return await API.post<AnalyticsPingRequest>({ return await API.post<AnalyticsPingRequest, AnalyticsPingResponse>({
url: "/api/bbtel/ping", url: "/api/bbtel/ping",
body: { body: {
...request, ...request,
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
}, },
parseResponse: () => undefined,
}) })
}, },
}) })

View File

@ -1,8 +1,11 @@
import { import {
CreateEnvironmentVariableRequest, CreateEnvironmentVariableRequest,
CreateEnvironmentVariableResponse,
DeleteEnvironmentVariablesResponse,
GetEnvironmentVariablesResponse, GetEnvironmentVariablesResponse,
StatusEnvironmentVariableResponse, StatusEnvironmentVariableResponse,
UpdateEnvironmentVariableRequest, UpdateEnvironmentVariableRequest,
UpdateEnvironmentVariableResponse,
} from "@budibase/types" } from "@budibase/types"
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
@ -11,12 +14,14 @@ export interface EnvironmentVariableEndpoints {
fetchEnvironmentVariables: () => Promise<GetEnvironmentVariablesResponse> fetchEnvironmentVariables: () => Promise<GetEnvironmentVariablesResponse>
createEnvironmentVariable: ( createEnvironmentVariable: (
data: CreateEnvironmentVariableRequest data: CreateEnvironmentVariableRequest
) => Promise<void> ) => Promise<CreateEnvironmentVariableResponse>
deleteEnvironmentVariable: (name: string) => Promise<void> deleteEnvironmentVariable: (
name: string
) => Promise<DeleteEnvironmentVariablesResponse>
updateEnvironmentVariable: ( updateEnvironmentVariable: (
name: string, name: string,
data: UpdateEnvironmentVariableRequest data: UpdateEnvironmentVariableRequest
) => Promise<void> ) => Promise<UpdateEnvironmentVariableResponse>
} }
export const buildEnvironmentVariableEndpoints = ( export const buildEnvironmentVariableEndpoints = (

View File

@ -1,13 +1,17 @@
import { EventPublishType, PostEventPublishRequest } from "@budibase/types" import {
EventPublishType,
PostEventPublishRequest,
PostEventPublishResponse,
} from "@budibase/types"
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface EventEndpoints { export interface EventEndpoints {
publishEvent: (type: EventPublishType) => Promise<void> publishEvent: (type: EventPublishType) => Promise<PostEventPublishResponse>
} }
export const buildEventEndpoints = (API: BaseAPIClient): EventEndpoints => ({ export const buildEventEndpoints = (API: BaseAPIClient): EventEndpoints => ({
publishEvent: async type => { publishEvent: async type => {
return await API.post<PostEventPublishRequest>({ return await API.post<PostEventPublishRequest, PostEventPublishResponse>({
url: `/api/global/event/publish`, url: `/api/global/event/publish`,
body: { body: {
type, type,

View File

@ -1,22 +1,29 @@
import { import {
ActivateLicenseKeyRequest, ActivateLicenseKeyRequest,
ActivateLicenseKeyResponse,
ActivateOfflineLicenseTokenRequest, ActivateOfflineLicenseTokenRequest,
ActivateOfflineLicenseTokenResponse,
GetLicenseKeyResponse, GetLicenseKeyResponse,
GetOfflineIdentifierResponse, GetOfflineIdentifierResponse,
GetOfflineLicenseTokenResponse, GetOfflineLicenseTokenResponse,
QuotaUsage, QuotaUsage,
RefreshOfflineLicenseResponse,
} from "@budibase/types" } from "@budibase/types"
import { BaseAPIClient } from "./types" import { BaseAPIClient } from "./types"
export interface LicensingEndpoints { export interface LicensingEndpoints {
activateLicenseKey: (licenseKey: string) => Promise<void> activateLicenseKey: (
licenseKey: string
) => Promise<ActivateLicenseKeyResponse>
deleteLicenseKey: () => Promise<void> deleteLicenseKey: () => Promise<void>
getLicenseKey: () => Promise<GetLicenseKeyResponse | void> getLicenseKey: () => Promise<GetLicenseKeyResponse | void>
activateOfflineLicense: (offlineLicenseToken: string) => Promise<void> activateOfflineLicense: (
offlineLicenseToken: string
) => Promise<ActivateOfflineLicenseTokenResponse>
deleteOfflineLicense: () => Promise<void> deleteOfflineLicense: () => Promise<void>
getOfflineLicense: () => Promise<GetOfflineLicenseTokenResponse | void> getOfflineLicense: () => Promise<GetOfflineLicenseTokenResponse | void>
getOfflineLicenseIdentifier: () => Promise<GetOfflineIdentifierResponse> getOfflineLicenseIdentifier: () => Promise<GetOfflineIdentifierResponse>
refreshLicense: () => Promise<void> refreshLicense: () => Promise<RefreshOfflineLicenseResponse>
getQuotaUsage: () => Promise<QuotaUsage> getQuotaUsage: () => Promise<QuotaUsage>
} }
@ -25,7 +32,7 @@ export const buildLicensingEndpoints = (
): LicensingEndpoints => ({ ): LicensingEndpoints => ({
// LICENSE KEY // LICENSE KEY
activateLicenseKey: async licenseKey => { activateLicenseKey: async licenseKey => {
return API.post<ActivateLicenseKeyRequest>({ return API.post<ActivateLicenseKeyRequest, ActivateLicenseKeyResponse>({
url: `/api/global/license/key`, url: `/api/global/license/key`,
body: { licenseKey }, body: { licenseKey },
}) })
@ -49,7 +56,10 @@ export const buildLicensingEndpoints = (
// OFFLINE LICENSE // OFFLINE LICENSE
activateOfflineLicense: async offlineLicenseToken => { activateOfflineLicense: async offlineLicenseToken => {
return API.post<ActivateOfflineLicenseTokenRequest>({ return API.post<
ActivateOfflineLicenseTokenRequest,
ActivateOfflineLicenseTokenResponse
>({
url: "/api/global/license/offline", url: "/api/global/license/offline",
body: { body: {
offlineLicenseToken, offlineLicenseToken,
@ -84,7 +94,6 @@ export const buildLicensingEndpoints = (
refreshLicense: async () => { refreshLicense: async () => {
return API.post({ return API.post({
url: "/api/global/license/refresh", url: "/api/global/license/refresh",
parseResponse: () => undefined,
}) })
}, },
/** /**