Merge branch 'master' into ts-portal-apps-store
This commit is contained in:
commit
018d332a7e
|
@ -30,7 +30,7 @@ env:
|
|||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
@ -47,7 +47,7 @@ jobs:
|
|||
- run: yarn lint
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
@ -76,7 +76,7 @@ jobs:
|
|||
fi
|
||||
|
||||
helm-lint:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
@ -88,7 +88,7 @@ jobs:
|
|||
- run: cd charts/budibase && helm lint .
|
||||
|
||||
test-libraries:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
@ -122,7 +122,7 @@ jobs:
|
|||
fi
|
||||
|
||||
test-worker:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v4
|
||||
|
@ -151,7 +151,7 @@ jobs:
|
|||
yarn test --verbose --reporters=default --reporters=github-actions
|
||||
|
||||
test-server:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
matrix:
|
||||
datasource:
|
||||
|
@ -237,7 +237,7 @@ jobs:
|
|||
yarn test --filter $FILTER --verbose --reporters=default --reporters=github-actions
|
||||
|
||||
check-pro-submodule:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
if: inputs.run_as_oss != true && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase')
|
||||
steps:
|
||||
- name: Checkout repo and submodules
|
||||
|
@ -296,7 +296,7 @@ jobs:
|
|||
fi
|
||||
|
||||
check-lockfile:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-22.04
|
||||
if: inputs.run_as_oss != true && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'Budibase/budibase')
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||
"version": "3.2.28",
|
||||
"version": "3.2.29",
|
||||
"npmClient": "yarn",
|
||||
"concurrency": 20,
|
||||
"command": {
|
||||
|
|
|
@ -43,12 +43,11 @@
|
|||
flex-direction: row;
|
||||
justify-content: flex-start;
|
||||
align-items: stretch;
|
||||
overflow-y: scroll !important;
|
||||
flex: 1 1 auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.main {
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
}
|
||||
|
||||
try {
|
||||
const app = await API.duplicateApp(data, appId)
|
||||
const app = await API.duplicateApp(appId, data)
|
||||
appsStore.load()
|
||||
if (!sdk.users.isBuilder($auth.user, app?.duplicateAppId)) {
|
||||
// Refresh for access to created applications
|
||||
|
|
|
@ -61,7 +61,7 @@ a {
|
|||
height: 8px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--spectrum-alias-background-color-default);
|
||||
background: transparent;
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background-color: var(--spectrum-global-color-gray-400);
|
||||
|
@ -71,6 +71,5 @@ a {
|
|||
background: var(--spectrum-alias-background-color-default);
|
||||
}
|
||||
html * {
|
||||
scrollbar-color: var(--spectrum-global-color-gray-400)
|
||||
var(--spectrum-alias-background-color-default);
|
||||
scrollbar-color: var(--spectrum-global-color-gray-400) transparent;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ export function createPluginsStore() {
|
|||
const { subscribe, set, update } = writable<Plugin[]>([])
|
||||
|
||||
async function load() {
|
||||
const plugins = (await API.getPlugins()) as Plugin[]
|
||||
const plugins: Plugin[] = await API.getPlugins()
|
||||
set(plugins)
|
||||
}
|
||||
|
||||
|
|
|
@ -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<AnalyticsEnabledResponse>
|
||||
analyticsPing: (
|
||||
payload: Omit<AnalyticsPingRequest, "timezone">
|
||||
) => Promise<void>
|
||||
) => Promise<AnalyticsPingResponse>
|
||||
}
|
||||
|
||||
export const buildAnalyticsEndpoints = (
|
||||
|
@ -24,13 +28,12 @@ export const buildAnalyticsEndpoints = (
|
|||
* Notifies analytics of a certain environment
|
||||
*/
|
||||
analyticsPing: async request => {
|
||||
return await API.post<AnalyticsPingRequest>({
|
||||
return await API.post<AnalyticsPingRequest, AnalyticsPingResponse>({
|
||||
url: "/api/bbtel/ping",
|
||||
body: {
|
||||
...request,
|
||||
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
||||
},
|
||||
parseResponse: () => undefined,
|
||||
})
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { sdk } from "@budibase/shared-core"
|
||||
import { BaseAPIClient } from "./types"
|
||||
import {
|
||||
AddAppSampleDataResponse,
|
||||
ClearDevLockResponse,
|
||||
CreateAppRequest,
|
||||
CreateAppResponse,
|
||||
|
@ -18,7 +19,9 @@ import {
|
|||
RevertAppClientResponse,
|
||||
RevertAppResponse,
|
||||
SetRevertableAppVersionRequest,
|
||||
SetRevertableAppVersionResponse,
|
||||
SyncAppResponse,
|
||||
UnpublishAppResponse,
|
||||
UpdateAppClientResponse,
|
||||
UpdateAppRequest,
|
||||
UpdateAppResponse,
|
||||
|
@ -30,7 +33,7 @@ export interface AppEndpoints {
|
|||
appId: string,
|
||||
metadata: UpdateAppRequest
|
||||
) => Promise<UpdateAppResponse>
|
||||
unpublishApp: (appId: string) => Promise<void>
|
||||
unpublishApp: (appId: string) => Promise<UnpublishAppResponse>
|
||||
publishAppChanges: (appId: string) => Promise<PublishAppResponse>
|
||||
revertAppChanges: (appId: string) => Promise<RevertAppResponse>
|
||||
updateAppClientVersion: (appId: string) => Promise<UpdateAppClientResponse>
|
||||
|
@ -56,8 +59,8 @@ export interface AppEndpoints {
|
|||
setRevertableVersion: (
|
||||
appId: string,
|
||||
revertableVersion: string
|
||||
) => Promise<void>
|
||||
addSampleData: (appId: string) => Promise<void>
|
||||
) => Promise<SetRevertableAppVersionResponse>
|
||||
addSampleData: (appId: string) => Promise<AddAppSampleDataResponse>
|
||||
|
||||
// Missing request or response types
|
||||
importApps: (apps: any) => Promise<any>
|
||||
|
@ -272,7 +275,10 @@ export const buildAppEndpoints = (API: BaseAPIClient): AppEndpoints => ({
|
|||
* @param revertableVersion the version number
|
||||
*/
|
||||
setRevertableVersion: async (appId, revertableVersion) => {
|
||||
return await API.post<SetRevertableAppVersionRequest>({
|
||||
return await API.post<
|
||||
SetRevertableAppVersionRequest,
|
||||
SetRevertableAppVersionResponse
|
||||
>({
|
||||
url: `/api/applications/${appId}/setRevertableVersion`,
|
||||
body: {
|
||||
revertableVersion,
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
import {
|
||||
GetInitInfoResponse,
|
||||
LoginRequest,
|
||||
LoginResponse,
|
||||
LogoutResponse,
|
||||
PasswordResetRequest,
|
||||
PasswordResetResponse,
|
||||
PasswordResetUpdateRequest,
|
||||
PasswordResetUpdateResponse,
|
||||
SetInitInfoRequest,
|
||||
SetInitInfoResponse,
|
||||
} from "@budibase/types"
|
||||
import { BaseAPIClient } from "./types"
|
||||
|
||||
export interface AuthEndpoints {
|
||||
logIn: (tenantId: string, username: string, password: string) => Promise<void>
|
||||
logIn: (
|
||||
tenantId: string,
|
||||
username: string,
|
||||
password: string
|
||||
) => Promise<LoginResponse>
|
||||
logOut: () => Promise<LogoutResponse>
|
||||
requestForgotPassword: (
|
||||
tenantId: string,
|
||||
|
@ -22,7 +28,7 @@ export interface AuthEndpoints {
|
|||
password: string,
|
||||
resetCode: string
|
||||
) => Promise<PasswordResetUpdateResponse>
|
||||
setInitInfo: (info: SetInitInfoRequest) => Promise<void>
|
||||
setInitInfo: (info: SetInitInfoRequest) => Promise<SetInitInfoResponse>
|
||||
getInitInfo: () => Promise<GetInitInfoResponse>
|
||||
}
|
||||
|
||||
|
@ -34,13 +40,12 @@ export const buildAuthEndpoints = (API: BaseAPIClient): AuthEndpoints => ({
|
|||
* @param password the password
|
||||
*/
|
||||
logIn: async (tenantId, username, password) => {
|
||||
return await API.post<LoginRequest>({
|
||||
return await API.post<LoginRequest, LoginResponse>({
|
||||
url: `/api/global/auth/${tenantId}/login`,
|
||||
body: {
|
||||
username,
|
||||
password,
|
||||
},
|
||||
parseResponse: () => undefined,
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
@ -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<GetEnvironmentVariablesResponse>
|
||||
createEnvironmentVariable: (
|
||||
data: CreateEnvironmentVariableRequest
|
||||
) => Promise<void>
|
||||
deleteEnvironmentVariable: (name: string) => Promise<void>
|
||||
) => Promise<CreateEnvironmentVariableResponse>
|
||||
deleteEnvironmentVariable: (
|
||||
name: string
|
||||
) => Promise<DeleteEnvironmentVariablesResponse>
|
||||
updateEnvironmentVariable: (
|
||||
name: string,
|
||||
data: UpdateEnvironmentVariableRequest
|
||||
) => Promise<void>
|
||||
) => Promise<UpdateEnvironmentVariableResponse>
|
||||
}
|
||||
|
||||
export const buildEnvironmentVariableEndpoints = (
|
||||
|
|
|
@ -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<void>
|
||||
publishEvent: (type: EventPublishType) => Promise<PostEventPublishResponse>
|
||||
}
|
||||
|
||||
export const buildEventEndpoints = (API: BaseAPIClient): EventEndpoints => ({
|
||||
publishEvent: async type => {
|
||||
return await API.post<PostEventPublishRequest>({
|
||||
return await API.post<PostEventPublishRequest, PostEventPublishResponse>({
|
||||
url: `/api/global/event/publish`,
|
||||
body: {
|
||||
type,
|
||||
|
|
|
@ -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<void>
|
||||
activateLicenseKey: (
|
||||
licenseKey: string
|
||||
) => Promise<ActivateLicenseKeyResponse>
|
||||
deleteLicenseKey: () => Promise<void>
|
||||
getLicenseKey: () => Promise<GetLicenseKeyResponse | void>
|
||||
activateOfflineLicense: (offlineLicenseToken: string) => Promise<void>
|
||||
activateOfflineLicense: (
|
||||
offlineLicenseToken: string
|
||||
) => Promise<ActivateOfflineLicenseTokenResponse>
|
||||
deleteOfflineLicense: () => Promise<void>
|
||||
getOfflineLicense: () => Promise<GetOfflineLicenseTokenResponse | void>
|
||||
getOfflineLicenseIdentifier: () => Promise<GetOfflineIdentifierResponse>
|
||||
refreshLicense: () => Promise<void>
|
||||
refreshLicense: () => Promise<RefreshOfflineLicenseResponse>
|
||||
getQuotaUsage: () => Promise<QuotaUsage>
|
||||
}
|
||||
|
||||
|
@ -25,7 +32,7 @@ export const buildLicensingEndpoints = (
|
|||
): LicensingEndpoints => ({
|
||||
// LICENSE KEY
|
||||
activateLicenseKey: async licenseKey => {
|
||||
return API.post<ActivateLicenseKeyRequest>({
|
||||
return API.post<ActivateLicenseKeyRequest, ActivateLicenseKeyResponse>({
|
||||
url: `/api/global/license/key`,
|
||||
body: { licenseKey },
|
||||
})
|
||||
|
@ -49,7 +56,10 @@ export const buildLicensingEndpoints = (
|
|||
|
||||
// OFFLINE LICENSE
|
||||
activateOfflineLicense: async offlineLicenseToken => {
|
||||
return API.post<ActivateOfflineLicenseTokenRequest>({
|
||||
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,
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e7c9f08aeb0498a20594f3c912afedcfdc220a6a
|
||||
Subproject commit 7fc699463b3957eb050351b983edef0d25a531ae
|
|
@ -1,10 +1,11 @@
|
|||
import { events, context } from "@budibase/backend-core"
|
||||
import { context, events } from "@budibase/backend-core"
|
||||
import {
|
||||
AnalyticsPingRequest,
|
||||
App,
|
||||
PingSource,
|
||||
Ctx,
|
||||
AnalyticsEnabledResponse,
|
||||
AnalyticsPingRequest,
|
||||
AnalyticsPingResponse,
|
||||
App,
|
||||
Ctx,
|
||||
PingSource,
|
||||
} from "@budibase/types"
|
||||
import { DocumentType, isDevAppID } from "../../db/utils"
|
||||
|
||||
|
@ -15,9 +16,12 @@ export const isEnabled = async (ctx: Ctx<void, AnalyticsEnabledResponse>) => {
|
|||
}
|
||||
}
|
||||
|
||||
export const ping = async (ctx: Ctx<AnalyticsPingRequest, void>) => {
|
||||
export const ping = async (
|
||||
ctx: Ctx<AnalyticsPingRequest, AnalyticsPingResponse>
|
||||
) => {
|
||||
const body = ctx.request.body
|
||||
|
||||
let pingType: PingSource | undefined
|
||||
switch (body.source) {
|
||||
case PingSource.APP: {
|
||||
const db = context.getAppDB({ skip_setup: true })
|
||||
|
@ -29,13 +33,18 @@ export const ping = async (ctx: Ctx<AnalyticsPingRequest, void>) => {
|
|||
} else {
|
||||
await events.serve.servedApp(appInfo, body.timezone, body.embedded)
|
||||
}
|
||||
pingType = PingSource.APP
|
||||
break
|
||||
}
|
||||
case PingSource.BUILDER: {
|
||||
await events.serve.servedBuilder(body.timezone)
|
||||
pingType = PingSource.BUILDER
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "pong",
|
||||
source: pingType,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,9 @@ import {
|
|||
ImportToUpdateAppRequest,
|
||||
ImportToUpdateAppResponse,
|
||||
SetRevertableAppVersionRequest,
|
||||
AddAppSampleDataResponse,
|
||||
UnpublishAppResponse,
|
||||
SetRevertableAppVersionResponse,
|
||||
} from "@budibase/types"
|
||||
import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
||||
import sdk from "../../sdk"
|
||||
|
@ -175,7 +178,9 @@ async function createInstance(appId: string, template: AppTemplate) {
|
|||
return { _id: appId }
|
||||
}
|
||||
|
||||
export const addSampleData = async (ctx: UserCtx<void, void>) => {
|
||||
export const addSampleData = async (
|
||||
ctx: UserCtx<void, AddAppSampleDataResponse>
|
||||
) => {
|
||||
const db = context.getAppDB()
|
||||
|
||||
try {
|
||||
|
@ -188,7 +193,7 @@ export const addSampleData = async (ctx: UserCtx<void, void>) => {
|
|||
await db.bulkDocs([...defaultDbDocs])
|
||||
}
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Sample tables added." }
|
||||
}
|
||||
|
||||
export async function fetch(ctx: UserCtx<void, FetchAppsResponse>) {
|
||||
|
@ -528,7 +533,6 @@ export async function create(
|
|||
await appPostCreate(ctx, newApplication)
|
||||
await cache.bustCache(cache.CacheKey.CHECKLIST)
|
||||
ctx.body = newApplication
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
// This endpoint currently operates as a PATCH rather than a PUT
|
||||
|
@ -551,7 +555,6 @@ export async function update(
|
|||
|
||||
const app = await updateAppPackage(ctx.request.body, ctx.params.appId)
|
||||
await events.app.updated(app)
|
||||
ctx.status = 200
|
||||
ctx.body = app
|
||||
builderSocket?.emitAppMetadataUpdate(ctx, {
|
||||
theme: app.theme,
|
||||
|
@ -592,7 +595,6 @@ export async function updateClient(
|
|||
}
|
||||
const app = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
||||
await events.app.versionUpdated(app, currentVersion, updatedToVersion)
|
||||
ctx.status = 200
|
||||
ctx.body = app
|
||||
}
|
||||
|
||||
|
@ -624,7 +626,6 @@ export async function revertClient(
|
|||
}
|
||||
const app = await updateAppPackage(appPackageUpdates, ctx.params.appId)
|
||||
await events.app.versionReverted(app, currentVersion, revertedToVersion)
|
||||
ctx.status = 200
|
||||
ctx.body = app
|
||||
}
|
||||
|
||||
|
@ -689,11 +690,10 @@ export async function destroy(ctx: UserCtx<void, DeleteAppResponse>) {
|
|||
await preDestroyApp(ctx)
|
||||
const result = await destroyApp(ctx)
|
||||
await postDestroyApp(ctx)
|
||||
ctx.status = 200
|
||||
ctx.body = result
|
||||
}
|
||||
|
||||
export async function unpublish(ctx: UserCtx<void, void>) {
|
||||
export async function unpublish(ctx: UserCtx<void, UnpublishAppResponse>) {
|
||||
const prodAppId = dbCore.getProdAppID(ctx.params.appId)
|
||||
const dbExists = await dbCore.dbExists(prodAppId)
|
||||
|
||||
|
@ -705,8 +705,8 @@ export async function unpublish(ctx: UserCtx<void, void>) {
|
|||
await preDestroyApp(ctx)
|
||||
await unpublishApp(ctx)
|
||||
await postDestroyApp(ctx)
|
||||
ctx.status = 204
|
||||
builderSocket?.emitAppUnpublish(ctx)
|
||||
ctx.body = { message: "App unpublished." }
|
||||
}
|
||||
|
||||
export async function sync(ctx: UserCtx<void, SyncAppResponse>) {
|
||||
|
@ -802,7 +802,6 @@ export async function duplicateApp(
|
|||
duplicateAppId: newApplication?.appId,
|
||||
sourceAppId,
|
||||
}
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
export async function updateAppPackage(
|
||||
|
@ -830,7 +829,7 @@ export async function updateAppPackage(
|
|||
}
|
||||
|
||||
export async function setRevertableVersion(
|
||||
ctx: UserCtx<SetRevertableAppVersionRequest, void>
|
||||
ctx: UserCtx<SetRevertableAppVersionRequest, SetRevertableAppVersionResponse>
|
||||
) {
|
||||
if (!env.isDev()) {
|
||||
ctx.status = 403
|
||||
|
@ -840,8 +839,7 @@ export async function setRevertableVersion(
|
|||
const app = await sdk.applications.metadata.get()
|
||||
app.revertableVersion = ctx.request.body.revertableVersion
|
||||
await db.put(app)
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Revertable version updated." }
|
||||
}
|
||||
|
||||
async function migrateAppNavigation() {
|
||||
|
|
|
@ -62,7 +62,6 @@ export async function create(
|
|||
|
||||
const createdAutomation = await sdk.automations.create(automation)
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "Automation created successfully",
|
||||
automation: createdAutomation,
|
||||
|
@ -84,7 +83,6 @@ export async function update(
|
|||
|
||||
const updatedAutomation = await sdk.automations.update(automation)
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: `Automation ${automation._id} updated successfully.`,
|
||||
automation: updatedAutomation,
|
||||
|
|
|
@ -182,7 +182,6 @@ export async function update(
|
|||
}
|
||||
}
|
||||
|
||||
ctx.status = 200
|
||||
ctx.message = "Datasource saved successfully."
|
||||
ctx.body = {
|
||||
datasource: await sdk.datasources.removeSecretSingle(datasource),
|
||||
|
@ -290,8 +289,7 @@ export async function destroy(ctx: UserCtx<void, DeleteDatasourceResponse>) {
|
|||
await db.remove(datasourceId, ctx.params.revId)
|
||||
await events.datasource.deleted(datasource)
|
||||
|
||||
ctx.message = `Datasource deleted.`
|
||||
ctx.status = 200
|
||||
ctx.body = { message: `Datasource deleted.` }
|
||||
builderSocket?.emitDatasourceDeletion(ctx, datasourceId)
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ export async function save(
|
|||
layout._rev = response.rev
|
||||
|
||||
ctx.body = layout
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
export async function destroy(ctx: UserCtx<void, DeleteLayoutResponse>) {
|
||||
|
@ -51,5 +50,4 @@ export async function destroy(ctx: UserCtx<void, DeleteLayoutResponse>) {
|
|||
await db.remove(layoutId, layoutRev)
|
||||
await events.layout.deleted(layoutId)
|
||||
ctx.body = { message: "Layout deleted successfully" }
|
||||
ctx.status = 200
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
Ctx,
|
||||
FetchOldMigrationResponse,
|
||||
GetOldMigrationStatus,
|
||||
RuneOldMigrationResponse,
|
||||
RunOldMigrationRequest,
|
||||
} from "@budibase/types"
|
||||
import {
|
||||
|
@ -11,18 +12,19 @@ import {
|
|||
getLatestEnabledMigrationId,
|
||||
} from "../../appMigrations"
|
||||
|
||||
export async function migrate(ctx: Ctx<RunOldMigrationRequest, void>) {
|
||||
export async function migrate(
|
||||
ctx: Ctx<RunOldMigrationRequest, RuneOldMigrationResponse>
|
||||
) {
|
||||
const options = ctx.request.body
|
||||
// don't await as can take a while, just return
|
||||
migrationImpl(options)
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Migration started." }
|
||||
}
|
||||
|
||||
export async function fetchDefinitions(
|
||||
ctx: Ctx<void, FetchOldMigrationResponse>
|
||||
) {
|
||||
ctx.body = MIGRATIONS
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
export async function getMigrationStatus(
|
||||
|
@ -41,5 +43,4 @@ export async function getMigrationStatus(
|
|||
!latestMigrationId || latestAppliedMigration >= latestMigrationId
|
||||
|
||||
ctx.body = { migrated }
|
||||
ctx.status = 200
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ export async function getDependantResources(
|
|||
export async function addPermission(ctx: UserCtx<void, AddPermissionResponse>) {
|
||||
const params: AddPermissionRequest = ctx.params
|
||||
await sdk.permissions.updatePermissionOnRole(params, PermissionUpdateType.ADD)
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Permission added." }
|
||||
}
|
||||
|
||||
export async function removePermission(
|
||||
|
@ -110,5 +110,5 @@ export async function removePermission(
|
|||
params,
|
||||
PermissionUpdateType.REMOVE
|
||||
)
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Permission removed." }
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@ const _import = async (
|
|||
...importResult,
|
||||
datasourceId,
|
||||
}
|
||||
ctx.status = 200
|
||||
}
|
||||
export { _import as import }
|
||||
|
||||
|
@ -455,6 +454,5 @@ export async function destroy(ctx: UserCtx<void, DeleteQueryResponse>) {
|
|||
const datasource = await sdk.datasources.get(query.datasourceId)
|
||||
await db.remove(ctx.params.queryId, ctx.params.revId)
|
||||
ctx.body = { message: `Query deleted.` }
|
||||
ctx.status = 200
|
||||
await events.query.deleted(datasource, query)
|
||||
}
|
||||
|
|
|
@ -234,8 +234,7 @@ export async function destroy(ctx: UserCtx<void, DeleteRoleResponse>) {
|
|||
// clean up inherits
|
||||
await removeRoleFromOthers(roleId)
|
||||
|
||||
ctx.message = `Role ${ctx.params.roleId} deleted successfully`
|
||||
ctx.status = 200
|
||||
ctx.body = { message: `Role ${ctx.params.roleId} deleted successfully` }
|
||||
builderSocket?.emitRoleDeletion(ctx, role)
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,6 @@ export async function patch(
|
|||
if (!row) {
|
||||
ctx.throw(404, "Row not found")
|
||||
}
|
||||
ctx.status = 200
|
||||
|
||||
ctx.eventEmitter?.emitRow({
|
||||
eventName: EventType.ROW_UPDATE,
|
||||
|
@ -110,7 +109,6 @@ export const save = async (ctx: UserCtx<SaveRowRequest, SaveRowResponse>) => {
|
|||
: await quotas.addRow(() =>
|
||||
sdk.rows.save(sourceId, ctx.request.body, ctx.user?._id)
|
||||
)
|
||||
ctx.status = 200
|
||||
|
||||
ctx.eventEmitter?.emitRow({
|
||||
eventName: EventType.ROW_SAVE,
|
||||
|
@ -223,7 +221,6 @@ async function deleteRow(ctx: UserCtx<DeleteRowRequest>) {
|
|||
|
||||
export async function destroy(ctx: UserCtx<DeleteRowRequest>) {
|
||||
let response, row
|
||||
ctx.status = 200
|
||||
|
||||
if (isDeleteRows(ctx.request.body)) {
|
||||
response = await deleteRows(ctx)
|
||||
|
@ -275,7 +272,6 @@ export async function search(ctx: Ctx<SearchRowRequest, SearchRowResponse>) {
|
|||
rows: undefined,
|
||||
}
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = await sdk.rows.search(searchParams)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
import { RowActionTriggerRequest, Ctx } from "@budibase/types"
|
||||
import {
|
||||
RowActionTriggerRequest,
|
||||
Ctx,
|
||||
RowActionTriggerResponse,
|
||||
} from "@budibase/types"
|
||||
import sdk from "../../../sdk"
|
||||
|
||||
export async function run(ctx: Ctx<RowActionTriggerRequest, void>) {
|
||||
export async function run(
|
||||
ctx: Ctx<RowActionTriggerRequest, RowActionTriggerResponse>
|
||||
) {
|
||||
const { tableId, actionId } = ctx.params
|
||||
const { rowId } = ctx.request.body
|
||||
|
||||
await sdk.rowActions.run(tableId, actionId, rowId, ctx.user)
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Row action triggered." }
|
||||
}
|
||||
|
|
|
@ -123,7 +123,6 @@ export async function destroy(ctx: UserCtx<void, DeleteScreenResponse>) {
|
|||
ctx.body = {
|
||||
message: "Screen deleted successfully",
|
||||
}
|
||||
ctx.status = 200
|
||||
builderSocket?.emitScreenDeletion(ctx, id)
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,6 @@ export async function save(ctx: UserCtx<SaveTableRequest, SaveTableResponse>) {
|
|||
if (isImport) {
|
||||
await events.table.imported(savedTable)
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.message = `Table ${table.name} saved successfully.`
|
||||
ctx.eventEmitter?.emitTable(EventType.TABLE_SAVE, appId, { ...savedTable })
|
||||
ctx.body = savedTable
|
||||
|
@ -153,7 +152,6 @@ export async function destroy(ctx: UserCtx<void, DeleteTableResponse>) {
|
|||
await events.table.deleted(deletedTable)
|
||||
|
||||
ctx.eventEmitter?.emitTable(EventType.TABLE_DELETE, appId, deletedTable)
|
||||
ctx.status = 200
|
||||
ctx.table = deletedTable
|
||||
ctx.body = { message: `Table ${tableId} deleted.` }
|
||||
builderSocket?.emitTableDeletion(ctx, deletedTable)
|
||||
|
@ -169,7 +167,6 @@ export async function bulkImport(
|
|||
// can only be done in the builder, but in the future we may need to
|
||||
// think about events for bulk items
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = { message: `Bulk rows created.` }
|
||||
}
|
||||
|
||||
|
@ -180,7 +177,6 @@ export async function csvToJson(
|
|||
|
||||
const result = await jsonFromCsvString(csvString)
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = result
|
||||
}
|
||||
|
||||
|
@ -190,7 +186,6 @@ export async function validateNewTableImport(
|
|||
const { rows, schema } = ctx.request.body
|
||||
|
||||
if (isRows(rows) && isSchema(schema)) {
|
||||
ctx.status = 200
|
||||
ctx.body = validateSchema(rows, schema, PROTECTED_INTERNAL_COLUMNS)
|
||||
} else {
|
||||
ctx.status = 422
|
||||
|
@ -224,7 +219,6 @@ export async function validateExistingTableImport(
|
|||
}
|
||||
|
||||
if (tableId && isRows(rows) && isSchema(schema)) {
|
||||
ctx.status = 200
|
||||
ctx.body = validateSchema(rows, schema, protectedColumnNames)
|
||||
} else {
|
||||
ctx.status = 422
|
||||
|
@ -245,6 +239,5 @@ export async function migrate(
|
|||
})
|
||||
}
|
||||
|
||||
ctx.status = 200
|
||||
ctx.body = { message: `Column ${oldColumn} migrated.` }
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ export async function run({
|
|||
response: ctx.body,
|
||||
id: ctx.body._id,
|
||||
revision: ctx.body._rev,
|
||||
success: ctx.status === 200,
|
||||
success: !!ctx.body._id,
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
|
|
|
@ -94,7 +94,7 @@ export async function run({
|
|||
return {
|
||||
response: ctx.body,
|
||||
row: ctx.row,
|
||||
success: ctx.status === 200,
|
||||
success: ctx.body.ok,
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
|
|
|
@ -152,7 +152,7 @@ export async function run({
|
|||
|
||||
return {
|
||||
rows,
|
||||
success: ctx.status === 200,
|
||||
success: true,
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
|
|
|
@ -166,7 +166,7 @@ export async function run({
|
|||
response: ctx.message,
|
||||
id: ctx.body._id,
|
||||
revision: ctx.body._rev,
|
||||
success: ctx.status === 200,
|
||||
success: !!ctx.body._id,
|
||||
}
|
||||
} catch (err) {
|
||||
return {
|
||||
|
|
|
@ -96,7 +96,7 @@ describe("Test a query step automation", () => {
|
|||
)
|
||||
.run()
|
||||
|
||||
expect(result.steps[0].outputs.success).toBe(false)
|
||||
expect(result.steps[0].outputs.success).toBe(true)
|
||||
expect(result.steps[0].outputs.rows).toBeDefined()
|
||||
expect(result.steps[0].outputs.rows.length).toBe(0)
|
||||
})
|
||||
|
@ -125,7 +125,7 @@ describe("Test a query step automation", () => {
|
|||
)
|
||||
.run()
|
||||
|
||||
expect(result.steps[0].outputs.success).toBe(false)
|
||||
expect(result.steps[0].outputs.success).toBe(true)
|
||||
expect(result.steps[0].outputs.rows).toBeDefined()
|
||||
expect(result.steps[0].outputs.rows.length).toBe(0)
|
||||
})
|
||||
|
|
|
@ -48,7 +48,7 @@ export class ApplicationAPI extends TestAPI {
|
|||
|
||||
unpublish = async (appId: string): Promise<void> => {
|
||||
await this._post(`/api/applications/${appId}/unpublish`, {
|
||||
expectations: { status: 204 },
|
||||
expectations: { status: 200 },
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import authorized from "../middleware/authorized"
|
||||
import currentApp from "../middleware/currentapp"
|
||||
import { BaseSocket } from "./websocket"
|
||||
import { auth, permissions } from "@budibase/backend-core"
|
||||
import { auth, permissions, context } from "@budibase/backend-core"
|
||||
import http from "http"
|
||||
import Koa from "koa"
|
||||
import { getSourceId } from "../api/controllers/row/utils"
|
||||
|
@ -10,6 +10,12 @@ import { Socket } from "socket.io"
|
|||
import { GridSocketEvent } from "@budibase/shared-core"
|
||||
import { userAgent } from "koa-useragent"
|
||||
import { createContext, runMiddlewares } from "./middleware"
|
||||
import sdk from "../sdk"
|
||||
import {
|
||||
findHBSBlocks,
|
||||
isJSBinding,
|
||||
decodeJSBinding,
|
||||
} from "@budibase/string-templates"
|
||||
|
||||
const { PermissionType, PermissionLevel } = permissions
|
||||
|
||||
|
@ -18,15 +24,46 @@ export default class GridSocket extends BaseSocket {
|
|||
super(app, server, "/socket/grid")
|
||||
}
|
||||
|
||||
// Checks if a view's query contains any current user bindings
|
||||
containsCurrentUserBinding(view: ViewV2): boolean {
|
||||
return findHBSBlocks(JSON.stringify(view.query))
|
||||
.map(binding => {
|
||||
const sanitizedBinding = binding.replace(/\\"/g, '"')
|
||||
if (isJSBinding(sanitizedBinding)) {
|
||||
return decodeJSBinding(sanitizedBinding)
|
||||
} else {
|
||||
return sanitizedBinding
|
||||
}
|
||||
})
|
||||
.some(binding => binding?.includes("[user]"))
|
||||
}
|
||||
|
||||
async onConnect(socket: Socket) {
|
||||
// Initial identification of connected spreadsheet
|
||||
socket.on(GridSocketEvent.SelectDatasource, async (payload, callback) => {
|
||||
const ds = payload.datasource
|
||||
const appId = payload.appId
|
||||
const resourceId = ds?.type === "table" ? ds?.tableId : ds?.id
|
||||
let valid = true
|
||||
|
||||
// Ignore if no table or app specified
|
||||
// Validate datasource
|
||||
if (!resourceId || !appId) {
|
||||
// Ignore if no table or app specified
|
||||
valid = false
|
||||
} else if (ds.type === "viewV2") {
|
||||
// If this is a view filtered by current user, don't sync changes
|
||||
try {
|
||||
await context.doInAppContext(appId, async () => {
|
||||
const view = await sdk.views.get(ds.id)
|
||||
if (this.containsCurrentUserBinding(view)) {
|
||||
valid = false
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
valid = false
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
socket.disconnect(true)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -12,3 +12,7 @@ export interface AnalyticsPingRequest {
|
|||
timezone: string
|
||||
embedded?: boolean
|
||||
}
|
||||
export interface AnalyticsPingResponse {
|
||||
message: string
|
||||
source?: PingSource
|
||||
}
|
||||
|
|
|
@ -44,6 +44,10 @@ export interface FetchAppPackageResponse {
|
|||
hasLock: boolean
|
||||
}
|
||||
|
||||
export interface AddAppSampleDataResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export type FetchAppsResponse = App[]
|
||||
|
||||
export interface PublishResponse {
|
||||
|
@ -61,6 +65,10 @@ export interface DeleteAppResponse {
|
|||
ok: boolean
|
||||
}
|
||||
|
||||
export interface UnpublishAppResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface ImportToUpdateAppRequest {
|
||||
encryptionPassword?: string
|
||||
}
|
||||
|
@ -71,6 +79,9 @@ export interface ImportToUpdateAppResponse {
|
|||
export interface SetRevertableAppVersionRequest {
|
||||
revertableVersion: string
|
||||
}
|
||||
export interface SetRevertableAppVersionResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface ExportAppDumpRequest {
|
||||
excludeRows: boolean
|
||||
|
|
|
@ -29,7 +29,9 @@ export interface AddedPermission {
|
|||
reason?: string
|
||||
}
|
||||
|
||||
export interface AddPermissionResponse {}
|
||||
export interface AddPermissionResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface AddPermissionRequest {
|
||||
roleId: string
|
||||
|
@ -38,4 +40,6 @@ export interface AddPermissionRequest {
|
|||
}
|
||||
|
||||
export interface RemovePermissionRequest extends AddPermissionRequest {}
|
||||
export interface RemovePermissionResponse {}
|
||||
export interface RemovePermissionResponse {
|
||||
message: string
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ export interface RowActionsResponse {
|
|||
export interface RowActionTriggerRequest {
|
||||
rowId: string
|
||||
}
|
||||
export interface RowActionTriggerResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface RowActionPermissionsResponse
|
||||
extends RowActionPermissionsData {}
|
||||
|
|
|
@ -2,12 +2,19 @@ export interface LoginRequest {
|
|||
username: string
|
||||
password: string
|
||||
}
|
||||
export interface LoginResponse {
|
||||
message: string
|
||||
userId?: string
|
||||
}
|
||||
|
||||
export interface LogoutResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface SetInitInfoRequest extends Record<string, any> {}
|
||||
export interface SetInitInfoResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface GetInitInfoResponse extends Record<string, any> {}
|
||||
|
||||
|
|
|
@ -7,12 +7,22 @@ export interface CreateEnvironmentVariableRequest {
|
|||
production: string
|
||||
development: string
|
||||
}
|
||||
export interface CreateEnvironmentVariableResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface UpdateEnvironmentVariableRequest {
|
||||
production: string
|
||||
development: string
|
||||
}
|
||||
export interface UpdateEnvironmentVariableResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface GetEnvironmentVariablesResponse {
|
||||
variables: string[]
|
||||
}
|
||||
|
||||
export interface DeleteEnvironmentVariablesResponse {
|
||||
message: string
|
||||
}
|
||||
|
|
|
@ -5,3 +5,6 @@ export enum EventPublishType {
|
|||
export interface PostEventPublishRequest {
|
||||
type: EventPublishType
|
||||
}
|
||||
export interface PostEventPublishResponse {
|
||||
message: string
|
||||
}
|
||||
|
|
|
@ -5,6 +5,9 @@ import { QuotaUsage } from "../../../documents"
|
|||
export interface ActivateLicenseKeyRequest {
|
||||
licenseKey: string
|
||||
}
|
||||
export interface ActivateLicenseKeyResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface GetLicenseKeyResponse {
|
||||
licenseKey: string
|
||||
|
@ -15,11 +18,20 @@ export interface GetLicenseKeyResponse {
|
|||
export interface ActivateOfflineLicenseTokenRequest {
|
||||
offlineLicenseToken: string
|
||||
}
|
||||
export interface ActivateOfflineLicenseTokenResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface GetOfflineLicenseTokenResponse {
|
||||
offlineLicenseToken: string
|
||||
}
|
||||
|
||||
// REFRESH
|
||||
|
||||
export interface RefreshOfflineLicenseResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
// IDENTIFIER
|
||||
|
||||
export interface GetOfflineIdentifierResponse {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { Migration, MigrationOptions } from "../../../sdk"
|
||||
|
||||
export interface RunOldMigrationRequest extends MigrationOptions {}
|
||||
export interface RuneOldMigrationResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export type FetchOldMigrationResponse = Migration[]
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { MigrationDefinition, MigrationOptions } from "../../../sdk"
|
||||
|
||||
export interface RunGlobalMigrationRequest extends MigrationOptions {}
|
||||
export interface RunGlobalMigrationResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export type FetchMigrationDefinitionsResponse = MigrationDefinition[]
|
||||
|
|
|
@ -110,6 +110,9 @@ export interface AddSSoUserRequest {
|
|||
ssoId: string
|
||||
email: string
|
||||
}
|
||||
export interface AddSSoUserResponse {
|
||||
message: string
|
||||
}
|
||||
|
||||
export interface CreateAdminUserResponse {
|
||||
_id: string
|
||||
|
|
|
@ -22,6 +22,8 @@ import {
|
|||
GetInitInfoResponse,
|
||||
PasswordResetResponse,
|
||||
PasswordResetUpdateResponse,
|
||||
SetInitInfoResponse,
|
||||
LoginResponse,
|
||||
} from "@budibase/types"
|
||||
import env from "../../../environment"
|
||||
import { Next } from "koa"
|
||||
|
@ -59,7 +61,10 @@ async function passportCallback(
|
|||
ctx.set(Header.TOKEN, token)
|
||||
}
|
||||
|
||||
export const login = async (ctx: Ctx<LoginRequest, void>, next: Next) => {
|
||||
export const login = async (
|
||||
ctx: Ctx<LoginRequest, LoginResponse>,
|
||||
next: Next
|
||||
) => {
|
||||
const email = ctx.request.body.username
|
||||
|
||||
const user = await userSdk.db.getUserByEmail(email)
|
||||
|
@ -74,7 +79,10 @@ export const login = async (ctx: Ctx<LoginRequest, void>, next: Next) => {
|
|||
await context.identity.doInUserContext(user, ctx, async () => {
|
||||
await events.auth.login("local", user.email)
|
||||
})
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "Login successful",
|
||||
userId: user.userId,
|
||||
}
|
||||
}
|
||||
)(ctx, next)
|
||||
}
|
||||
|
@ -88,10 +96,14 @@ export const logout = async (ctx: UserCtx<void, LogoutResponse>) => {
|
|||
|
||||
// INIT
|
||||
|
||||
export const setInitInfo = (ctx: UserCtx<SetInitInfoRequest, void>) => {
|
||||
export const setInitInfo = (
|
||||
ctx: UserCtx<SetInitInfoRequest, SetInitInfoResponse>
|
||||
) => {
|
||||
const initInfo = ctx.request.body
|
||||
setCookie(ctx, initInfo, Cookie.Init)
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "Init info updated.",
|
||||
}
|
||||
}
|
||||
|
||||
export const getInitInfo = (ctx: UserCtx<void, GetInitInfoResponse>) => {
|
||||
|
|
|
@ -2,10 +2,13 @@ import {
|
|||
UserCtx,
|
||||
PostEventPublishRequest,
|
||||
EventPublishType,
|
||||
PostEventPublishResponse,
|
||||
} from "@budibase/types"
|
||||
import { events } from "@budibase/backend-core"
|
||||
|
||||
export async function publish(ctx: UserCtx<PostEventPublishRequest, void>) {
|
||||
export async function publish(
|
||||
ctx: UserCtx<PostEventPublishRequest, PostEventPublishResponse>
|
||||
) {
|
||||
switch (ctx.request.body.type) {
|
||||
case EventPublishType.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED:
|
||||
await events.environmentVariable.upgradePanelOpened(ctx.user._id!)
|
||||
|
@ -13,5 +16,5 @@ export async function publish(ctx: UserCtx<PostEventPublishRequest, void>) {
|
|||
default:
|
||||
ctx.throw(400, "Invalid publish event type.")
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Event published." }
|
||||
}
|
||||
|
|
|
@ -1,29 +1,33 @@
|
|||
import { licensing, quotas } from "@budibase/pro"
|
||||
import {
|
||||
ActivateLicenseKeyRequest,
|
||||
ActivateLicenseKeyResponse,
|
||||
ActivateOfflineLicenseTokenRequest,
|
||||
ActivateOfflineLicenseTokenResponse,
|
||||
GetLicenseKeyResponse,
|
||||
GetOfflineIdentifierResponse,
|
||||
GetOfflineLicenseTokenResponse,
|
||||
GetQuotaUsageResponse,
|
||||
RefreshOfflineLicenseResponse,
|
||||
UserCtx,
|
||||
} from "@budibase/types"
|
||||
|
||||
// LICENSE KEY
|
||||
|
||||
export async function activateLicenseKey(
|
||||
ctx: UserCtx<ActivateLicenseKeyRequest>
|
||||
ctx: UserCtx<ActivateLicenseKeyRequest, ActivateLicenseKeyResponse>
|
||||
) {
|
||||
const { licenseKey } = ctx.request.body
|
||||
await licensing.keys.activateLicenseKey(licenseKey)
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "License activated.",
|
||||
}
|
||||
}
|
||||
|
||||
export async function getLicenseKey(ctx: UserCtx<void, GetLicenseKeyResponse>) {
|
||||
const licenseKey = await licensing.keys.getLicenseKey()
|
||||
if (licenseKey) {
|
||||
ctx.body = { licenseKey: "*" }
|
||||
ctx.status = 200
|
||||
} else {
|
||||
ctx.status = 404
|
||||
}
|
||||
|
@ -37,11 +41,16 @@ export async function deleteLicenseKey(ctx: UserCtx<void, void>) {
|
|||
// OFFLINE LICENSE
|
||||
|
||||
export async function activateOfflineLicenseToken(
|
||||
ctx: UserCtx<ActivateOfflineLicenseTokenRequest, void>
|
||||
ctx: UserCtx<
|
||||
ActivateOfflineLicenseTokenRequest,
|
||||
ActivateOfflineLicenseTokenResponse
|
||||
>
|
||||
) {
|
||||
const { offlineLicenseToken } = ctx.request.body
|
||||
await licensing.offline.activateOfflineLicenseToken(offlineLicenseToken)
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "License token activated.",
|
||||
}
|
||||
}
|
||||
|
||||
export async function getOfflineLicenseToken(
|
||||
|
@ -50,7 +59,6 @@ export async function getOfflineLicenseToken(
|
|||
const offlineLicenseToken = await licensing.offline.getOfflineLicenseToken()
|
||||
if (offlineLicenseToken) {
|
||||
ctx.body = { offlineLicenseToken: "*" }
|
||||
ctx.status = 200
|
||||
} else {
|
||||
ctx.status = 404
|
||||
}
|
||||
|
@ -66,14 +74,17 @@ export async function getOfflineLicenseIdentifier(
|
|||
) {
|
||||
const identifierBase64 = await licensing.offline.getIdentifierBase64()
|
||||
ctx.body = { identifierBase64 }
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
// LICENSES
|
||||
|
||||
export const refresh = async (ctx: UserCtx<void, void>) => {
|
||||
export const refresh = async (
|
||||
ctx: UserCtx<void, RefreshOfflineLicenseResponse>
|
||||
) => {
|
||||
await licensing.cache.refresh()
|
||||
ctx.status = 200
|
||||
ctx.body = {
|
||||
message: "License refreshed.",
|
||||
}
|
||||
}
|
||||
|
||||
// USAGE
|
||||
|
@ -82,5 +93,4 @@ export const getQuotaUsage = async (
|
|||
ctx: UserCtx<void, GetQuotaUsageResponse>
|
||||
) => {
|
||||
ctx.body = await quotas.getQuotaUsage()
|
||||
ctx.status = 200
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import {
|
|||
AcceptUserInviteRequest,
|
||||
AcceptUserInviteResponse,
|
||||
AddSSoUserRequest,
|
||||
AddSSoUserResponse,
|
||||
BulkUserRequest,
|
||||
BulkUserResponse,
|
||||
CheckInviteResponse,
|
||||
|
@ -93,7 +94,9 @@ export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
|||
}
|
||||
}
|
||||
|
||||
export const addSsoSupport = async (ctx: Ctx<AddSSoUserRequest, void>) => {
|
||||
export const addSsoSupport = async (
|
||||
ctx: Ctx<AddSSoUserRequest, AddSSoUserResponse>
|
||||
) => {
|
||||
const { email, ssoId } = ctx.request.body
|
||||
try {
|
||||
// Status is changed to 404 from getUserDoc if user is not found
|
||||
|
@ -113,7 +116,7 @@ export const addSsoSupport = async (ctx: Ctx<AddSSoUserRequest, void>) => {
|
|||
email,
|
||||
ssoId,
|
||||
})
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "SSO support added." }
|
||||
} catch (err: any) {
|
||||
ctx.throw(err.status || 400, err)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ export const save = async (
|
|||
metadata = await accounts.metadata.saveMetadata(metadata)
|
||||
|
||||
ctx.body = metadata
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
export const destroy = async (ctx: Ctx<void, void>) => {
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
import {
|
||||
FetchMigrationDefinitionsResponse,
|
||||
RunGlobalMigrationRequest,
|
||||
RunGlobalMigrationResponse,
|
||||
UserCtx,
|
||||
} from "@budibase/types"
|
||||
|
||||
const { migrate, MIGRATIONS } = require("../../../migrations")
|
||||
|
||||
export const runMigrations = async (
|
||||
ctx: UserCtx<RunGlobalMigrationRequest, void>
|
||||
ctx: UserCtx<RunGlobalMigrationRequest, RunGlobalMigrationResponse>
|
||||
) => {
|
||||
const options = ctx.request.body
|
||||
// don't await as can take a while, just return
|
||||
migrate(options)
|
||||
ctx.status = 200
|
||||
ctx.body = { message: "Migration started." }
|
||||
}
|
||||
|
||||
export const fetchDefinitions = async (
|
||||
ctx: UserCtx<void, FetchMigrationDefinitionsResponse>
|
||||
) => {
|
||||
ctx.body = MIGRATIONS
|
||||
ctx.status = 200
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ describe("/api/system/migrations", () => {
|
|||
|
||||
it("runs migrations", async () => {
|
||||
const res = await config.api.migrations.runMigrations()
|
||||
expect(res.text).toBe("OK")
|
||||
expect(res.body.message).toBeDefined()
|
||||
expect(migrateFn).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -8773,7 +8773,7 @@ dd-trace@5.26.0:
|
|||
shell-quote "^1.8.1"
|
||||
tlhunter-sorted-set "^0.1.0"
|
||||
|
||||
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@^4.3.5, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4:
|
||||
debug@4, debug@^4.0.0, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1, debug@^4.3.2, debug@^4.3.3, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4:
|
||||
version "4.3.7"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52"
|
||||
integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==
|
||||
|
@ -8794,6 +8794,13 @@ debug@^3.1.0, debug@^3.2.7:
|
|||
dependencies:
|
||||
ms "^2.1.1"
|
||||
|
||||
debug@^4.3.5:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.0.tgz#2b3f2aea2ffeb776477460267377dc8710faba8a"
|
||||
integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==
|
||||
dependencies:
|
||||
ms "^2.1.3"
|
||||
|
||||
debuglog@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
|
||||
|
|
Loading…
Reference in New Issue