From 4b499ca4870f0f8c68c7b2f5b9fea72b2e247459 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 16 Dec 2024 17:08:42 +0000 Subject: [PATCH] Update more endpoints with new response messages --- packages/frontend-core/src/api/analytics.ts | 11 ++++++---- .../src/api/environmentVariables.ts | 11 +++++++--- packages/frontend-core/src/api/events.ts | 10 ++++++--- packages/frontend-core/src/api/licensing.ts | 21 +++++++++++++------ 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/packages/frontend-core/src/api/analytics.ts b/packages/frontend-core/src/api/analytics.ts index de0de802e1..b57a8e5925 100644 --- a/packages/frontend-core/src/api/analytics.ts +++ b/packages/frontend-core/src/api/analytics.ts @@ -1,11 +1,15 @@ import { BaseAPIClient } from "./types" -import { AnalyticsEnabledResponse, AnalyticsPingRequest } from "@budibase/types" +import { + AnalyticsEnabledResponse, + AnalyticsPingRequest, + AnalyticsPingResponse, +} from "@budibase/types" export interface AnalyticsEndpoints { getAnalyticsStatus: () => Promise analyticsPing: ( payload: Omit - ) => Promise + ) => Promise } export const buildAnalyticsEndpoints = ( @@ -24,13 +28,12 @@ export const buildAnalyticsEndpoints = ( * Notifies analytics of a certain environment */ analyticsPing: async request => { - return await API.post({ + return await API.post({ url: "/api/bbtel/ping", body: { ...request, timezone: Intl.DateTimeFormat().resolvedOptions().timeZone, }, - parseResponse: () => undefined, }) }, }) diff --git a/packages/frontend-core/src/api/environmentVariables.ts b/packages/frontend-core/src/api/environmentVariables.ts index ed7a284a4d..8dd2988c5f 100644 --- a/packages/frontend-core/src/api/environmentVariables.ts +++ b/packages/frontend-core/src/api/environmentVariables.ts @@ -1,8 +1,11 @@ import { CreateEnvironmentVariableRequest, + CreateEnvironmentVariableResponse, + DeleteEnvironmentVariablesResponse, GetEnvironmentVariablesResponse, StatusEnvironmentVariableResponse, UpdateEnvironmentVariableRequest, + UpdateEnvironmentVariableResponse, } from "@budibase/types" import { BaseAPIClient } from "./types" @@ -11,12 +14,14 @@ export interface EnvironmentVariableEndpoints { fetchEnvironmentVariables: () => Promise createEnvironmentVariable: ( data: CreateEnvironmentVariableRequest - ) => Promise - deleteEnvironmentVariable: (name: string) => Promise + ) => Promise + deleteEnvironmentVariable: ( + name: string + ) => Promise updateEnvironmentVariable: ( name: string, data: UpdateEnvironmentVariableRequest - ) => Promise + ) => Promise } export const buildEnvironmentVariableEndpoints = ( diff --git a/packages/frontend-core/src/api/events.ts b/packages/frontend-core/src/api/events.ts index 9e6cc40de3..2bec0ea680 100644 --- a/packages/frontend-core/src/api/events.ts +++ b/packages/frontend-core/src/api/events.ts @@ -1,13 +1,17 @@ -import { EventPublishType, PostEventPublishRequest } from "@budibase/types" +import { + EventPublishType, + PostEventPublishRequest, + PostEventPublishResponse, +} from "@budibase/types" import { BaseAPIClient } from "./types" export interface EventEndpoints { - publishEvent: (type: EventPublishType) => Promise + publishEvent: (type: EventPublishType) => Promise } export const buildEventEndpoints = (API: BaseAPIClient): EventEndpoints => ({ publishEvent: async type => { - return await API.post({ + return await API.post({ url: `/api/global/event/publish`, body: { type, diff --git a/packages/frontend-core/src/api/licensing.ts b/packages/frontend-core/src/api/licensing.ts index fd8ee36e83..bc499b92d4 100644 --- a/packages/frontend-core/src/api/licensing.ts +++ b/packages/frontend-core/src/api/licensing.ts @@ -1,22 +1,29 @@ import { ActivateLicenseKeyRequest, + ActivateLicenseKeyResponse, ActivateOfflineLicenseTokenRequest, + ActivateOfflineLicenseTokenResponse, GetLicenseKeyResponse, GetOfflineIdentifierResponse, GetOfflineLicenseTokenResponse, QuotaUsage, + RefreshOfflineLicenseResponse, } from "@budibase/types" import { BaseAPIClient } from "./types" export interface LicensingEndpoints { - activateLicenseKey: (licenseKey: string) => Promise + activateLicenseKey: ( + licenseKey: string + ) => Promise deleteLicenseKey: () => Promise getLicenseKey: () => Promise - activateOfflineLicense: (offlineLicenseToken: string) => Promise + activateOfflineLicense: ( + offlineLicenseToken: string + ) => Promise deleteOfflineLicense: () => Promise getOfflineLicense: () => Promise getOfflineLicenseIdentifier: () => Promise - refreshLicense: () => Promise + refreshLicense: () => Promise getQuotaUsage: () => Promise } @@ -25,7 +32,7 @@ export const buildLicensingEndpoints = ( ): LicensingEndpoints => ({ // LICENSE KEY activateLicenseKey: async licenseKey => { - return API.post({ + return API.post({ url: `/api/global/license/key`, body: { licenseKey }, }) @@ -49,7 +56,10 @@ export const buildLicensingEndpoints = ( // OFFLINE LICENSE activateOfflineLicense: async offlineLicenseToken => { - return API.post({ + return API.post< + ActivateOfflineLicenseTokenRequest, + ActivateOfflineLicenseTokenResponse + >({ url: "/api/global/license/offline", body: { offlineLicenseToken, @@ -84,7 +94,6 @@ export const buildLicensingEndpoints = ( refreshLicense: async () => { return API.post({ url: "/api/global/license/refresh", - parseResponse: () => undefined, }) }, /**