Merge remote-tracking branch 'origin/develop' into feature/app-settings-section
This commit is contained in:
commit
c1248eed12
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"version": "2.7.25-alpha.2",
|
"version": "2.7.25-alpha.7",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
|
"useNx": true,
|
||||||
"packages": [
|
"packages": [
|
||||||
"packages/backend-core",
|
"packages/backend-core",
|
||||||
"packages/bbui",
|
"packages/bbui",
|
||||||
|
@ -16,7 +17,6 @@
|
||||||
"packages/worker",
|
"packages/worker",
|
||||||
"packages/pro/packages/pro"
|
"packages/pro/packages/pro"
|
||||||
],
|
],
|
||||||
"useWorkspaces": true,
|
|
||||||
"command": {
|
"command": {
|
||||||
"publish": {
|
"publish": {
|
||||||
"ignoreChanges": [
|
"ignoreChanges": [
|
||||||
|
|
11
package.json
11
package.json
|
@ -2,23 +2,22 @@
|
||||||
"name": "root",
|
"name": "root",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@esbuild-plugins/node-resolve": "^0.2.2",
|
|
||||||
"@esbuild-plugins/tsconfig-paths": "^0.1.2",
|
"@esbuild-plugins/tsconfig-paths": "^0.1.2",
|
||||||
"@nx/js": "16.2.1",
|
"@nx/js": "16.2.1",
|
||||||
"@rollup/plugin-json": "^4.0.2",
|
"@rollup/plugin-json": "^4.0.2",
|
||||||
"@typescript-eslint/parser": "5.45.0",
|
"@typescript-eslint/parser": "5.45.0",
|
||||||
"babel-eslint": "^10.0.3",
|
"babel-eslint": "^10.0.3",
|
||||||
"esbuild": "^0.17.18",
|
"esbuild": "^0.17.18",
|
||||||
|
"esbuild-node-externals": "^1.7.0",
|
||||||
"eslint": "^7.28.0",
|
"eslint": "^7.28.0",
|
||||||
"eslint-plugin-cypress": "^2.11.3",
|
"eslint-plugin-cypress": "^2.11.3",
|
||||||
"eslint-plugin-svelte3": "^3.2.0",
|
"eslint-plugin-svelte3": "^3.2.0",
|
||||||
"husky": "^8.0.3",
|
"husky": "^8.0.3",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"kill-port": "^1.6.1",
|
"kill-port": "^1.6.1",
|
||||||
"lerna": "7.0.0-alpha.0",
|
"lerna": "7.0.2",
|
||||||
"madge": "^6.0.0",
|
"madge": "^6.0.0",
|
||||||
"minimist": "^1.2.8",
|
"minimist": "^1.2.8",
|
||||||
"nx": "^16.2.1",
|
|
||||||
"prettier": "^2.3.1",
|
"prettier": "^2.3.1",
|
||||||
"prettier-plugin-svelte": "^2.3.0",
|
"prettier-plugin-svelte": "^2.3.0",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
|
@ -48,9 +47,9 @@
|
||||||
"kill-builder": "kill-port 3000",
|
"kill-builder": "kill-port 3000",
|
||||||
"kill-server": "kill-port 4001 4002",
|
"kill-server": "kill-port 4001 4002",
|
||||||
"kill-all": "yarn run kill-builder && yarn run kill-server",
|
"kill-all": "yarn run kill-builder && yarn run kill-server",
|
||||||
"dev": "yarn run kill-all && lerna run --stream --parallel dev:builder --stream",
|
"dev": "yarn run kill-all && lerna run --stream --parallel dev:builder --stream",
|
||||||
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream --parallel dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker",
|
"dev:noserver": "yarn run kill-builder && lerna run --stream dev:stack:up && lerna run --stream --parallel dev:builder --ignore @budibase/backend-core --ignore @budibase/server --ignore @budibase/worker",
|
||||||
"dev:server": "yarn run kill-server && lerna run --stream --parallel dev:builder --scope @budibase/worker --scope @budibase/server",
|
"dev:server": "yarn run kill-server && yarn build --projects=@budibase/client && lerna run --stream --parallel dev:builder --scope @budibase/worker --scope @budibase/server",
|
||||||
"dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream --parallel dev:built",
|
"dev:built": "yarn run kill-all && cd packages/server && yarn dev:stack:up && cd ../../ && lerna run --stream --parallel dev:built",
|
||||||
"dev:docker": "yarn build:docker:pre && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0",
|
"dev:docker": "yarn build:docker:pre && docker-compose -f hosting/docker-compose.build.yaml -f hosting/docker-compose.dev.yaml --env-file hosting/.env up --build --scale proxy-service=0",
|
||||||
"test": "lerna run --stream test --stream",
|
"test": "lerna run --stream test --stream",
|
||||||
|
|
|
@ -31,4 +31,6 @@ const config: Config.InitialOptions = {
|
||||||
coverageReporters: ["lcov", "json", "clover"],
|
coverageReporters: ["lcov", "json", "clover"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
process.env.DISABLE_PINO_LOGGER = "1"
|
||||||
|
|
||||||
export default config
|
export default config
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
"aws-cloudfront-sign": "2.2.0",
|
"aws-cloudfront-sign": "2.2.0",
|
||||||
"aws-sdk": "2.1030.0",
|
"aws-sdk": "2.1030.0",
|
||||||
"bcrypt": "5.0.1",
|
"bcrypt": "5.1.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"bull": "4.10.1",
|
"bull": "4.10.1",
|
||||||
"correlation-id": "4.0.0",
|
"correlation-id": "4.0.0",
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
import TemplateCard from "components/common/TemplateCard.svelte"
|
import TemplateCard from "components/common/TemplateCard.svelte"
|
||||||
import createFromScratchScreen from "builderStore/store/screenTemplates/createFromScratchScreen"
|
import createFromScratchScreen from "builderStore/store/screenTemplates/createFromScratchScreen"
|
||||||
import { Roles } from "constants/backend"
|
import { Roles } from "constants/backend"
|
||||||
|
import { lowercase } from "helpers"
|
||||||
|
|
||||||
export let template
|
export let template
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
|
|
||||||
const values = writable({ name: "", url: null })
|
const values = writable({ name: "", url: null })
|
||||||
const validation = createValidationStore()
|
const validation = createValidationStore()
|
||||||
|
const encryptionValidation = createValidationStore()
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
const { url } = $values
|
const { url } = $values
|
||||||
|
@ -27,8 +29,11 @@
|
||||||
...$values,
|
...$values,
|
||||||
url: url?.[0] === "/" ? url.substring(1, url.length) : url,
|
url: url?.[0] === "/" ? url.substring(1, url.length) : url,
|
||||||
})
|
})
|
||||||
|
encryptionValidation.check({ ...$values })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: encryptedFile = $values.file?.name?.endsWith(".enc.tar.gz")
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const lastChar = $auth.user?.firstName
|
const lastChar = $auth.user?.firstName
|
||||||
? $auth.user?.firstName[$auth.user?.firstName.length - 1]
|
? $auth.user?.firstName[$auth.user?.firstName.length - 1]
|
||||||
|
@ -87,6 +92,9 @@
|
||||||
appValidation.name(validation, { apps: applications })
|
appValidation.name(validation, { apps: applications })
|
||||||
appValidation.url(validation, { apps: applications })
|
appValidation.url(validation, { apps: applications })
|
||||||
appValidation.file(validation, { template })
|
appValidation.file(validation, { template })
|
||||||
|
|
||||||
|
encryptionValidation.addValidatorType("encryptionPassword", "text", true)
|
||||||
|
|
||||||
// init validation
|
// init validation
|
||||||
const { url } = $values
|
const { url } = $values
|
||||||
validation.check({
|
validation.check({
|
||||||
|
@ -110,6 +118,9 @@
|
||||||
data.append("templateName", template.name)
|
data.append("templateName", template.name)
|
||||||
data.append("templateKey", template.key)
|
data.append("templateKey", template.key)
|
||||||
data.append("templateFile", $values.file)
|
data.append("templateFile", $values.file)
|
||||||
|
if ($values.encryptionPassword?.trim()) {
|
||||||
|
data.append("encryptionPassword", $values.encryptionPassword.trim())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create App
|
// Create App
|
||||||
|
@ -143,67 +154,119 @@
|
||||||
$goto(`/builder/app/${createdApp.instance._id}`)
|
$goto(`/builder/app/${createdApp.instance._id}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
creating = false
|
creating = false
|
||||||
console.error(error)
|
throw error
|
||||||
notifications.error("Error creating app")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Step = { CONFIG: "config", SET_PASSWORD: "set_password" }
|
||||||
|
let currentStep = Step.CONFIG
|
||||||
|
$: stepConfig = {
|
||||||
|
[Step.CONFIG]: {
|
||||||
|
title: "Create your app",
|
||||||
|
confirmText: template?.fromFile ? "Import app" : "Create app",
|
||||||
|
onConfirm: async () => {
|
||||||
|
if (encryptedFile) {
|
||||||
|
currentStep = Step.SET_PASSWORD
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
await createNewApp()
|
||||||
|
} catch (error) {
|
||||||
|
notifications.error("Error creating app")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isValid: $validation.valid,
|
||||||
|
},
|
||||||
|
[Step.SET_PASSWORD]: {
|
||||||
|
title: "Provide the export password",
|
||||||
|
confirmText: "Import app",
|
||||||
|
onConfirm: async () => {
|
||||||
|
try {
|
||||||
|
await createNewApp()
|
||||||
|
} catch (e) {
|
||||||
|
let message = "Error creating app"
|
||||||
|
if (e.message) {
|
||||||
|
message += `: ${lowercase(e.message)}`
|
||||||
|
}
|
||||||
|
notifications.error(message)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isValid: $encryptionValidation.valid,
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title={"Create your app"}
|
title={stepConfig[currentStep].title}
|
||||||
confirmText={template?.fromFile ? "Import app" : "Create app"}
|
confirmText={stepConfig[currentStep].confirmText}
|
||||||
onConfirm={createNewApp}
|
onConfirm={stepConfig[currentStep].onConfirm}
|
||||||
disabled={!$validation.valid}
|
disabled={!stepConfig[currentStep].isValid}
|
||||||
>
|
>
|
||||||
{#if template && !template?.fromFile}
|
{#if currentStep === Step.CONFIG}
|
||||||
<TemplateCard
|
{#if template && !template?.fromFile}
|
||||||
name={template.name}
|
<TemplateCard
|
||||||
imageSrc={template.image}
|
name={template.name}
|
||||||
backgroundColour={template.background}
|
imageSrc={template.image}
|
||||||
overlayEnabled={false}
|
backgroundColour={template.background}
|
||||||
icon={template.icon}
|
overlayEnabled={false}
|
||||||
/>
|
icon={template.icon}
|
||||||
{/if}
|
/>
|
||||||
{#if template?.fromFile}
|
|
||||||
<Dropzone
|
|
||||||
error={$validation.touched.file && $validation.errors.file}
|
|
||||||
gallery={false}
|
|
||||||
label="File to import"
|
|
||||||
value={[$values.file]}
|
|
||||||
on:change={e => {
|
|
||||||
$values.file = e.detail?.[0]
|
|
||||||
$validation.touched.file = true
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<Input
|
|
||||||
autofocus={true}
|
|
||||||
bind:value={$values.name}
|
|
||||||
disabled={creating}
|
|
||||||
error={$validation.touched.name && $validation.errors.name}
|
|
||||||
on:blur={() => ($validation.touched.name = true)}
|
|
||||||
on:change={nameToUrl($values.name)}
|
|
||||||
label="Name"
|
|
||||||
placeholder={defaultAppName}
|
|
||||||
/>
|
|
||||||
<span>
|
|
||||||
<Input
|
|
||||||
bind:value={$values.url}
|
|
||||||
disabled={creating}
|
|
||||||
error={$validation.touched.url && $validation.errors.url}
|
|
||||||
on:blur={() => ($validation.touched.url = true)}
|
|
||||||
on:change={tidyUrl($values.url)}
|
|
||||||
label="URL"
|
|
||||||
placeholder={$values.url
|
|
||||||
? $values.url
|
|
||||||
: `/${resolveAppUrl(template, $values.name)}`}
|
|
||||||
/>
|
|
||||||
{#if $values.url && $values.url !== "" && !$validation.errors.url}
|
|
||||||
<div class="app-server" title={appUrl}>
|
|
||||||
{appUrl}
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
{#if template?.fromFile}
|
||||||
|
<Dropzone
|
||||||
|
error={$validation.touched.file && $validation.errors.file}
|
||||||
|
gallery={false}
|
||||||
|
label="File to import"
|
||||||
|
value={[$values.file]}
|
||||||
|
on:change={e => {
|
||||||
|
$values.file = e.detail?.[0]
|
||||||
|
$validation.touched.file = true
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
<Input
|
||||||
|
autofocus={true}
|
||||||
|
bind:value={$values.name}
|
||||||
|
disabled={creating}
|
||||||
|
error={$validation.touched.name && $validation.errors.name}
|
||||||
|
on:blur={() => ($validation.touched.name = true)}
|
||||||
|
on:change={nameToUrl($values.name)}
|
||||||
|
label="Name"
|
||||||
|
placeholder={defaultAppName}
|
||||||
|
/>
|
||||||
|
<span>
|
||||||
|
<Input
|
||||||
|
bind:value={$values.url}
|
||||||
|
disabled={creating}
|
||||||
|
error={$validation.touched.url && $validation.errors.url}
|
||||||
|
on:blur={() => ($validation.touched.url = true)}
|
||||||
|
on:change={tidyUrl($values.url)}
|
||||||
|
label="URL"
|
||||||
|
placeholder={$values.url
|
||||||
|
? $values.url
|
||||||
|
: `/${resolveAppUrl(template, $values.name)}`}
|
||||||
|
/>
|
||||||
|
{#if $values.url && $values.url !== "" && !$validation.errors.url}
|
||||||
|
<div class="app-server" title={appUrl}>
|
||||||
|
{appUrl}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
{#if currentStep === Step.SET_PASSWORD}
|
||||||
|
<Input
|
||||||
|
autofocus={true}
|
||||||
|
label="Imported file password"
|
||||||
|
type="password"
|
||||||
|
bind:value={$values.encryptionPassword}
|
||||||
|
disabled={creating}
|
||||||
|
on:blur={() => ($encryptionValidation.touched.encryptionPassword = true)}
|
||||||
|
error={$encryptionValidation.touched.encryptionPassword &&
|
||||||
|
$encryptionValidation.errors.encryptionPassword}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
"src/**/*.spec.js",
|
"src/**/*.spec.js",
|
||||||
"../backend-core/dist/**/*"
|
"../backend-core/dist/**/*"
|
||||||
],
|
],
|
||||||
"exec": "node ./scripts/build.js && node ./dist/index.js"
|
"exec": "yarn build && node ./dist/index.js"
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
"airtable": "0.10.1",
|
"airtable": "0.10.1",
|
||||||
"arangojs": "7.2.0",
|
"arangojs": "7.2.0",
|
||||||
"aws-sdk": "2.1030.0",
|
"aws-sdk": "2.1030.0",
|
||||||
|
"bcrypt": "5.1.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"bull": "4.10.1",
|
"bull": "4.10.1",
|
||||||
"chmodr": "1.2.0",
|
"chmodr": "1.2.0",
|
||||||
|
|
|
@ -115,7 +115,18 @@ function checkAppName(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createInstance(appId: string, template: any) {
|
interface AppTemplate {
|
||||||
|
templateString: string
|
||||||
|
useTemplate: string
|
||||||
|
file?: {
|
||||||
|
type: string
|
||||||
|
path: string
|
||||||
|
password?: string
|
||||||
|
}
|
||||||
|
key?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createInstance(appId: string, template: AppTemplate) {
|
||||||
const db = context.getAppDB()
|
const db = context.getAppDB()
|
||||||
await db.put({
|
await db.put({
|
||||||
_id: "_design/database",
|
_id: "_design/database",
|
||||||
|
@ -240,19 +251,24 @@ export async function fetchAppPackage(ctx: UserCtx) {
|
||||||
async function performAppCreate(ctx: UserCtx) {
|
async function performAppCreate(ctx: UserCtx) {
|
||||||
const apps = (await dbCore.getAllApps({ dev: true })) as App[]
|
const apps = (await dbCore.getAllApps({ dev: true })) as App[]
|
||||||
const name = ctx.request.body.name,
|
const name = ctx.request.body.name,
|
||||||
possibleUrl = ctx.request.body.url
|
possibleUrl = ctx.request.body.url,
|
||||||
|
encryptionPassword = ctx.request.body.encryptionPassword
|
||||||
|
|
||||||
checkAppName(ctx, apps, name)
|
checkAppName(ctx, apps, name)
|
||||||
const url = sdk.applications.getAppUrl({ name, url: possibleUrl })
|
const url = sdk.applications.getAppUrl({ name, url: possibleUrl })
|
||||||
checkAppUrl(ctx, apps, url)
|
checkAppUrl(ctx, apps, url)
|
||||||
|
|
||||||
const { useTemplate, templateKey, templateString } = ctx.request.body
|
const { useTemplate, templateKey, templateString } = ctx.request.body
|
||||||
const instanceConfig: any = {
|
const instanceConfig: AppTemplate = {
|
||||||
useTemplate,
|
useTemplate,
|
||||||
key: templateKey,
|
key: templateKey,
|
||||||
templateString,
|
templateString,
|
||||||
}
|
}
|
||||||
if (ctx.request.files && ctx.request.files.templateFile) {
|
if (ctx.request.files && ctx.request.files.templateFile) {
|
||||||
instanceConfig.file = ctx.request.files.templateFile
|
instanceConfig.file = {
|
||||||
|
...(ctx.request.files.templateFile as any),
|
||||||
|
password: encryptionPassword,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const tenantId = tenancy.isMultiTenant() ? tenancy.getTenantId() : null
|
const tenantId = tenancy.isMultiTenant() ? tenancy.getTenantId() : null
|
||||||
const appId = generateDevAppID(generateAppID(tenantId))
|
const appId = generateDevAppID(generateAppID(tenantId))
|
||||||
|
|
|
@ -15,7 +15,6 @@ import * as api from "./api"
|
||||||
import * as automations from "./automations"
|
import * as automations from "./automations"
|
||||||
import { Thread } from "./threads"
|
import { Thread } from "./threads"
|
||||||
import * as redis from "./utilities/redis"
|
import * as redis from "./utilities/redis"
|
||||||
import { initialise as initialiseWebsockets } from "./websockets"
|
|
||||||
import { events, logging, middleware, timers } from "@budibase/backend-core"
|
import { events, logging, middleware, timers } from "@budibase/backend-core"
|
||||||
import { startup } from "./startup"
|
import { startup } from "./startup"
|
||||||
const Sentry = require("@sentry/node")
|
const Sentry = require("@sentry/node")
|
||||||
|
|
|
@ -489,7 +489,11 @@ class MongoIntegration implements IntegrationBase {
|
||||||
|
|
||||||
switch (query.extra.actionType) {
|
switch (query.extra.actionType) {
|
||||||
case "find": {
|
case "find": {
|
||||||
return await collection.find(json).toArray()
|
if (json) {
|
||||||
|
return await collection.find(json).toArray()
|
||||||
|
} else {
|
||||||
|
return await collection.find().toArray()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case "findOne": {
|
case "findOne": {
|
||||||
return await collection.findOne(json)
|
return await collection.findOne(json)
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
"@techpass/passport-openidconnect": "0.3.2",
|
"@techpass/passport-openidconnect": "0.3.2",
|
||||||
"@types/global-agent": "2.1.1",
|
"@types/global-agent": "2.1.1",
|
||||||
"aws-sdk": "2.1030.0",
|
"aws-sdk": "2.1030.0",
|
||||||
|
"bcrypt": "5.1.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"dd-trace": "3.13.2",
|
"dd-trace": "3.13.2",
|
||||||
"dotenv": "8.6.0",
|
"dotenv": "8.6.0",
|
||||||
|
|
|
@ -38,7 +38,7 @@ const MAX_USERS_UPLOAD_LIMIT = 1000
|
||||||
|
|
||||||
export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
export const save = async (ctx: UserCtx<User, SaveUserResponse>) => {
|
||||||
try {
|
try {
|
||||||
const currentUserId = ctx.user._id
|
const currentUserId = ctx.user?._id
|
||||||
const requestUser = ctx.request.body
|
const requestUser = ctx.request.body
|
||||||
|
|
||||||
const user = await userSdk.save(requestUser, { currentUserId })
|
const user = await userSdk.save(requestUser, { currentUserId })
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"setup": "yarn && node scripts/createEnv.js",
|
"setup": "yarn && node scripts/createEnv.js",
|
||||||
|
"user": "yarn && node scripts/createEnv.js && node scripts/createUser.js",
|
||||||
"test": "jest --runInBand --json --outputFile=testResults.json --forceExit",
|
"test": "jest --runInBand --json --outputFile=testResults.json --forceExit",
|
||||||
"test:watch": "yarn run test --watch",
|
"test:watch": "yarn run test --watch",
|
||||||
"test:debug": "DEBUG=1 yarn run test",
|
"test:debug": "DEBUG=1 yarn run test",
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
const dotenv = require("dotenv")
|
||||||
|
const { join } = require("path")
|
||||||
|
const fs = require("fs")
|
||||||
|
const fetch = require("node-fetch")
|
||||||
|
|
||||||
|
function getVarFromDotEnv(path, varName) {
|
||||||
|
const parsed = dotenv.parse(fs.readFileSync(path))
|
||||||
|
return parsed[varName]
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createUser() {
|
||||||
|
const serverPath = join(__dirname, "..", "..", "packages", "server", ".env")
|
||||||
|
const qaCorePath = join(__dirname, "..", ".env")
|
||||||
|
const apiKey = getVarFromDotEnv(serverPath, "INTERNAL_API_KEY")
|
||||||
|
const username = getVarFromDotEnv(qaCorePath, "BB_ADMIN_USER_EMAIL")
|
||||||
|
const password = getVarFromDotEnv(qaCorePath, "BB_ADMIN_USER_PASSWORD")
|
||||||
|
const url = getVarFromDotEnv(qaCorePath, "BUDIBASE_URL")
|
||||||
|
const resp = await fetch(`${url}/api/public/v1/users`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"x-budibase-api-key": apiKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
email: username,
|
||||||
|
password,
|
||||||
|
builder: {
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
|
admin: {
|
||||||
|
global: true,
|
||||||
|
},
|
||||||
|
roles: {},
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
if (resp.status !== 200) {
|
||||||
|
throw new Error(await resp.text())
|
||||||
|
} else {
|
||||||
|
return await resp.json()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
createUser()
|
||||||
|
.then(() => {
|
||||||
|
console.log("User created - ready to use")
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error("Failed to create user - ", err)
|
||||||
|
})
|
|
@ -67,11 +67,12 @@ export default class AccountInternalAPIClient {
|
||||||
}
|
}
|
||||||
const message = `${method} ${url} - ${response.status}`
|
const message = `${method} ${url} - ${response.status}`
|
||||||
|
|
||||||
|
const isDebug = process.env.LOG_LEVEL === "debug"
|
||||||
if (response.status > 499) {
|
if (response.status > 499) {
|
||||||
console.error(message, data)
|
console.error(message, data)
|
||||||
} else if (response.status >= 400) {
|
} else if (response.status >= 400) {
|
||||||
console.warn(message, data)
|
console.warn(message, data)
|
||||||
} else {
|
} else if (isDebug) {
|
||||||
console.debug(message, data)
|
console.debug(message, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,11 +58,12 @@ class BudibaseInternalAPIClient {
|
||||||
}
|
}
|
||||||
const message = `${method} ${url} - ${response.status}`
|
const message = `${method} ${url} - ${response.status}`
|
||||||
|
|
||||||
|
const isDebug = process.env.LOG_LEVEL === "debug"
|
||||||
if (response.status > 499) {
|
if (response.status > 499) {
|
||||||
console.error(message, data)
|
console.error(message, data)
|
||||||
} else if (response.status >= 400) {
|
} else if (response.status >= 400) {
|
||||||
console.warn(message, data)
|
console.warn(message, data)
|
||||||
} else {
|
} else if (isDebug) {
|
||||||
console.debug(message, data)
|
console.debug(message, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import TestConfiguration from "../../config/TestConfiguration"
|
||||||
import * as fixtures from "../../fixtures"
|
import * as fixtures from "../../fixtures"
|
||||||
import { Query } from "@budibase/types"
|
import { Query } from "@budibase/types"
|
||||||
|
|
||||||
describe("Internal API - Data Sources: MongoDB", () => {
|
xdescribe("Internal API - Data Sources: MongoDB", () => {
|
||||||
const config = new TestConfiguration()
|
const config = new TestConfiguration()
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
process.env.DISABLE_PINO_LOGGER = "1"
|
||||||
import { DEFAULT_TENANT_ID, logging } from "@budibase/backend-core"
|
import { DEFAULT_TENANT_ID, logging } from "@budibase/backend-core"
|
||||||
import { AccountInternalAPI } from "../account-api"
|
import { AccountInternalAPI } from "../account-api"
|
||||||
import * as fixtures from "../internal-api/fixtures"
|
import * as fixtures from "../internal-api/fixtures"
|
||||||
|
|
|
@ -57,11 +57,12 @@ class BudibasePublicAPIClient {
|
||||||
}
|
}
|
||||||
const message = `${method} ${url} - ${response.status}`
|
const message = `${method} ${url} - ${response.status}`
|
||||||
|
|
||||||
|
const isDebug = process.env.LOG_LEVEL === "debug"
|
||||||
if (response.status > 499) {
|
if (response.status > 499) {
|
||||||
console.error(message, data)
|
console.error(message, data)
|
||||||
} else if (response.status >= 400) {
|
} else if (response.status >= 400) {
|
||||||
console.warn(message, data)
|
console.warn(message, data)
|
||||||
} else {
|
} else if (isDebug) {
|
||||||
console.debug(message, data)
|
console.debug(message, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ const path = require("path")
|
||||||
|
|
||||||
const { build } = require("esbuild")
|
const { build } = require("esbuild")
|
||||||
|
|
||||||
const { default: NodeResolve } = require("@esbuild-plugins/node-resolve")
|
|
||||||
const {
|
const {
|
||||||
default: TsconfigPathsPlugin,
|
default: TsconfigPathsPlugin,
|
||||||
} = require("@esbuild-plugins/tsconfig-paths")
|
} = require("@esbuild-plugins/tsconfig-paths")
|
||||||
|
const { nodeExternalsPlugin } = require("esbuild-node-externals")
|
||||||
|
|
||||||
var argv = require("minimist")(process.argv.slice(2))
|
var argv = require("minimist")(process.argv.slice(2))
|
||||||
|
|
||||||
|
@ -25,32 +25,28 @@ function runBuild(entry, outfile) {
|
||||||
minify: !isDev,
|
minify: !isDev,
|
||||||
sourcemap: isDev,
|
sourcemap: isDev,
|
||||||
tsconfig,
|
tsconfig,
|
||||||
plugins: [
|
plugins: [TsconfigPathsPlugin({ tsconfig }), nodeExternalsPlugin()],
|
||||||
TsconfigPathsPlugin({ tsconfig }),
|
|
||||||
NodeResolve({
|
|
||||||
extensions: [".ts", ".js"],
|
|
||||||
onResolved: resolved => {
|
|
||||||
if (resolved.includes("node_modules") && !resolved.includes("/@budibase/pro/")) {
|
|
||||||
return {
|
|
||||||
external: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return resolved
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
target: "node14",
|
target: "node14",
|
||||||
preserveSymlinks: true,
|
preserveSymlinks: true,
|
||||||
loader: {
|
loader: {
|
||||||
".svelte": "copy",
|
".svelte": "copy",
|
||||||
},
|
},
|
||||||
|
metafile: true,
|
||||||
|
external: [
|
||||||
|
"deasync",
|
||||||
|
"mock-aws-s3",
|
||||||
|
"nock",
|
||||||
|
"pino",
|
||||||
|
"koa-pino-logger",
|
||||||
|
"bull",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
build({
|
build({
|
||||||
...sharedConfig,
|
...sharedConfig,
|
||||||
platform: "node",
|
platform: "node",
|
||||||
outfile,
|
outfile,
|
||||||
}).then(() => {
|
}).then(result => {
|
||||||
glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => {
|
glob(`${process.cwd()}/src/**/*.hbs`, {}, (err, files) => {
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`)
|
fs.copyFileSync(file, `${process.cwd()}/dist/${path.basename(file)}`)
|
||||||
|
@ -61,6 +57,11 @@ function runBuild(entry, outfile) {
|
||||||
`Build successfully in ${(Date.now() - start) / 1000} seconds`
|
`Build successfully in ${(Date.now() - start) / 1000} seconds`
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
fs.writeFileSync(
|
||||||
|
`dist/${path.basename(outfile)}.meta.json`,
|
||||||
|
JSON.stringify(result.metafile)
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue