Licensing API typing.

This commit is contained in:
mike12345567 2024-12-05 15:01:48 +00:00
parent cbab77ea24
commit c0df3e67b3
2 changed files with 10 additions and 3 deletions

View File

@ -1,5 +1,7 @@
// LICENSE KEY
import { QuotaUsage } from "../../../documents"
export interface ActivateLicenseKeyRequest {
licenseKey: string
}
@ -23,3 +25,5 @@ export interface GetOfflineLicenseTokenResponse {
export interface GetOfflineIdentifierResponse {
identifierBase64: string
}
export interface GetQuotaUsageResponse extends QuotaUsage {}

View File

@ -5,6 +5,7 @@ import {
GetLicenseKeyResponse,
GetOfflineIdentifierResponse,
GetOfflineLicenseTokenResponse,
GetQuotaUsageResponse,
UserCtx,
} from "@budibase/types"
@ -36,7 +37,7 @@ export async function deleteLicenseKey(ctx: UserCtx<void, void>) {
// OFFLINE LICENSE
export async function activateOfflineLicenseToken(
ctx: UserCtx<ActivateOfflineLicenseTokenRequest>
ctx: UserCtx<ActivateOfflineLicenseTokenRequest, void>
) {
const { offlineLicenseToken } = ctx.request.body
await licensing.offline.activateOfflineLicenseToken(offlineLicenseToken)
@ -70,14 +71,16 @@ export async function getOfflineLicenseIdentifier(
// LICENSES
export const refresh = async (ctx: any) => {
export const refresh = async (ctx: UserCtx<void, void>) => {
await licensing.cache.refresh()
ctx.status = 200
}
// USAGE
export const getQuotaUsage = async (ctx: any) => {
export const getQuotaUsage = async (
ctx: UserCtx<void, GetQuotaUsageResponse>
) => {
ctx.body = await quotas.getQuotaUsage()
ctx.status = 200
}