Remove obsolete templateString
This commit is contained in:
parent
cb5082a0c0
commit
8dee7b2c45
|
@ -36,7 +36,6 @@ import {
|
|||
import { USERS_TABLE_SCHEMA, DEFAULT_BB_DATASOURCE_ID } from "../../constants"
|
||||
import { buildDefaultDocs } from "../../db/defaultData/datasource_bb_default"
|
||||
import { removeAppFromUserRoles } from "../../utilities/workerRequests"
|
||||
import { stringToReadStream } from "../../utilities"
|
||||
import { doesUserHaveLock } from "../../utilities/redis"
|
||||
import { cleanupAutomations } from "../../automations/utils"
|
||||
import { getUniqueRows } from "../../utilities/usageQuota/rows"
|
||||
|
@ -128,7 +127,6 @@ function checkAppName(
|
|||
}
|
||||
|
||||
interface AppTemplate {
|
||||
templateString?: string
|
||||
useTemplate?: string
|
||||
file?: {
|
||||
type?: string
|
||||
|
@ -153,14 +151,7 @@ async function createInstance(appId: string, template: AppTemplate) {
|
|||
await createRoutingView()
|
||||
await createAllSearchIndex()
|
||||
|
||||
// replicate the template data to the instance DB
|
||||
// this is currently very hard to test, downloading and importing template files
|
||||
if (template && template.templateString) {
|
||||
const { ok } = await db.load(stringToReadStream(template.templateString))
|
||||
if (!ok) {
|
||||
throw "Error loading database dump from memory."
|
||||
}
|
||||
} else if (template && template.useTemplate === "true") {
|
||||
if (template && template.useTemplate === "true") {
|
||||
await sdk.backups.importApp(appId, db, template)
|
||||
} else {
|
||||
// create the users table
|
||||
|
@ -248,14 +239,8 @@ export async function fetchAppPackage(
|
|||
|
||||
async function performAppCreate(ctx: UserCtx<CreateAppRequest, App>) {
|
||||
const apps = (await dbCore.getAllApps({ dev: true })) as App[]
|
||||
const {
|
||||
name,
|
||||
url,
|
||||
encryptionPassword,
|
||||
useTemplate,
|
||||
templateKey,
|
||||
templateString,
|
||||
} = ctx.request.body
|
||||
const { name, url, encryptionPassword, useTemplate, templateKey } =
|
||||
ctx.request.body
|
||||
|
||||
checkAppName(ctx, apps, name)
|
||||
const appUrl = sdk.applications.getAppUrl({ name, url })
|
||||
|
@ -264,7 +249,6 @@ async function performAppCreate(ctx: UserCtx<CreateAppRequest, App>) {
|
|||
const instanceConfig: AppTemplate = {
|
||||
useTemplate,
|
||||
key: templateKey,
|
||||
templateString,
|
||||
}
|
||||
if (ctx.request.files && ctx.request.files.templateFile) {
|
||||
instanceConfig.file = {
|
||||
|
|
|
@ -141,7 +141,6 @@ describe("/applications", () => {
|
|||
name: utils.newid(),
|
||||
useTemplate: "true",
|
||||
templateKey: "test",
|
||||
templateString: "{}",
|
||||
})
|
||||
expect(app._id).toBeDefined()
|
||||
expect(events.app.created).toHaveBeenCalledTimes(1)
|
||||
|
|
|
@ -355,9 +355,7 @@ export function applicationValidator(opts = { isCreate: true }) {
|
|||
_id: OPTIONAL_STRING,
|
||||
_rev: OPTIONAL_STRING,
|
||||
url: OPTIONAL_STRING,
|
||||
template: Joi.object({
|
||||
templateString: OPTIONAL_STRING,
|
||||
}),
|
||||
template: Joi.object({}),
|
||||
}
|
||||
|
||||
const appNameValidator = Joi.string()
|
||||
|
@ -390,9 +388,7 @@ export function applicationValidator(opts = { isCreate: true }) {
|
|||
_rev: OPTIONAL_STRING,
|
||||
name: appNameValidator,
|
||||
url: OPTIONAL_STRING,
|
||||
template: Joi.object({
|
||||
templateString: OPTIONAL_STRING,
|
||||
}).unknown(true),
|
||||
template: Joi.object({}).unknown(true),
|
||||
snippets: snippetValidator,
|
||||
}).unknown(true)
|
||||
)
|
||||
|
|
|
@ -2,9 +2,6 @@ import env from "../environment"
|
|||
import { context } from "@budibase/backend-core"
|
||||
import { generateMetadataID } from "../db/utils"
|
||||
import { Document } from "@budibase/types"
|
||||
import stream from "stream"
|
||||
|
||||
const Readable = stream.Readable
|
||||
|
||||
export function wait(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms))
|
||||
|
@ -98,15 +95,6 @@ export function escapeDangerousCharacters(string: string) {
|
|||
.replace(/[\t]/g, "\\t")
|
||||
}
|
||||
|
||||
export function stringToReadStream(string: string) {
|
||||
return new Readable({
|
||||
read() {
|
||||
this.push(string)
|
||||
this.push(null)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: string) {
|
||||
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
||||
const byteIncrements = 1024
|
||||
|
|
|
@ -10,7 +10,6 @@ export interface CreateAppRequest {
|
|||
templateFile?: string
|
||||
includeSampleData?: boolean
|
||||
encryptionPassword?: string
|
||||
templateString?: string
|
||||
file?: { path: string }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue