server tests in-memory and passing
This commit is contained in:
parent
13bbc3956e
commit
97db4f1765
|
@ -16,8 +16,8 @@ export const getBackendUiStore = () => {
|
|||
store.actions = {
|
||||
database: {
|
||||
select: async db => {
|
||||
const modelsResponse = await api.get(`/api/${db.id}/models`)
|
||||
const viewsResponse = await api.get(`/api/${db.id}/views`)
|
||||
const modelsResponse = await api.get(`/api/${db._id}/models`)
|
||||
const viewsResponse = await api.get(`/api/${db._id}/views`)
|
||||
const models = await modelsResponse.json()
|
||||
const views = await viewsResponse.json()
|
||||
store.update(state => {
|
||||
|
@ -37,7 +37,7 @@ export const getBackendUiStore = () => {
|
|||
}),
|
||||
view: record =>
|
||||
store.update(state => {
|
||||
state.breadcrumbs = [state.selectedDatabase.name, record.id]
|
||||
state.breadcrumbs = [state.selectedDatabase.name, record._id]
|
||||
return state
|
||||
}),
|
||||
select: record =>
|
||||
|
|
|
@ -354,7 +354,7 @@ const addChildComponent = store => (componentToAdd, presetName) => {
|
|||
|
||||
const presetProps = presetName ? component.presets[presetName] : {}
|
||||
|
||||
const instanceId = get(backendUiStore).selectedDatabase.id;
|
||||
const instanceId = get(backendUiStore).selectedDatabase._id;
|
||||
|
||||
const newComponent = createProps(component, {
|
||||
...presetProps,
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
async function selectRecord(record) {
|
||||
return await api.loadRecord(record.key, {
|
||||
appname: $store.appname,
|
||||
instanceId: $backendUiStore.selectedDatabase.id,
|
||||
instanceId: $backendUiStore.selectedDatabase._id,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
let views = []
|
||||
let currentPage = 0
|
||||
|
||||
$: instanceId = $backendUiStore.selectedDatabase.id
|
||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||
|
||||
$: {
|
||||
if ($backendUiStore.selectedView) {
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
import api from "builderStore/api"
|
||||
|
||||
export async function createUser(user, appId, instanceId) {
|
||||
const CREATE_USER_URL = `/api/${appId}/${instanceId}/users`
|
||||
const CREATE_USER_URL = `/api/${instanceId}/users`
|
||||
const response = await api.post(CREATE_USER_URL, user)
|
||||
const json = await response.json()
|
||||
return json.user
|
||||
return await response.json()
|
||||
}
|
||||
|
||||
export async function createDatabase(clientId, appname, instanceName) {
|
||||
const CREATE_DATABASE_URL = `/api/${clientId}/${appname}/instances`
|
||||
export async function createDatabase(appname, instanceName) {
|
||||
const CREATE_DATABASE_URL = `/api/${appname}/instances`
|
||||
const response = await api.post(CREATE_DATABASE_URL, {
|
||||
name: instanceName,
|
||||
})
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
|
||||
async function createDatabase() {
|
||||
const response = await api.createDatabase(
|
||||
$store.clientId,
|
||||
$store.appId,
|
||||
databaseName
|
||||
)
|
||||
store.createDatabaseForApp(response.instance)
|
||||
store.createDatabaseForApp(response)
|
||||
onClosed()
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
let fieldToEdit
|
||||
|
||||
$: modelFields = model.schema ? Object.entries(model.schema) : []
|
||||
$: instanceId = $backendUiStore.selectedDatabase.id
|
||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||
|
||||
function editField() {}
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
|||
const SAVE_MODEL_URL = `/api/${instanceId}/models`
|
||||
const response = await api.post(SAVE_MODEL_URL, model)
|
||||
const newModel = await response.json()
|
||||
backendUiStore.actions.models.create(newModel.model)
|
||||
backendUiStore.actions.models.create(newModel)
|
||||
onClosed()
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
let errors = []
|
||||
let selectedModel
|
||||
|
||||
$: instanceId = $backendUiStore.selectedDatabase.id
|
||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||
|
||||
$: modelSchema = $backendUiStore.selectedModel
|
||||
? Object.entries($backendUiStore.selectedModel.schema)
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
let currentSnippetEditor = SNIPPET_EDITORS.MAP
|
||||
|
||||
$: instanceId = $backendUiStore.selectedDatabase.id
|
||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||
|
||||
function deleteView() {}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
let password
|
||||
|
||||
$: valid = username && password
|
||||
$: instanceId = $backendUiStore.selectedDatabase.id
|
||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||
$: appId = $store.appId
|
||||
|
||||
async function createUser() {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
export let record
|
||||
export let onClosed
|
||||
|
||||
$: instanceId = $backendUiStore.selectedDatabase.id
|
||||
$: instanceId = $backendUiStore.selectedDatabase._id
|
||||
</script>
|
||||
|
||||
<section>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
{#if $backendUiStore.selectedDatabase.id}
|
||||
{#if $backendUiStore.selectedDatabase._id}
|
||||
<div class="hierarchy">
|
||||
<div class="components-list-container">
|
||||
<div class="nav-group-header">
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
const response = await api.delete(DELETE_DATABASE_URL)
|
||||
store.update(state => {
|
||||
state.appInstances = state.appInstances.filter(
|
||||
db => db.id !== database.id
|
||||
db => db._id !== database._id
|
||||
)
|
||||
return state
|
||||
})
|
||||
|
@ -28,14 +28,14 @@
|
|||
{#each $store.appInstances as database}
|
||||
<li>
|
||||
<span class="icon">
|
||||
{#if database.id === $backendUiStore.selectedDatabase.id}
|
||||
{#if database._id === $backendUiStore.selectedDatabase._id}
|
||||
<CheckIcon />
|
||||
{/if}
|
||||
</span>
|
||||
<button
|
||||
class:active={database.id === $backendUiStore.selectedDatabase.id}
|
||||
class:active={database._id === $backendUiStore.selectedDatabase._id}
|
||||
on:click={() => {
|
||||
$goto(`./database/${database.id}`), selectDatabase(database)
|
||||
$goto(`./database/${database._id}`), selectDatabase(database)
|
||||
}}>
|
||||
{database.name}
|
||||
</button>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
$: currentAppInfo = {
|
||||
appname: $store.appname,
|
||||
instanceId: $backendUiStore.selectedDatabase.id,
|
||||
instanceId: $backendUiStore.selectedDatabase._id,
|
||||
}
|
||||
|
||||
async function fetchUsers() {
|
||||
|
@ -33,7 +33,7 @@
|
|||
{#each $backendUiStore.users as user}
|
||||
<li>
|
||||
<i class="ri-user-4-line" />
|
||||
<button class:active={user.id === $store.currentUserId}>
|
||||
<button class:active={user.username === $store.currentUserName}>
|
||||
{user.name}
|
||||
</button>
|
||||
</li>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
</ActionButton>
|
||||
{/if}
|
||||
</div>
|
||||
{#if $backendUiStore.selectedDatabase.id}
|
||||
{#if $backendUiStore.selectedDatabase._id}
|
||||
<ModelDataTable {selectRecord} />
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
onMount(async () => {
|
||||
if ($store.appInstances.length > 0) {
|
||||
await selectDatabase($store.appInstances[0])
|
||||
$goto(`./${$backendUiStore.selectedDatabase.id}`)
|
||||
$goto(`./${$backendUiStore.selectedDatabase._id}`)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
onMount(async () => {
|
||||
if ($store.appInstances.length > 0) {
|
||||
await selectDatabase($store.appInstances[0])
|
||||
$goto(`../${$backendUiStore.selectedDatabase.id}`)
|
||||
$goto(`../${$backendUiStore.selectedDatabase._id}`)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
let promise = getApps()
|
||||
|
||||
async function getApps() {
|
||||
const res = await fetch(`/api/${$store.clientId}/applications`)
|
||||
const res = await fetch(`/api/applications`)
|
||||
const json = await res.json()
|
||||
|
||||
if (res.ok) {
|
||||
|
|
|
@ -3,7 +3,7 @@ const { exists, readFile, writeFile, ensureDir } = require("fs-extra")
|
|||
const chalk = require("chalk")
|
||||
const { serverFileName, xPlatHomeDir } = require("../../common")
|
||||
const { join } = require("path")
|
||||
const initialiseClientDb = require("@budibase/server/src/db/initialiseClientDb")
|
||||
const { create } = require("@budibase/server/src/db/clientDb")
|
||||
const Sqrl = require("squirrelly")
|
||||
const uuid = require("uuid")
|
||||
const CouchDB = require("@budibase/server/src/db/client")
|
||||
|
@ -68,8 +68,7 @@ const createClientDatabase = async opts => {
|
|||
}
|
||||
}
|
||||
|
||||
const db = new CouchDB(`client-${opts.clientId}`)
|
||||
await initialiseClientDb(db)
|
||||
await create(opts.clientId)
|
||||
}
|
||||
|
||||
const createDevEnvFile = async opts => {
|
||||
|
|
|
@ -5,6 +5,7 @@ module.exports = ({ dir }) => {
|
|||
dir = xPlatHomeDir(dir)
|
||||
process.env.BUDIBASE_DIR = resolve(dir)
|
||||
require("dotenv").config({ path: resolve(dir, ".env") })
|
||||
require("@budibase/server/src/app")
|
||||
console.log(`Budibase Builder running on port ${process.env.PORT}..`)
|
||||
require("@budibase/server/src/app")().then(() => {
|
||||
console.log(`Budibase Builder running on port ${process.env.PORT}..`)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -2,10 +2,6 @@
|
|||
# http://admin:password@localhost:5984
|
||||
COUCH_DB_URL={{couchDbUrl}}
|
||||
|
||||
# local (PouchDB) - default for dev
|
||||
# remote (CouchDB) - required couch db installation
|
||||
DATABASE_TYPE={{database}}
|
||||
|
||||
# identifies a client database - i.e. group of apps
|
||||
CLIENT_ID={{clientId}}
|
||||
|
||||
|
@ -13,8 +9,7 @@ CLIENT_ID={{clientId}}
|
|||
ADMIN_SECRET={{adminSecret}}
|
||||
|
||||
# used to create cookie hashes
|
||||
COOKIE_KEY_1={{cookieKey1}}
|
||||
COOKIE_KEY_2={{cookieKey2}}
|
||||
JWT_SECRET={{cookieKey1}}
|
||||
|
||||
# port to run http server on
|
||||
PORT=4001
|
|
@ -11,38 +11,103 @@
|
|||
"program": "${workspaceFolder}/src/index.js"
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest App Server",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["apps", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest Builder",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["builder", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Initialise Budibase",
|
||||
"program": "yarn",
|
||||
"args": ["run", "initialise"],
|
||||
"console": "externalTerminal"
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest - All",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": [],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest - Users",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["user.spec", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest - Instances",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["instance.spec", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest - Records",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["record.spec", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest - Models",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["model.spec", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest - Views",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["view.spec", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Jest Builder",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": ["builder", "--runInBand"],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest-cli/bin/jest",
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"name": "Initialise Budibase",
|
||||
"program": "yarn",
|
||||
"args": ["run", "initialise"],
|
||||
"console": "externalTerminal"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -50,11 +50,13 @@
|
|||
"eslint": "^6.8.0",
|
||||
"jest": "^24.8.0",
|
||||
"nodemon": "^2.0.2",
|
||||
"pouchdb-adapter-memory": "^7.2.1",
|
||||
"server-destroy": "^1.0.1",
|
||||
"supertest": "^4.0.2"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node"
|
||||
"testEnvironment": "node",
|
||||
"setupFiles": ["./scripts/jestSetup.js"]
|
||||
},
|
||||
"gitHead": "b1f4f90927d9e494e513220ef060af28d2d42455"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
const { tmpdir } = require("os")
|
||||
|
||||
process.env.NODE_ENV = "jest"
|
||||
process.env.JWT_SECRET = "test-jwtsecret"
|
||||
process.env.CLIENT_ID = "test-client-id"
|
||||
process.env.BUDIBASE_DIR = tmpdir("budibase-unittests")
|
||||
process.env.ADMIN_SECRET = "test-admin-secret"
|
||||
|
||||
// makes the output of the tests messy
|
||||
// but please temporarily enable for debugging :)
|
||||
process.env.LOGGER = "off"
|
|
@ -1,8 +1,10 @@
|
|||
const CouchDB = require("../../db")
|
||||
const { getPackageForBuilder } = require("../../utilities/builder")
|
||||
const uuid = require("uuid")
|
||||
const env = require("../../environment")
|
||||
|
||||
exports.fetch = async function(ctx) {
|
||||
const clientDb = new CouchDB(`client-${ctx.params.clientId}`)
|
||||
const clientDb = new CouchDB(`client-${env.CLIENT_ID}`)
|
||||
const body = await clientDb.query("client/by_type", {
|
||||
include_docs: true,
|
||||
key: ["app"],
|
||||
|
@ -12,14 +14,16 @@ exports.fetch = async function(ctx) {
|
|||
}
|
||||
|
||||
exports.fetchAppPackage = async function(ctx) {
|
||||
const clientDb = new CouchDB(`client-${ctx.params.clientId}`)
|
||||
const clientDb = new CouchDB(`client-${env.CLIENT_ID}`)
|
||||
const application = await clientDb.get(ctx.params.applicationId)
|
||||
ctx.body = await getPackageForBuilder(ctx.config, application)
|
||||
}
|
||||
|
||||
exports.create = async function(ctx) {
|
||||
const clientDb = new CouchDB(`client-${ctx.params.clientId}`)
|
||||
const { id, rev } = await clientDb.post({
|
||||
const clientDb = new CouchDB(`client-${env.CLIENT_ID}`)
|
||||
|
||||
const newApplication = {
|
||||
_id: uuid.v4().replace(/-/g, ""),
|
||||
type: "app",
|
||||
instances: [],
|
||||
userInstanceMap: {},
|
||||
|
@ -28,11 +32,10 @@ exports.create = async function(ctx) {
|
|||
"@budibase/materialdesign-components",
|
||||
],
|
||||
...ctx.request.body,
|
||||
})
|
||||
|
||||
ctx.body = {
|
||||
id,
|
||||
rev,
|
||||
message: `Application ${ctx.request.body.name} created successfully`,
|
||||
}
|
||||
|
||||
const { rev } = await clientDb.post(newApplication)
|
||||
newApplication._rev = rev
|
||||
ctx.body = newApplication
|
||||
ctx.message = `Application ${ctx.request.body.name} created successfully`
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const jwt = require("jsonwebtoken")
|
||||
const CouchDB = require("../../db")
|
||||
const bcrypt = require("../../utilities/bcrypt")
|
||||
const env = require("../../environment")
|
||||
|
||||
exports.authenticate = async ctx => {
|
||||
const { username, password } = ctx.request.body
|
||||
|
@ -13,7 +14,7 @@ exports.authenticate = async ctx => {
|
|||
const appId = referer[3]
|
||||
|
||||
// find the instance that the user is associated with
|
||||
const db = new CouchDB(`client-${process.env.CLIENT_ID}`)
|
||||
const db = new CouchDB(`client-${env.CLIENT_ID}`)
|
||||
const app = await db.get(appId)
|
||||
const instanceId = app.userInstanceMap[username]
|
||||
|
||||
|
|
|
@ -1,36 +1,18 @@
|
|||
const CouchDB = require("../../db")
|
||||
const { create, destroy } = require("../../db/clientDb")
|
||||
const env = require("../../environment")
|
||||
|
||||
exports.getClientId = async function(ctx) {
|
||||
ctx.body = process.env.CLIENT_ID
|
||||
ctx.body = env.CLIENT_ID
|
||||
}
|
||||
|
||||
exports.create = async function(ctx) {
|
||||
const clientId = `client-${ctx.request.body.clientId}`
|
||||
const db = new CouchDB(clientId)
|
||||
|
||||
await db.put({
|
||||
_id: "_design/client",
|
||||
views: {
|
||||
by_type: {
|
||||
map: function(doc) {
|
||||
emit([doc.type], doc._id)
|
||||
}.toString(),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
ctx.body = {
|
||||
message: `Client Database ${clientId} successfully provisioned.`,
|
||||
}
|
||||
await create(env.CLIENT_ID)
|
||||
ctx.status = 200
|
||||
ctx.message = `Client Database ${env.CLIENT_ID} successfully provisioned.`
|
||||
}
|
||||
|
||||
exports.destroy = async function(ctx) {
|
||||
const dbId = `client-${ctx.params.clientId}`
|
||||
|
||||
await new CouchDB(dbId).destroy()
|
||||
|
||||
ctx.body = {
|
||||
status: 200,
|
||||
message: `Client Database ${dbId} successfully deleted.`,
|
||||
}
|
||||
await destroy(env.CLIENT_ID)
|
||||
ctx.status = 200
|
||||
ctx.message = `Client Database ${env.CLIENT_ID} successfully deleted.`
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
const CouchDB = require("../../db")
|
||||
const uuid = require("uuid")
|
||||
const env = require("../../environment")
|
||||
|
||||
const clientDatabaseId = clientId => `client-${clientId}`
|
||||
|
||||
exports.create = async function(ctx) {
|
||||
const instanceName = ctx.request.body.name
|
||||
const instanceId = `app_${ctx.params.applicationId.substring(6)}_inst_${uuid.v4()}`
|
||||
const { clientId, applicationId } = ctx.params
|
||||
const uid = uuid.v4().replace(/-/g, "")
|
||||
const instanceId = `${ctx.params.applicationId.substring(0,7)}_${uid}`
|
||||
const { applicationId } = ctx.params
|
||||
const clientId = env.CLIENT_ID
|
||||
const db = new CouchDB(instanceId)
|
||||
await db.put({
|
||||
_id: "_design/database",
|
||||
|
@ -29,18 +34,15 @@ exports.create = async function(ctx) {
|
|||
})
|
||||
|
||||
// Add the new instance under the app clientDB
|
||||
const clientDatabaseId = `client-${clientId}`
|
||||
const clientDb = new CouchDB(clientDatabaseId)
|
||||
const clientDb = new CouchDB(clientDatabaseId(clientId))
|
||||
const budibaseApp = await clientDb.get(applicationId)
|
||||
const instance = { id: instanceId, name: instanceName }
|
||||
const instance = { _id: instanceId, name: instanceName }
|
||||
budibaseApp.instances.push(instance)
|
||||
await clientDb.put(budibaseApp)
|
||||
|
||||
ctx.body = {
|
||||
message: `Instance Database ${instanceName} successfully provisioned.`,
|
||||
status: 200,
|
||||
instance,
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.message = `Instance Database ${instanceName} successfully provisioned.`
|
||||
ctx.body = instance
|
||||
}
|
||||
|
||||
exports.destroy = async function(ctx) {
|
||||
|
@ -50,15 +52,13 @@ exports.destroy = async function(ctx) {
|
|||
|
||||
// remove instance from client application document
|
||||
const { metadata } = designDoc
|
||||
const clientDb = new CouchDB(metadata.clientId)
|
||||
const clientDb = new CouchDB(clientDatabaseId(metadata.clientId))
|
||||
const budibaseApp = await clientDb.get(metadata.applicationId)
|
||||
budibaseApp.instances = budibaseApp.instances.filter(
|
||||
instance => instance !== ctx.params.instanceId
|
||||
)
|
||||
await clientDb.put(budibaseApp)
|
||||
|
||||
ctx.body = {
|
||||
message: `Instance Database ${ctx.params.instanceId} successfully destroyed.`,
|
||||
status: 200,
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.message = `Instance Database ${ctx.params.instanceId} successfully destroyed.`
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const CouchDB = require("../../db")
|
||||
const uuid = require("uuid")
|
||||
|
||||
exports.fetch = async function(ctx) {
|
||||
const db = new CouchDB(ctx.params.instanceId)
|
||||
|
@ -11,17 +12,21 @@ exports.fetch = async function(ctx) {
|
|||
|
||||
exports.create = async function(ctx) {
|
||||
const db = new CouchDB(ctx.params.instanceId)
|
||||
const newModel = await db.post({
|
||||
const newModel = {
|
||||
type: "model",
|
||||
...ctx.request.body,
|
||||
})
|
||||
_id: uuid.v4().replace(/-/g, ""),
|
||||
}
|
||||
|
||||
const result = await db.post(newModel)
|
||||
newModel._rev = result.rev
|
||||
|
||||
const designDoc = await db.get("_design/database")
|
||||
designDoc.views = {
|
||||
...designDoc.views,
|
||||
[`all_${newModel.id}`]: {
|
||||
[`all_${newModel._id}`]: {
|
||||
map: `function(doc) {
|
||||
if (doc.modelId === "${newModel.id}") {
|
||||
if (doc.modelId === "${newModel._id}") {
|
||||
emit(doc[doc.key], doc._id);
|
||||
}
|
||||
}`,
|
||||
|
@ -29,15 +34,9 @@ exports.create = async function(ctx) {
|
|||
}
|
||||
await db.put(designDoc)
|
||||
|
||||
ctx.body = {
|
||||
message: `Model ${ctx.request.body.name} created successfully.`,
|
||||
status: 200,
|
||||
model: {
|
||||
_id: newModel.id,
|
||||
_rev: newModel.rev,
|
||||
...ctx.request.body,
|
||||
},
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.message = `Model ${ctx.request.body.name} created successfully.`
|
||||
ctx.body = newModel
|
||||
}
|
||||
|
||||
exports.update = async function(ctx) {}
|
||||
|
@ -45,8 +44,8 @@ exports.update = async function(ctx) {}
|
|||
exports.destroy = async function(ctx) {
|
||||
const db = new CouchDB(ctx.params.instanceId)
|
||||
|
||||
const model = await db.remove(ctx.params.modelId, ctx.params.revId)
|
||||
const modelViewId = `all_${model.id}`
|
||||
await db.remove(ctx.params.modelId, ctx.params.revId)
|
||||
const modelViewId = `all_${ctx.params.modelId}`
|
||||
|
||||
// Delete all records for that model
|
||||
const records = await db.query(`database/${modelViewId}`)
|
||||
|
@ -59,8 +58,6 @@ exports.destroy = async function(ctx) {
|
|||
delete designDoc.views[modelViewId]
|
||||
await db.put(designDoc)
|
||||
|
||||
ctx.body = {
|
||||
message: `Model ${model.id} deleted.`,
|
||||
status: 200,
|
||||
}
|
||||
ctx.status = 200
|
||||
ctx.message = `Model ${ctx.params.modelId} deleted.`
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const CouchDB = require("../../db")
|
||||
const Ajv = require("ajv")
|
||||
const uuid = require("uuid")
|
||||
|
||||
const ajv = new Ajv()
|
||||
|
||||
|
@ -7,6 +8,10 @@ exports.save = async function(ctx) {
|
|||
const db = new CouchDB(ctx.params.instanceId)
|
||||
const record = ctx.request.body
|
||||
|
||||
if (!record._rev && !record._id) {
|
||||
record._id = uuid.v4().replace(/-/, "")
|
||||
}
|
||||
|
||||
// validation with ajv
|
||||
const model = await db.get(record.modelId)
|
||||
const validate = ajv.compile({
|
||||
|
@ -23,18 +28,15 @@ exports.save = async function(ctx) {
|
|||
return
|
||||
}
|
||||
|
||||
const existingRecord = record._id && (await db.get(record._id))
|
||||
const existingRecord = record._rev && (await db.get(record._id))
|
||||
|
||||
if (existingRecord) {
|
||||
const response = await db.put({ ...record, _id: existingRecord._id })
|
||||
ctx.body = {
|
||||
message: `${model.name} updated successfully.`,
|
||||
status: 200,
|
||||
record: {
|
||||
...record,
|
||||
...response,
|
||||
},
|
||||
}
|
||||
const response = await db.put(record)
|
||||
record._rev = response.rev
|
||||
record.type = "record"
|
||||
ctx.body = record
|
||||
ctx.status = 200
|
||||
ctx.message = `${model.name} updated successfully.`
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -45,10 +47,7 @@ exports.save = async function(ctx) {
|
|||
// record: record,
|
||||
// })
|
||||
|
||||
ctx.body = {
|
||||
...record,
|
||||
...response
|
||||
}
|
||||
ctx.body = record
|
||||
ctx.status = 200
|
||||
ctx.message = `${model.name} created successfully`
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
const CouchDB = require("../../db")
|
||||
const bcrypt = require("../../utilities/bcrypt")
|
||||
const env = require("../../environment")
|
||||
|
||||
const getUserId = userName => `user_${userName}`
|
||||
|
||||
exports.fetch = async function(ctx) {
|
||||
const database = new CouchDB(ctx.params.instanceId)
|
||||
|
@ -13,20 +16,22 @@ exports.fetch = async function(ctx) {
|
|||
|
||||
exports.create = async function(ctx) {
|
||||
const database = new CouchDB(ctx.params.instanceId)
|
||||
const appId = (await database.get("_design/database")).metadata.applicationId
|
||||
const { username, password, name } = ctx.request.body
|
||||
|
||||
if (!username || !password) ctx.throw(400, "Username and Password Required.")
|
||||
|
||||
const response = await database.post({
|
||||
_id: getUserId(username),
|
||||
username,
|
||||
password: await bcrypt.hash(password),
|
||||
name,
|
||||
name: name || username,
|
||||
type: "user",
|
||||
})
|
||||
|
||||
// the clientDB needs to store a map of users against the app
|
||||
const clientDb = new CouchDB(`client-${process.env.CLIENT_ID}`)
|
||||
const app = await clientDb.get(ctx.params.appId)
|
||||
const clientDb = new CouchDB(`client-${env.CLIENT_ID}`)
|
||||
const app = await clientDb.get(appId)
|
||||
|
||||
app.userInstanceMap = {
|
||||
...app.userInstanceMap,
|
||||
|
@ -34,24 +39,28 @@ exports.create = async function(ctx) {
|
|||
}
|
||||
await clientDb.put(app)
|
||||
|
||||
ctx.status = 200
|
||||
ctx.message = "User created successfully."
|
||||
ctx.body = {
|
||||
user: {
|
||||
id: response.id,
|
||||
rev: response.rev,
|
||||
username,
|
||||
name,
|
||||
},
|
||||
message: `User created successfully.`,
|
||||
status: 200,
|
||||
_rev: response.rev,
|
||||
username,
|
||||
name,
|
||||
}
|
||||
}
|
||||
|
||||
exports.destroy = async function(ctx) {
|
||||
const database = new CouchDB(ctx.params.instanceId)
|
||||
const response = await database.destroy(ctx.params.userId)
|
||||
await database.destroy(getUserId(ctx.params.username))
|
||||
ctx.message = `User ${ctx.params.username} deleted.`
|
||||
ctx.status = 200
|
||||
}
|
||||
|
||||
exports.find = async function(ctx) {
|
||||
const database = new CouchDB(ctx.params.instanceId)
|
||||
const user = await database.get(getUserId(ctx.params.username))
|
||||
ctx.body = {
|
||||
...response,
|
||||
message: `User deleted.`,
|
||||
status: 200,
|
||||
username: user.username,
|
||||
name: user.name,
|
||||
_rev: user._rev,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,23 +24,17 @@ const controller = {
|
|||
},
|
||||
create: async ctx => {
|
||||
const db = new CouchDB(ctx.params.instanceId)
|
||||
const { name, ...viewDefinition } = ctx.request.body
|
||||
const newView = ctx.request.body
|
||||
|
||||
const designDoc = await db.get("_design/database")
|
||||
designDoc.views = {
|
||||
...designDoc.views,
|
||||
[name]: viewDefinition,
|
||||
[newView.name]: newView,
|
||||
}
|
||||
const newView = await db.put(designDoc)
|
||||
await db.put(designDoc)
|
||||
|
||||
ctx.body = {
|
||||
view: {
|
||||
...ctx.request.body,
|
||||
...newView,
|
||||
},
|
||||
message: `View ${name} created successfully.`,
|
||||
status: 200,
|
||||
}
|
||||
ctx.body = newView
|
||||
ctx.message = `View ${newView.name} created successfully.`
|
||||
},
|
||||
destroy: async ctx => {
|
||||
const db = new CouchDB(ctx.params.instanceId)
|
||||
|
|
|
@ -18,6 +18,7 @@ const {
|
|||
} = require("./routes")
|
||||
|
||||
const router = new Router()
|
||||
const env = require("../environment")
|
||||
|
||||
router
|
||||
.use(
|
||||
|
@ -34,9 +35,9 @@ router
|
|||
.use(async (ctx, next) => {
|
||||
ctx.config = {
|
||||
latestPackagesFolder: budibaseAppsDir(),
|
||||
jwtSecret: process.env.JWT_SECRET,
|
||||
jwtSecret: env.JWT_SECRET,
|
||||
}
|
||||
ctx.isDev = process.env.NODE_ENV !== "production"
|
||||
ctx.isDev = env.NODE_ENV !== "production" && env.NODE_ENV !== "jest"
|
||||
await next()
|
||||
})
|
||||
.use(authenticated)
|
||||
|
@ -46,7 +47,7 @@ router.use(async (ctx, next) => {
|
|||
try {
|
||||
await next()
|
||||
} catch (err) {
|
||||
console.trace(err)
|
||||
if (env.LOGGER !== "off") console.trace(err)
|
||||
ctx.status = err.status || err.statusCode || 500
|
||||
ctx.body = {
|
||||
message: err.message,
|
||||
|
|
|
@ -4,8 +4,8 @@ const controller = require("../controllers/application")
|
|||
const router = Router()
|
||||
|
||||
router
|
||||
.get("/api/:clientId/applications", controller.fetch)
|
||||
.get("/api/:clientId/:applicationId/appPackage", controller.fetchAppPackage)
|
||||
.post("/api/:clientId/applications", controller.create)
|
||||
.get("/api/applications", controller.fetch)
|
||||
.get("/api/:applicationId/appPackage", controller.fetchAppPackage)
|
||||
.post("/api/applications", controller.create)
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
const Router = require("@koa/router")
|
||||
const controller = require("../controllers/client")
|
||||
const env = require("../../environment")
|
||||
|
||||
const router = Router()
|
||||
|
||||
router
|
||||
.get("/api/client/id", controller.getClientId)
|
||||
.post("/api/clients", controller.create)
|
||||
.delete("/api/clients/:clientId", controller.destroy)
|
||||
router.get("/api/client/id", controller.getClientId)
|
||||
|
||||
if (env.NODE_ENV === "jest") {
|
||||
router
|
||||
.post("/api/client", controller.create)
|
||||
.delete("/api/client", controller.destroy)
|
||||
}
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -4,7 +4,7 @@ const controller = require("../controllers/instance")
|
|||
const router = Router()
|
||||
|
||||
router
|
||||
.post("/api/:clientId/:applicationId/instances", controller.create)
|
||||
.post("/api/:applicationId/instances", controller.create)
|
||||
.delete("/api/instances/:instanceId", controller.destroy)
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -1,35 +1,32 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const { createClientDatabase, destroyDatabase } = require("./couchTestUtils");
|
||||
|
||||
|
||||
const CLIENT_DB_ID = "client-testing";
|
||||
const {
|
||||
createClientDatabase,
|
||||
supertest
|
||||
} = require("./couchTestUtils")
|
||||
|
||||
describe("/applications", () => {
|
||||
let request;
|
||||
let server;
|
||||
let request
|
||||
let server
|
||||
|
||||
beforeAll(async () => {
|
||||
server = app;
|
||||
request = supertest(server);
|
||||
await createClientDatabase();
|
||||
({ request, server } = await supertest())
|
||||
await createClientDatabase(request)
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
server.close();
|
||||
await destroyDatabase(CLIENT_DB_ID)
|
||||
server.close()
|
||||
})
|
||||
|
||||
describe("create", () => {
|
||||
it("returns a success message when the application is successfully created", done => {
|
||||
request
|
||||
.post("/api/testing/applications")
|
||||
.post("/api/applications")
|
||||
.send({ name: "My App" })
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end((err, res) => {
|
||||
expect(res.body.message).toEqual("Application My App created successfully");
|
||||
expect(res.res.statusMessage).toEqual("Application My App created successfully")
|
||||
expect(res.body._id).toBeDefined()
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
|
|
@ -1,58 +1,48 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const { createClientDatabase, destroyClientDatabase } = require("./couchTestUtils")
|
||||
const {
|
||||
createClientDatabase,
|
||||
destroyClientDatabase,
|
||||
supertest,
|
||||
} = require("./couchTestUtils")
|
||||
|
||||
|
||||
const CLIENT_DB_ID = "client-testing";
|
||||
const CLIENT_ID = "test-client-id"
|
||||
|
||||
describe("/clients", () => {
|
||||
let request;
|
||||
let server;
|
||||
let db;
|
||||
|
||||
beforeAll(async () => {
|
||||
server = app
|
||||
request = supertest(server);
|
||||
beforeEach(async () => {
|
||||
({ request, server } = await supertest())
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
afterEach(async () => {
|
||||
server.close();
|
||||
})
|
||||
|
||||
describe("create", () => {
|
||||
afterEach(async () => {
|
||||
await destroyClientDatabase();
|
||||
});
|
||||
|
||||
it("returns a success message when the client database is successfully created", done => {
|
||||
request
|
||||
.post("/api/clients")
|
||||
it("returns a success message when the client database is successfully created", async () => {
|
||||
const res = await request
|
||||
.post("/api/client")
|
||||
.send({ clientId: "testing" })
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end((err, res) => {
|
||||
expect(res.body.message).toEqual(`Client Database ${CLIENT_DB_ID} successfully provisioned.`);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
expect(res.res.statusMessage).toEqual(`Client Database ${process.env.CLIENT_ID} successfully provisioned.`);
|
||||
})
|
||||
});
|
||||
|
||||
describe("destroy", () => {
|
||||
beforeEach(async () => {
|
||||
db = await createClientDatabase();
|
||||
db = await createClientDatabase(request);
|
||||
});
|
||||
|
||||
it("returns a success message when the client database is successfully destroyed", async done => {
|
||||
request
|
||||
.delete(`/api/clients/testing`)
|
||||
it("returns a success message when the client database is successfully destroyed", async () => {
|
||||
const res = await request
|
||||
.delete(`/api/client`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end((err, res) => {
|
||||
expect(res.body.message).toEqual(`Client Database ${CLIENT_DB_ID} successfully deleted.`);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
expect(res.res.statusMessage).toEqual(`Client Database ${process.env.CLIENT_ID} successfully deleted.`);
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,8 +1,34 @@
|
|||
const CouchDB = require("../../../db")
|
||||
const CLIENT_DB_ID = "client-testing"
|
||||
const TEST_APP_ID = "test-app"
|
||||
const supertest = require("supertest")
|
||||
const app = require("../../../app")
|
||||
|
||||
exports.createModel = async (instanceId, model) => {
|
||||
exports.supertest = async () => {
|
||||
let request
|
||||
let port = 4002
|
||||
let started = false
|
||||
let server
|
||||
while (!started && port < 4020) {
|
||||
try {
|
||||
server = await app(port)
|
||||
started = true
|
||||
} catch (e) {
|
||||
if (e.code === "EADDRINUSE") port = port + 1
|
||||
else throw e
|
||||
}
|
||||
}
|
||||
|
||||
if (!started) throw Error("Application failed to start")
|
||||
|
||||
request = supertest(server)
|
||||
return { request, server }
|
||||
}
|
||||
|
||||
exports.defaultHeaders = {
|
||||
Accept: "application/json",
|
||||
Authorization: "Basic test-admin-secret",
|
||||
}
|
||||
|
||||
exports.createModel = async (request, instanceId, model) => {
|
||||
model = model || {
|
||||
name: "TestModel",
|
||||
type: "model",
|
||||
|
@ -11,72 +37,60 @@ exports.createModel = async (instanceId, model) => {
|
|||
name: { type: "string" },
|
||||
},
|
||||
}
|
||||
const db = new CouchDB(instanceId)
|
||||
const response = await db.post(model)
|
||||
|
||||
const designDoc = await db.get("_design/database")
|
||||
designDoc.views = {
|
||||
...designDoc.views,
|
||||
[`all_${response.id}`]: {
|
||||
map: `function(doc) {
|
||||
if (doc.modelId === "${response.id}") {
|
||||
emit(doc[doc.key], doc._id);
|
||||
}
|
||||
}`,
|
||||
},
|
||||
}
|
||||
await db.put(designDoc)
|
||||
|
||||
return {
|
||||
...response,
|
||||
...model,
|
||||
}
|
||||
const res = await request
|
||||
.post(`/api/${instanceId}/models`)
|
||||
.set(exports.defaultHeaders)
|
||||
.send(model)
|
||||
return res.body
|
||||
}
|
||||
|
||||
exports.createClientDatabase = async () => {
|
||||
const db = new CouchDB(CLIENT_DB_ID)
|
||||
|
||||
await db.put({
|
||||
_id: "_design/client",
|
||||
views: {
|
||||
by_type: {
|
||||
map: function(doc) {
|
||||
emit([doc.type], doc._id)
|
||||
},
|
||||
}.toString(),
|
||||
},
|
||||
})
|
||||
|
||||
await db.put({
|
||||
_id: TEST_APP_ID,
|
||||
type: "app",
|
||||
instances: [],
|
||||
})
|
||||
|
||||
return db
|
||||
exports.createClientDatabase = async request => {
|
||||
const res = await request
|
||||
.post("/api/client")
|
||||
.set(exports.defaultHeaders)
|
||||
.send({})
|
||||
return res.body
|
||||
}
|
||||
|
||||
exports.destroyClientDatabase = async () => new CouchDB(CLIENT_DB_ID).destroy()
|
||||
exports.createApplication = async (request, name = "test_application") => {
|
||||
const res = await request
|
||||
.post("/api/applications")
|
||||
.set(exports.defaultHeaders)
|
||||
.send({
|
||||
name,
|
||||
})
|
||||
return res.body
|
||||
}
|
||||
|
||||
exports.createInstanceDatabase = async instanceId => {
|
||||
const db = new CouchDB(instanceId)
|
||||
exports.destroyClientDatabase = async request => {
|
||||
await request
|
||||
.delete(`/api/client`)
|
||||
.set(exports.defaultHeaders)
|
||||
.send({})
|
||||
}
|
||||
|
||||
await db.put({
|
||||
_id: "_design/database",
|
||||
metadata: {
|
||||
clientId: CLIENT_DB_ID,
|
||||
applicationId: TEST_APP_ID,
|
||||
},
|
||||
views: {
|
||||
by_type: {
|
||||
map: function(doc) {
|
||||
emit([doc.type], doc._id)
|
||||
}.toString(),
|
||||
},
|
||||
},
|
||||
})
|
||||
exports.createInstance = async (request, appId) => {
|
||||
const res = await request
|
||||
.post(`/api/${appId}/instances`)
|
||||
.set(exports.defaultHeaders)
|
||||
.send({
|
||||
name: "test-instance",
|
||||
})
|
||||
return res.body
|
||||
}
|
||||
|
||||
return db
|
||||
exports.createUser = async (
|
||||
request,
|
||||
instanceId,
|
||||
username = "bill",
|
||||
password = "bills_password"
|
||||
) => {
|
||||
const res = await request
|
||||
.post(`/api/${instanceId}/users`)
|
||||
.set(exports.defaultHeaders)
|
||||
.send({ name: "Bill", username, password })
|
||||
return res.body
|
||||
}
|
||||
|
||||
exports.insertDocument = async (databaseId, document) => {
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const {
|
||||
createInstanceDatabase,
|
||||
createInstance,
|
||||
createClientDatabase,
|
||||
destroyClientDatabase
|
||||
createApplication,
|
||||
supertest,
|
||||
defaultHeaders
|
||||
} = require("./couchTestUtils");
|
||||
|
||||
|
||||
const TEST_INSTANCE_ID = "testing-123";
|
||||
const TEST_APP_ID = "test-app";
|
||||
|
||||
describe("/instances", () => {
|
||||
let request;
|
||||
let server;
|
||||
|
||||
let TEST_APP_ID;
|
||||
let server
|
||||
let request
|
||||
beforeAll(async () => {
|
||||
server = app
|
||||
request = supertest(server);
|
||||
({ request, server } = await supertest())
|
||||
await createClientDatabase(request);
|
||||
TEST_APP_ID = (await createApplication(request))._id
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -25,48 +22,30 @@ describe("/instances", () => {
|
|||
|
||||
describe("create", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
clientDb = await createClientDatabase();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await destroyClientDatabase();
|
||||
});
|
||||
|
||||
it("returns a success message when the instance database is successfully created", done => {
|
||||
request
|
||||
.post(`/api/testing/${TEST_APP_ID}/instances`)
|
||||
.send({ name: TEST_INSTANCE_ID })
|
||||
.set("Accept", "application/json")
|
||||
it("returns a success message when the instance database is successfully created", async () => {
|
||||
const res = await request
|
||||
.post(`/api/${TEST_APP_ID}/instances`)
|
||||
.send({ name: "test-instance" })
|
||||
.set(defaultHeaders)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
expect(res.body.message).toEqual("Instance Database testing-123 successfully provisioned.");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
expect(res.res.statusMessage).toEqual("Instance Database test-instance successfully provisioned.");
|
||||
expect(res.body._id).toBeDefined();
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
describe("destroy", () => {
|
||||
beforeEach(async () => {
|
||||
await createClientDatabase();
|
||||
instanceDb = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await destroyClientDatabase();
|
||||
});
|
||||
|
||||
it("returns a success message when the instance database is successfully deleted", done => {
|
||||
request
|
||||
.delete(`/api/instances/${TEST_INSTANCE_ID}`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
it("returns a success message when the instance database is successfully deleted", async () => {
|
||||
const instance = await createInstance(request, TEST_APP_ID);
|
||||
const res = await request
|
||||
.delete(`/api/instances/${instance._id}`)
|
||||
.set(defaultHeaders)
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
expect(res.body.message).toEqual("Instance Database testing-123 successfully destroyed.");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
expect(res.res.statusMessage).toEqual(`Instance Database ${instance._id} successfully destroyed.`);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const { createInstanceDatabase, createModel } = require("./couchTestUtils");
|
||||
|
||||
|
||||
const TEST_INSTANCE_ID = "testing-123";
|
||||
const {
|
||||
createInstance,
|
||||
createModel,
|
||||
supertest,
|
||||
createClientDatabase,
|
||||
createApplication
|
||||
} = require("./couchTestUtils")
|
||||
|
||||
describe("/models", () => {
|
||||
let request;
|
||||
let server;
|
||||
let request
|
||||
let server
|
||||
let app
|
||||
let instance
|
||||
|
||||
beforeAll(async () => {
|
||||
server = app;
|
||||
request = supertest(server);
|
||||
({ request, server } = await supertest())
|
||||
await createClientDatabase(request)
|
||||
app = await createApplication(request)
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -19,19 +23,14 @@ describe("/models", () => {
|
|||
})
|
||||
|
||||
describe("create", () => {
|
||||
let db;
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
instance = await createInstance(request, app._id);
|
||||
});
|
||||
|
||||
it("returns a success message when the model is successfully created", done => {
|
||||
request
|
||||
.post(`/api/${TEST_INSTANCE_ID}/models`)
|
||||
.post(`/api/${instance._id}/models`)
|
||||
.send({
|
||||
name: "TestModel",
|
||||
key: "name",
|
||||
|
@ -43,29 +42,24 @@ describe("/models", () => {
|
|||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
expect(res.body.message).toEqual("Model TestModel created successfully.");
|
||||
expect(res.body.model.name).toEqual("TestModel");
|
||||
expect(res.res.statusMessage).toEqual("Model TestModel created successfully.");
|
||||
expect(res.body.name).toEqual("TestModel");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
describe("fetch", () => {
|
||||
let testModel;
|
||||
let db;
|
||||
let testModel
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
testModel = await createModel(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
instance = await createInstance(request, app._id)
|
||||
testModel = await createModel(request, instance._id, testModel)
|
||||
});
|
||||
|
||||
it("returns all the models for that instance in the response body", done => {
|
||||
request
|
||||
.get(`/api/${TEST_INSTANCE_ID}/models`)
|
||||
.get(`/api/${instance._id}/models`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
|
@ -80,25 +74,20 @@ describe("/models", () => {
|
|||
|
||||
describe("destroy", () => {
|
||||
let testModel;
|
||||
let db;
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
testModel = await createModel(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
instance = await createInstance(request, app._id)
|
||||
testModel = await createModel(request, instance._id, testModel)
|
||||
});
|
||||
|
||||
it("returns a success response when a model is deleted.", done => {
|
||||
request
|
||||
.delete(`/api/${TEST_INSTANCE_ID}/models/${testModel.id}/${testModel.rev}`)
|
||||
.delete(`/api/${instance._id}/models/${testModel._id}/${testModel._rev}`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (_, res) => {
|
||||
expect(res.body.message).toEqual(`Model ${testModel.id} deleted.`);
|
||||
expect(res.res.statusMessage).toEqual(`Model ${testModel._id} deleted.`);
|
||||
done();
|
||||
});
|
||||
})
|
||||
|
|
|
@ -1,27 +1,23 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const { createInstanceDatabase, createModel } = require("./couchTestUtils");
|
||||
|
||||
const TEST_INSTANCE_ID = "testing-123";
|
||||
|
||||
const CONTACT_MODEL = {
|
||||
"name": "Contact",
|
||||
"type": "model",
|
||||
"key": "name",
|
||||
"schema": {
|
||||
"name": { "type": "string" },
|
||||
"age": { "type": "number" }
|
||||
}
|
||||
};
|
||||
const {
|
||||
createApplication,
|
||||
createClientDatabase,
|
||||
createInstance,
|
||||
createModel,
|
||||
supertest
|
||||
} = require("./couchTestUtils");
|
||||
|
||||
describe("/records", () => {
|
||||
let request;
|
||||
let server;
|
||||
let db;
|
||||
let request
|
||||
let server
|
||||
let instance
|
||||
let model
|
||||
let record
|
||||
let app
|
||||
|
||||
beforeAll(async () => {
|
||||
server = app;
|
||||
request = supertest(server);
|
||||
({ request, server } = await supertest())
|
||||
await createClientDatabase(request)
|
||||
app = await createApplication(request)
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
@ -29,95 +25,94 @@ describe("/records", () => {
|
|||
})
|
||||
|
||||
describe("save, load, update, delete", () => {
|
||||
let record;
|
||||
let model;
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
model = await createModel(TEST_INSTANCE_ID, CONTACT_MODEL)
|
||||
instance = await createInstance(request, app._id)
|
||||
model = await createModel(request, instance._id)
|
||||
record = {
|
||||
name: "Test Contact",
|
||||
status: "new",
|
||||
modelId: model.id
|
||||
modelId: model._id
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
it("returns a success message when the record is created", done => {
|
||||
request
|
||||
.post(`/api/${TEST_INSTANCE_ID}/records`)
|
||||
.send(record)
|
||||
const createRecord = async r =>
|
||||
await request
|
||||
.post(`/api/${instance._id}/records`)
|
||||
.send(r || record)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
expect(res.res.statusMessage).toEqual("Contact created successfully")
|
||||
expect(res.body.name).toEqual("Test Contact")
|
||||
expect(res.body._rev).toBeDefined()
|
||||
done();
|
||||
});
|
||||
|
||||
it("returns a success message when the record is created", async () => {
|
||||
const res = await createRecord()
|
||||
expect(res.res.statusMessage).toEqual(`${model.name} created successfully`)
|
||||
expect(res.body.name).toEqual("Test Contact")
|
||||
expect(res.body._rev).toBeDefined()
|
||||
})
|
||||
|
||||
it("updates a record successfully", async () => {
|
||||
const existing = await db.post(record);
|
||||
const rec = await createRecord()
|
||||
const existing = rec.body
|
||||
|
||||
const res = await request
|
||||
.post(`/api/${TEST_INSTANCE_ID}/records`)
|
||||
.post(`/api/${instance._id}/records`)
|
||||
.send({
|
||||
_id: existing.id,
|
||||
_rev: existing.rev,
|
||||
modelId: model.id,
|
||||
_id: existing._id,
|
||||
_rev: existing._rev,
|
||||
modelId: model._id,
|
||||
name: "Updated Name",
|
||||
})
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
|
||||
expect(res.body.message).toEqual("Contact updated successfully.")
|
||||
expect(res.body.record.name).toEqual("Updated Name")
|
||||
expect(res.res.statusMessage).toEqual(`${model.name} updated successfully.`)
|
||||
expect(res.body.name).toEqual("Updated Name")
|
||||
})
|
||||
|
||||
it("should load a record", async () => {
|
||||
const existing = await db.post(record);
|
||||
const rec = await createRecord()
|
||||
const existing = rec.body
|
||||
|
||||
const res = await request
|
||||
.get(`/api/${TEST_INSTANCE_ID}/records/${existing.id}`)
|
||||
.get(`/api/${instance._id}/records/${existing._id}`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
|
||||
expect(res.body).toEqual({
|
||||
...record,
|
||||
_id: existing.id,
|
||||
_rev: existing.rev
|
||||
_id: existing._id,
|
||||
_rev: existing._rev,
|
||||
type: "record",
|
||||
})
|
||||
})
|
||||
|
||||
it("should list all records for given modelId", async () => {
|
||||
const newRecord = {
|
||||
modelId: model.id,
|
||||
modelId: model._id,
|
||||
name: "Second Contact",
|
||||
status: "new"
|
||||
}
|
||||
|
||||
await db.post(newRecord);
|
||||
await createRecord()
|
||||
await createRecord(newRecord)
|
||||
|
||||
const res = await request
|
||||
.get(`/api/${TEST_INSTANCE_ID}/all_${newRecord.modelId}/records`)
|
||||
.get(`/api/${instance._id}/all_${newRecord.modelId}/records`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
|
||||
expect(res.body.length).toBe(1)
|
||||
expect(res.body[0].name).toEqual(newRecord.name);
|
||||
expect(res.body.length).toBe(2)
|
||||
expect(res.body.find(r => r.name === newRecord.name)).toBeDefined()
|
||||
expect(res.body.find(r => r.name === record.name)).toBeDefined()
|
||||
})
|
||||
|
||||
it("load should return 404 when record does not exist", async () => {
|
||||
await createRecord()
|
||||
await request
|
||||
.get(`/api/${TEST_INSTANCE_ID}/records/not-a-valid-id`)
|
||||
.get(`/api/${instance._id}/records/not-a-valid-id`)
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(404)
|
||||
|
|
|
@ -1,75 +1,62 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const {
|
||||
createInstanceDatabase
|
||||
} = require("./couchTestUtils");
|
||||
|
||||
|
||||
const TEST_INSTANCE_ID = "testing-123";
|
||||
const TEST_USER = {
|
||||
name: "Dave"
|
||||
}
|
||||
createClientDatabase,
|
||||
createApplication,
|
||||
createInstance,
|
||||
supertest,
|
||||
defaultHeaders,
|
||||
createUser,
|
||||
} = require("./couchTestUtils")
|
||||
|
||||
describe("/users", () => {
|
||||
let request;
|
||||
let server;
|
||||
let request
|
||||
let server
|
||||
let app
|
||||
let instance
|
||||
|
||||
beforeAll(async () => {
|
||||
server = app
|
||||
request = supertest(server);
|
||||
({ request, server } = await supertest(server))
|
||||
await createClientDatabase(request)
|
||||
app = await createApplication(request)
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
instance = await createInstance(request, app._id)
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
server.close();
|
||||
})
|
||||
|
||||
describe("fetch", () => {
|
||||
let db;
|
||||
describe("fetch", () => {
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
it("returns a list of users from an instance db", done => {
|
||||
request
|
||||
.get(`/api/${TEST_INSTANCE_ID}/users`)
|
||||
.set("Accept", "application/json")
|
||||
it("returns a list of users from an instance db", async () => {
|
||||
await createUser(request, instance._id, "brenda", "brendas_password")
|
||||
await createUser(request, instance._id, "pam", "pam_password")
|
||||
const res = await request
|
||||
.get(`/api/${instance._id}/users`)
|
||||
.set(defaultHeaders)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
const user = res.body[0];
|
||||
expect(user.name).toEqual(TEST_USER.name);
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
|
||||
expect(res.body.length).toBe(2)
|
||||
expect(res.body.find(u => u.username === "brenda")).toBeDefined()
|
||||
expect(res.body.find(u => u.username === "pam")).toBeDefined()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
describe("create", () => {
|
||||
let db;
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
it("returns a success message when a user is successfully created", done => {
|
||||
request
|
||||
.post(`/api/${TEST_INSTANCE_ID}/users`)
|
||||
.send({ name: "Bill", username: "bill1", password: "password" })
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
it("returns a success message when a user is successfully created", async () => {
|
||||
const res = await request
|
||||
.post(`/api/${instance._id}/users`)
|
||||
.set(defaultHeaders)
|
||||
.send({ name: "Bill", username: "bill", password: "bills_password" })
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
expect(res.body.message).toEqual("User created successfully.");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
.expect('Content-Type', /json/)
|
||||
|
||||
expect(res.res.statusMessage).toEqual("User created successfully.");
|
||||
expect(res.body._id).toBeUndefined()
|
||||
})
|
||||
});
|
||||
})
|
||||
|
|
|
@ -1,78 +1,73 @@
|
|||
const supertest = require("supertest");
|
||||
const app = require("../../../app");
|
||||
const { createInstanceDatabase, createModel, destroyDatabase } = require("./couchTestUtils");
|
||||
|
||||
|
||||
const TEST_INSTANCE_ID = "testing-123";
|
||||
const {
|
||||
createClientDatabase,
|
||||
createApplication,
|
||||
createInstance,
|
||||
createModel,
|
||||
supertest,
|
||||
defaultHeaders
|
||||
} = require("./couchTestUtils")
|
||||
|
||||
describe("/views", () => {
|
||||
let request;
|
||||
let server;
|
||||
let db;
|
||||
let request
|
||||
let server
|
||||
let app
|
||||
let instance
|
||||
let model
|
||||
|
||||
beforeAll(async () => {
|
||||
server = app;
|
||||
request = supertest(server);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
server.close();
|
||||
({ request, server } = await supertest())
|
||||
await createClientDatabase(request)
|
||||
app = await createApplication(request)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
instance = await createInstance(request, app._id)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
server.close()
|
||||
})
|
||||
|
||||
const createView = async () =>
|
||||
await request
|
||||
.post(`/api/${instance._id}/views`)
|
||||
.send({
|
||||
name: "TestView",
|
||||
map: `function(doc) {
|
||||
if (doc.id) {
|
||||
emit(doc.name, doc._id);
|
||||
}
|
||||
}`,
|
||||
reduce: `function(keys, values) { }`
|
||||
})
|
||||
.set(defaultHeaders)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
|
||||
describe("create", () => {
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
db && await db.destroy();
|
||||
});
|
||||
|
||||
it("returns a success message when the view is successfully created", done => {
|
||||
request
|
||||
.post(`/api/${TEST_INSTANCE_ID}/views`)
|
||||
.send({
|
||||
name: "TestView",
|
||||
map: `function(doc) {
|
||||
if (doc.id) {
|
||||
emit(doc.name, doc._id);
|
||||
}
|
||||
}`,
|
||||
reduce: `function(keys, values) { }`
|
||||
})
|
||||
.set("Accept", "application/json")
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (err, res) => {
|
||||
expect(res.body.message).toEqual("View TestView created successfully.");
|
||||
expect(res.body.id).toEqual("_design/database");
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
it("returns a success message when the view is successfully created", async () => {
|
||||
const res = await createView()
|
||||
expect(res.res.statusMessage).toEqual("View TestView created successfully.");
|
||||
expect(res.body.name).toEqual("TestView");
|
||||
})
|
||||
});
|
||||
|
||||
describe("fetch", () => {
|
||||
let db;
|
||||
|
||||
beforeEach(async () => {
|
||||
db = await createInstanceDatabase(TEST_INSTANCE_ID);
|
||||
await createModel(TEST_INSTANCE_ID);
|
||||
model = await createModel(request, instance._id);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await db.destroy();
|
||||
});
|
||||
|
||||
it("returns a list of all the views that exist in the instance database", done => {
|
||||
request
|
||||
.get(`/api/${TEST_INSTANCE_ID}/views`)
|
||||
.set("Accept", "application/json")
|
||||
it("should only return custom views", async () => {
|
||||
const view = await createView()
|
||||
const res = await request
|
||||
.get(`/api/${instance._id}/views`)
|
||||
.set(defaultHeaders)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(200)
|
||||
.end(async (_, res) => {
|
||||
expect(res.body.by_type).toBeDefined();
|
||||
done();
|
||||
});
|
||||
})
|
||||
});
|
||||
expect(res.body.length).toBe(1)
|
||||
expect(res.body.find(v => v.name === view.body.name)).toBeDefined()
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
@ -5,7 +5,8 @@ const router = Router()
|
|||
|
||||
router
|
||||
.get("/api/:instanceId/users", controller.fetch)
|
||||
.post("/api/:appId/:instanceId/users", controller.create)
|
||||
.delete("/api/:instanceId/users/:userId", controller.destroy)
|
||||
.get("/api/:instanceId/users/:username", controller.find)
|
||||
.post("/api/:instanceId/users", controller.create)
|
||||
.delete("/api/:instanceId/users/:username", controller.destroy)
|
||||
|
||||
module.exports = router
|
||||
|
|
|
@ -2,14 +2,29 @@ const Koa = require("koa")
|
|||
const logger = require("koa-logger")
|
||||
const api = require("./api")
|
||||
const koaBody = require("koa-body")
|
||||
const env = require("./environment")
|
||||
const http = require("http")
|
||||
|
||||
const app = new Koa()
|
||||
|
||||
// set up top level koa middleware
|
||||
app.use(koaBody({ multipart: true }))
|
||||
app.use(logger())
|
||||
|
||||
if (env.LOGGER !== "off") app.use(logger())
|
||||
|
||||
// api routes
|
||||
app.use(api.routes())
|
||||
|
||||
module.exports = app.listen(process.env.PORT || 4001)
|
||||
module.exports = async port => {
|
||||
const server = http.createServer(app.callback())
|
||||
return new Promise((resolve, reject) => {
|
||||
server.on("error", e => {
|
||||
if (e.code === "EADDRINUSE") {
|
||||
reject(e)
|
||||
}
|
||||
})
|
||||
server.listen({ port }, () => {
|
||||
resolve(server)
|
||||
})
|
||||
})
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
const PouchDB = require("pouchdb")
|
||||
const allDbs = require("pouchdb-all-dbs")
|
||||
const { budibaseAppsDir } = require("../utilities/budibaseDir")
|
||||
const env = require("../environment")
|
||||
|
||||
const COUCH_DB_URL = process.env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/`
|
||||
const COUCH_DB_URL = env.COUCH_DB_URL || `leveldb://${budibaseAppsDir()}/`
|
||||
const isInMemory = env.NODE_ENV === "jest"
|
||||
|
||||
if (isInMemory) PouchDB.plugin(require("pouchdb-adapter-memory"))
|
||||
|
||||
const Pouch = PouchDB.defaults({
|
||||
prefix: COUCH_DB_URL,
|
||||
prefix: isInMemory ? undefined : COUCH_DB_URL,
|
||||
adapter: isInMemory ? "memory" : undefined,
|
||||
})
|
||||
|
||||
allDbs(Pouch)
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
const CouchDB = require("./client")
|
||||
|
||||
exports.create = async clientId => {
|
||||
const dbId = `client-${clientId}`
|
||||
const db = new CouchDB(dbId)
|
||||
await db.put({
|
||||
_id: "_design/client",
|
||||
views: {
|
||||
by_type: {
|
||||
map: `function(doc) {
|
||||
emit([doc.type], doc._id)
|
||||
}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
return db
|
||||
}
|
||||
|
||||
exports.destroy = async function(clientId) {
|
||||
const dbId = `client-${clientId}`
|
||||
await new CouchDB(dbId).destroy()
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
module.exports = async db => {
|
||||
const doc = await db.put({
|
||||
_id: "_design/client",
|
||||
views: {
|
||||
by_type: {
|
||||
map: `function(doc) {
|
||||
emit([doc.type], doc._id)
|
||||
}`,
|
||||
},
|
||||
},
|
||||
})
|
||||
console.log(doc)
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
module.exports = {
|
||||
CLIENT_ID: process.env.CLIENT_ID,
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
JWT_SECRET: process.env.JWT_SECRET,
|
||||
BUDIBASE_DIR: process.env.BUDIBASE_DIR,
|
||||
ADMIN_SECRET: process.env.ADMIN_SECRET,
|
||||
PORT: process.env.PORT,
|
||||
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
||||
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
||||
LOGGER: process.env.LOGGER,
|
||||
}
|
|
@ -1,10 +1,17 @@
|
|||
const jwt = require("jsonwebtoken")
|
||||
const STATUS_CODES = require("../utilities/statusCodes");
|
||||
const STATUS_CODES = require("../utilities/statusCodes")
|
||||
const env = require("../environment")
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
if (ctx.isDev) {
|
||||
const authHeader = ctx.get("Authorization")
|
||||
|
||||
if (
|
||||
authHeader &&
|
||||
authHeader.startsWith("Basic") &&
|
||||
authHeader.split(" ")[1] === env.ADMIN_SECRET
|
||||
) {
|
||||
ctx.isAuthenticated = true
|
||||
await next();
|
||||
await next()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const bcrypt = require("bcryptjs")
|
||||
const env = require("../environment")
|
||||
|
||||
const SALT_ROUNDS = process.env.SALT_ROUNDS || 10
|
||||
const SALT_ROUNDS = env.SALT_ROUNDS || 10
|
||||
|
||||
exports.hash = async data => {
|
||||
const salt = await bcrypt.genSalt(SALT_ROUNDS)
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
const { join } = require("path")
|
||||
const { homedir, tmpdir } = require("os")
|
||||
const env = require("../environment")
|
||||
|
||||
module.exports.budibaseAppsDir = function() {
|
||||
return process.env.BUDIBASE_DIR || join(homedir(), ".budibase")
|
||||
return env.BUDIBASE_DIR || join(homedir(), ".budibase")
|
||||
}
|
||||
|
||||
module.exports.budibaseTempDir = function() {
|
||||
|
|
|
@ -9,6 +9,7 @@ const {
|
|||
rmdir,
|
||||
} = require("fs-extra")
|
||||
const { join, dirname, resolve } = require("path")
|
||||
const env = require("../../environment")
|
||||
|
||||
const buildPage = require("./buildPage")
|
||||
const getPages = require("./getPages")
|
||||
|
@ -31,7 +32,7 @@ module.exports.getPackageForBuilder = async (config, application) => {
|
|||
|
||||
application,
|
||||
|
||||
clientId: process.env.CLIENT_ID,
|
||||
clientId: env.CLIENT_ID,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -194,6 +194,20 @@
|
|||
lodash "^4.17.13"
|
||||
to-fast-properties "^2.0.0"
|
||||
|
||||
"@budibase/client@^0.0.32":
|
||||
version "0.0.32"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.0.32.tgz#76d9f147563a0bf939eae7f32ce75b2a527ba496"
|
||||
integrity sha512-jmCCLn0CUoQbL6h623S5IqK6+GYLqX3WzUTZInSb1SCBOM3pI0eLP5HwTR6s7r42SfD0v9jTWRdyTnHiElNj8A==
|
||||
dependencies:
|
||||
"@nx-js/compiler-util" "^2.0.0"
|
||||
bcryptjs "^2.4.3"
|
||||
deep-equal "^2.0.1"
|
||||
lodash "^4.17.15"
|
||||
lunr "^2.3.5"
|
||||
regexparam "^1.3.0"
|
||||
shortid "^2.2.8"
|
||||
svelte "^3.9.2"
|
||||
|
||||
"@budibase/core@^0.0.32":
|
||||
version "0.0.32"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/core/-/core-0.0.32.tgz#c5d9ab869c5e9596a1ac337aaf041e795b1cc7fa"
|
||||
|
@ -550,6 +564,13 @@ abort-controller@3.0.0:
|
|||
dependencies:
|
||||
event-target-shim "^5.0.0"
|
||||
|
||||
abstract-leveldown@2.4.1:
|
||||
version "2.4.1"
|
||||
resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.4.1.tgz#b3bfedb884eb693a12775f0c55e9f0a420ccee64"
|
||||
integrity sha1-s7/tuITraToSd18MVenwpCDM7mQ=
|
||||
dependencies:
|
||||
xtend "~4.0.0"
|
||||
|
||||
abstract-leveldown@^6.2.1:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-6.3.0.tgz#d25221d1e6612f820c35963ba4bd739928f6026a"
|
||||
|
@ -791,6 +812,11 @@ array-equal@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
|
||||
integrity sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=
|
||||
|
||||
array-filter@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83"
|
||||
integrity sha1-uveeYubvTCpMC4MSMtr/7CUfnYM=
|
||||
|
||||
array-unique@^0.3.2:
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
|
||||
|
@ -858,6 +884,13 @@ atob@^2.1.2:
|
|||
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
||||
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
|
||||
|
||||
available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5"
|
||||
integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ==
|
||||
dependencies:
|
||||
array-filter "^1.0.0"
|
||||
|
||||
aws-sign2@~0.7.0:
|
||||
version "0.7.0"
|
||||
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
|
||||
|
@ -1558,6 +1591,26 @@ decompress-response@^3.3.0:
|
|||
dependencies:
|
||||
mimic-response "^1.0.0"
|
||||
|
||||
deep-equal@^2.0.1:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.3.tgz#cad1c15277ad78a5c01c49c2dee0f54de8a6a7b0"
|
||||
integrity sha512-Spqdl4H+ky45I9ByyJtXteOm9CaIrPmnIPmOhrkKGNYWeDgCvJ8jNYVCTjChxW4FqGuZnLHADc8EKRMX6+CgvA==
|
||||
dependencies:
|
||||
es-abstract "^1.17.5"
|
||||
es-get-iterator "^1.1.0"
|
||||
is-arguments "^1.0.4"
|
||||
is-date-object "^1.0.2"
|
||||
is-regex "^1.0.5"
|
||||
isarray "^2.0.5"
|
||||
object-is "^1.1.2"
|
||||
object-keys "^1.1.1"
|
||||
object.assign "^4.1.0"
|
||||
regexp.prototype.flags "^1.3.0"
|
||||
side-channel "^1.0.2"
|
||||
which-boxed-primitive "^1.0.1"
|
||||
which-collection "^1.0.1"
|
||||
which-typed-array "^1.1.2"
|
||||
|
||||
deep-equal@~1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
|
||||
|
@ -1862,7 +1915,7 @@ error-inject@^1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/error-inject/-/error-inject-1.0.0.tgz#e2b3d91b54aed672f309d950d154850fa11d4f37"
|
||||
integrity sha1-4rPZG1Su1nLzCdlQ0VSFD6EdTzc=
|
||||
|
||||
es-abstract@^1.17.0-next.1, es-abstract@^1.17.2, es-abstract@^1.17.5:
|
||||
es-abstract@^1.17.0-next.1, es-abstract@^1.17.2, es-abstract@^1.17.4, es-abstract@^1.17.5:
|
||||
version "1.17.5"
|
||||
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9"
|
||||
integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg==
|
||||
|
@ -1879,6 +1932,19 @@ es-abstract@^1.17.0-next.1, es-abstract@^1.17.2, es-abstract@^1.17.5:
|
|||
string.prototype.trimleft "^2.1.1"
|
||||
string.prototype.trimright "^2.1.1"
|
||||
|
||||
es-get-iterator@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.0.tgz#bb98ad9d6d63b31aacdc8f89d5d0ee57bcb5b4c8"
|
||||
integrity sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ==
|
||||
dependencies:
|
||||
es-abstract "^1.17.4"
|
||||
has-symbols "^1.0.1"
|
||||
is-arguments "^1.0.4"
|
||||
is-map "^2.0.1"
|
||||
is-set "^2.0.1"
|
||||
is-string "^1.0.5"
|
||||
isarray "^2.0.5"
|
||||
|
||||
es-to-primitive@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a"
|
||||
|
@ -2847,11 +2913,21 @@ is-accessor-descriptor@^1.0.0:
|
|||
dependencies:
|
||||
kind-of "^6.0.0"
|
||||
|
||||
is-arguments@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3"
|
||||
integrity sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA==
|
||||
|
||||
is-arrayish@^0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d"
|
||||
integrity sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=
|
||||
|
||||
is-bigint@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.0.tgz#73da8c33208d00f130e9b5e15d23eac9215601c4"
|
||||
integrity sha512-t5mGUXC/xRheCK431ylNiSkGGpBp8bHENBcENTkDT6ppwPzEVxNGZRvgvmOEfbWkFhA7D2GEuE2mmQTr78sl2g==
|
||||
|
||||
is-binary-path@~2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09"
|
||||
|
@ -2859,6 +2935,11 @@ is-binary-path@~2.1.0:
|
|||
dependencies:
|
||||
binary-extensions "^2.0.0"
|
||||
|
||||
is-boolean-object@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.0.1.tgz#10edc0900dd127697a92f6f9807c7617d68ac48e"
|
||||
integrity sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ==
|
||||
|
||||
is-buffer@^1.1.5:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
||||
|
@ -2895,7 +2976,7 @@ is-data-descriptor@^1.0.0:
|
|||
dependencies:
|
||||
kind-of "^6.0.0"
|
||||
|
||||
is-date-object@^1.0.1:
|
||||
is-date-object@^1.0.1, is-date-object@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e"
|
||||
integrity sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==
|
||||
|
@ -2970,11 +3051,21 @@ is-installed-globally@^0.3.1:
|
|||
global-dirs "^2.0.1"
|
||||
is-path-inside "^3.0.1"
|
||||
|
||||
is-map@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1"
|
||||
integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw==
|
||||
|
||||
is-npm@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-npm/-/is-npm-4.0.0.tgz#c90dd8380696df87a7a6d823c20d0b12bbe3c84d"
|
||||
integrity sha512-96ECIfh9xtDDlPylNPXhzjsykHsMJZ18ASpaWzQyBr4YRTcVjUvzaHayDAES2oU/3KpljhHUjtSRNiDwi0F0ig==
|
||||
|
||||
is-number-object@^1.0.3:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197"
|
||||
integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==
|
||||
|
||||
is-number@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195"
|
||||
|
@ -3011,11 +3102,21 @@ is-regex@^1.0.5:
|
|||
dependencies:
|
||||
has "^1.0.3"
|
||||
|
||||
is-set@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.1.tgz#d1604afdab1724986d30091575f54945da7e5f43"
|
||||
integrity sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA==
|
||||
|
||||
is-stream@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
|
||||
integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=
|
||||
|
||||
is-string@^1.0.4, is-string@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6"
|
||||
integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==
|
||||
|
||||
is-symbol@^1.0.2:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937"
|
||||
|
@ -3032,11 +3133,31 @@ is-type-of@^1.0.0:
|
|||
is-class-hotfix "~0.0.6"
|
||||
isstream "~0.1.2"
|
||||
|
||||
is-typed-array@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.3.tgz#a4ff5a5e672e1a55f99c7f54e59597af5c1df04d"
|
||||
integrity sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ==
|
||||
dependencies:
|
||||
available-typed-arrays "^1.0.0"
|
||||
es-abstract "^1.17.4"
|
||||
foreach "^2.0.5"
|
||||
has-symbols "^1.0.1"
|
||||
|
||||
is-typedarray@^1.0.0, is-typedarray@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
|
||||
integrity sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=
|
||||
|
||||
is-weakmap@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.1.tgz#5008b59bdc43b698201d18f62b37b2ca243e8cf2"
|
||||
integrity sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==
|
||||
|
||||
is-weakset@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.1.tgz#e9a0af88dbd751589f5e50d80f4c98b780884f83"
|
||||
integrity sha512-pi4vhbhVHGLxohUw7PhGsueT4vRGFoXhP7+RGN0jKIv9+8PWYCQTqtADngrxOm2g46hoH0+g8uZZBzMrvVGDmw==
|
||||
|
||||
is-windows@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
|
||||
|
@ -3062,6 +3183,11 @@ isarray@1.0.0, isarray@~1.0.0:
|
|||
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
|
||||
integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=
|
||||
|
||||
isarray@^2.0.5:
|
||||
version "2.0.5"
|
||||
resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723"
|
||||
integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==
|
||||
|
||||
isbinaryfile@^4.0.6:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.6.tgz#edcb62b224e2b4710830b67498c8e4e5a4d2610b"
|
||||
|
@ -4071,6 +4197,11 @@ ltgt@2.2.1, ltgt@^2.1.2:
|
|||
resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5"
|
||||
integrity sha1-81ypHEk/e3PaDgdJUwTxezH4fuU=
|
||||
|
||||
ltgt@~2.1.3:
|
||||
version "2.1.3"
|
||||
resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.1.3.tgz#10851a06d9964b971178441c23c9e52698eece34"
|
||||
integrity sha1-EIUaBtmWS5cReEQcI8nlJpjuzjQ=
|
||||
|
||||
lunr@^2.3.5:
|
||||
version "2.3.8"
|
||||
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.8.tgz#a8b89c31f30b5a044b97d2d28e2da191b6ba2072"
|
||||
|
@ -4122,6 +4253,17 @@ media-typer@0.3.0:
|
|||
resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748"
|
||||
integrity sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=
|
||||
|
||||
memdown@1.2.4:
|
||||
version "1.2.4"
|
||||
resolved "https://registry.yarnpkg.com/memdown/-/memdown-1.2.4.tgz#cd9a34aaf074d53445a271108eb4b8dd4ec0f27f"
|
||||
integrity sha1-zZo0qvB01TRFonEQjrS43U7A8n8=
|
||||
dependencies:
|
||||
abstract-leveldown "2.4.1"
|
||||
functional-red-black-tree "^1.0.1"
|
||||
immediate "^3.2.3"
|
||||
inherits "~2.0.1"
|
||||
ltgt "~2.1.3"
|
||||
|
||||
merge-stream@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
|
||||
|
@ -4421,6 +4563,14 @@ object-inspect@^1.7.0:
|
|||
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67"
|
||||
integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw==
|
||||
|
||||
object-is@^1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6"
|
||||
integrity sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ==
|
||||
dependencies:
|
||||
define-properties "^1.1.3"
|
||||
es-abstract "^1.17.5"
|
||||
|
||||
object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.0.6, object-keys@^1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
|
||||
|
@ -4687,6 +4837,47 @@ posix-character-classes@^0.1.0:
|
|||
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
||||
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
|
||||
|
||||
pouchdb-adapter-leveldb-core@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-adapter-leveldb-core/-/pouchdb-adapter-leveldb-core-7.2.1.tgz#71bf2a05755689e2b05e78e796003a18ebf65a69"
|
||||
integrity sha512-kwNsaM1pYDVz6LG9z2/7Tfcuw5iZJ5u8IqzjxMAGCfurScMaF4e7IJnVWqAceWSiaCrp91DbCULhrl4SH8iTDg==
|
||||
dependencies:
|
||||
argsarray "0.0.1"
|
||||
buffer-from "1.1.0"
|
||||
double-ended-queue "2.1.0-0"
|
||||
levelup "4.1.0"
|
||||
pouchdb-adapter-utils "7.2.1"
|
||||
pouchdb-binary-utils "7.2.1"
|
||||
pouchdb-collections "7.2.1"
|
||||
pouchdb-errors "7.2.1"
|
||||
pouchdb-json "7.2.1"
|
||||
pouchdb-md5 "7.2.1"
|
||||
pouchdb-merge "7.2.1"
|
||||
pouchdb-utils "7.2.1"
|
||||
sublevel-pouchdb "7.2.1"
|
||||
through2 "3.0.1"
|
||||
|
||||
pouchdb-adapter-memory@^7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-adapter-memory/-/pouchdb-adapter-memory-7.2.1.tgz#70341b54093b6bda3ab6e78482c8d00b906178e9"
|
||||
integrity sha512-W4+9+xol95NIdDlk2KVxhv81QWRx/P4L9CPGdh7nqGtzuhVbvqMEqZN24XauIoBaaDy1LLkCyXMvChNt3GHBRQ==
|
||||
dependencies:
|
||||
memdown "1.2.4"
|
||||
pouchdb-adapter-leveldb-core "7.2.1"
|
||||
pouchdb-utils "7.2.1"
|
||||
|
||||
pouchdb-adapter-utils@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-adapter-utils/-/pouchdb-adapter-utils-7.2.1.tgz#d2583bc5c6bfcd6cf0d20acd54cb51683a196d37"
|
||||
integrity sha512-asMAhH6mJRgz6JFEvaS/gMcfWR9pCM+DLPzzIN5vSAm8jUEaMApCONx86xhBwVgzAJ8aVzrG11J9D5iJlM7LSQ==
|
||||
dependencies:
|
||||
pouchdb-binary-utils "7.2.1"
|
||||
pouchdb-collections "7.2.1"
|
||||
pouchdb-errors "7.2.1"
|
||||
pouchdb-md5 "7.2.1"
|
||||
pouchdb-merge "7.2.1"
|
||||
pouchdb-utils "7.2.1"
|
||||
|
||||
pouchdb-all-dbs@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-all-dbs/-/pouchdb-all-dbs-1.0.2.tgz#8fa1aa4b01665e00e0da9c61bf6dbb99eca05d3c"
|
||||
|
@ -4698,6 +4889,45 @@ pouchdb-all-dbs@^1.0.2:
|
|||
pouchdb-promise "5.4.3"
|
||||
tiny-queue "^0.2.0"
|
||||
|
||||
pouchdb-binary-utils@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-binary-utils/-/pouchdb-binary-utils-7.2.1.tgz#ad23ed63d09699e7e6244f846b5cf07c6d9d4b8b"
|
||||
integrity sha512-kbzOOYti/3d8s2bQY5EfJVd7c9E84q4oEpr1M8fOOHKnINZFteKkZQywD4roblUnew0Obyhvozif4LAr3CMZFg==
|
||||
dependencies:
|
||||
buffer-from "1.1.0"
|
||||
|
||||
pouchdb-collections@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-collections/-/pouchdb-collections-7.2.1.tgz#768c2c578b22eda9ac0c92a4b1106d18f3c113fb"
|
||||
integrity sha512-cqe3GY3wDq2j59tnh+5ZV0bZj1O+YWiBz4qM7HEcgrEXnc29ADvXXPp71tmcpZUCR39bzLKyYtadAQu7FpOeOA==
|
||||
|
||||
pouchdb-errors@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-errors/-/pouchdb-errors-7.2.1.tgz#798f5279a0d363d6b93c97a1b65ee903f61af143"
|
||||
integrity sha512-/tBP+eWY6a62UoZnJ6JJlNmbNpNS5FgVimkqwLMrFQkXpbJlhshYDeJ5PHR0W3Rlfc54GMZC7m4KhJt9kG/CkA==
|
||||
dependencies:
|
||||
inherits "2.0.4"
|
||||
|
||||
pouchdb-json@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-json/-/pouchdb-json-7.2.1.tgz#41836bdffed1d1b6207793f0b26bf771105c0c61"
|
||||
integrity sha512-YGRX/qDl+iEX2vz23kzBtMoH0hpb9xASKnEGZPH76BTDq4RQ+eUOxyXU9E1fPdQhsq8+0pcEQN7VCnFEdQ7MUQ==
|
||||
dependencies:
|
||||
vuvuzela "1.0.3"
|
||||
|
||||
pouchdb-md5@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-md5/-/pouchdb-md5-7.2.1.tgz#2b057b148b3f31491d77c4dd6b6139af31b07f66"
|
||||
integrity sha512-TJqGtNguctPiSai5b4+oTPi9oOcxSbNolkUtxRBxklf8kw+PNsDUi1H0DIFmA57n0qHCU19PXdbEVYlUhv/PAA==
|
||||
dependencies:
|
||||
pouchdb-binary-utils "7.2.1"
|
||||
spark-md5 "3.0.0"
|
||||
|
||||
pouchdb-merge@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-merge/-/pouchdb-merge-7.2.1.tgz#d9301a4e92ccb14347ef8cc6a01caa63e3950fcd"
|
||||
integrity sha512-TgxXPw1sZERwihoWSzLIdvn5MP1YKhYNaB0UuvYjboK+WUpCLh5WEeNTJi6WwUD9Yoc66QxP9D3qmfNEjd1BHQ==
|
||||
|
||||
pouchdb-promise@5.4.3:
|
||||
version "5.4.3"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-promise/-/pouchdb-promise-5.4.3.tgz#331d670b1989d5a03f268811214f27f54150cb2b"
|
||||
|
@ -4705,6 +4935,20 @@ pouchdb-promise@5.4.3:
|
|||
dependencies:
|
||||
lie "3.0.4"
|
||||
|
||||
pouchdb-utils@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb-utils/-/pouchdb-utils-7.2.1.tgz#5dec1c53c8ecba717e5762311e9a1def2d4ebf9c"
|
||||
integrity sha512-ZInfRpKtJ2HwLz2Dv3NEona9khvGud0rWzvQGwUs1zoaOoSB5XxK3ui5s5fLpBrONgz0WcTB49msOUq4oAUzFg==
|
||||
dependencies:
|
||||
argsarray "0.0.1"
|
||||
clone-buffer "1.0.0"
|
||||
immediate "3.0.6"
|
||||
inherits "2.0.4"
|
||||
pouchdb-collections "7.2.1"
|
||||
pouchdb-errors "7.2.1"
|
||||
pouchdb-md5 "7.2.1"
|
||||
uuid "3.3.3"
|
||||
|
||||
pouchdb@^7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/pouchdb/-/pouchdb-7.2.1.tgz#619e3d5c2463ddd94a4b1bf40d44408c46e9de79"
|
||||
|
@ -4971,6 +5215,19 @@ regex-not@^1.0.0, regex-not@^1.0.2:
|
|||
extend-shallow "^3.0.2"
|
||||
safe-regex "^1.1.0"
|
||||
|
||||
regexp.prototype.flags@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75"
|
||||
integrity sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ==
|
||||
dependencies:
|
||||
define-properties "^1.1.3"
|
||||
es-abstract "^1.17.0-next.1"
|
||||
|
||||
regexparam@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f"
|
||||
integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g==
|
||||
|
||||
regexpp@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-2.0.1.tgz#8d19d31cf632482b589049f8281f93dbcba4d07f"
|
||||
|
@ -5299,6 +5556,14 @@ shortid@^2.2.8:
|
|||
dependencies:
|
||||
nanoid "^2.1.0"
|
||||
|
||||
side-channel@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.2.tgz#df5d1abadb4e4bf4af1cd8852bf132d2f7876947"
|
||||
integrity sha512-7rL9YlPHg7Ancea1S96Pa8/QWb4BtXL/TZvS6B8XFetGBeuhAsfmUspK6DokBeZ64+Kj9TCNRD/30pVz1BvQNA==
|
||||
dependencies:
|
||||
es-abstract "^1.17.0-next.1"
|
||||
object-inspect "^1.7.0"
|
||||
|
||||
signal-exit@^3.0.0, signal-exit@^3.0.2:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c"
|
||||
|
@ -5630,6 +5895,16 @@ strip-json-comments@~2.0.1:
|
|||
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
|
||||
integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo=
|
||||
|
||||
sublevel-pouchdb@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/sublevel-pouchdb/-/sublevel-pouchdb-7.2.1.tgz#ce3ec06c91ee5afb5ab1bb7abbb905fd4dcc8c38"
|
||||
integrity sha512-pliYcLDubhpe8ONw3P09CehULjuNopl6ybj6N0YudOg+FidqEYgJUgN/1n7ZqVrcXCDHws9g6lN1srlQta5/XQ==
|
||||
dependencies:
|
||||
inherits "2.0.4"
|
||||
level-codec "9.0.1"
|
||||
ltgt "2.2.1"
|
||||
readable-stream "1.0.33"
|
||||
|
||||
sumchecker@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/sumchecker/-/sumchecker-3.0.1.tgz#6377e996795abb0b6d348e9b3e1dfb24345a8e42"
|
||||
|
@ -5682,6 +5957,11 @@ supports-color@^7.1.0:
|
|||
dependencies:
|
||||
has-flag "^4.0.0"
|
||||
|
||||
svelte@^3.9.2:
|
||||
version "3.22.2"
|
||||
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.22.2.tgz#06585244191bf7a112af2a0025610f33d77c3715"
|
||||
integrity sha512-DxumO0+vvHA6NSc2jtVty08I8lFI43q8P2zX6JxZL8J1kqK5NVjad6TRM/twhnWXC+QScnwkZ15O6X1aTsEKTA==
|
||||
|
||||
symbol-tree@^3.2.2:
|
||||
version "3.2.4"
|
||||
resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2"
|
||||
|
@ -6157,11 +6437,44 @@ whatwg-url@^7.0.0:
|
|||
tr46 "^1.0.1"
|
||||
webidl-conversions "^4.0.2"
|
||||
|
||||
which-boxed-primitive@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz#cbe8f838ebe91ba2471bb69e9edbda67ab5a5ec1"
|
||||
integrity sha512-7BT4TwISdDGBgaemWU0N0OU7FeAEJ9Oo2P1PHRm/FCWoEi2VLWC9b6xvxAA3C/NMpxg3HXVgi0sMmGbNUbNepQ==
|
||||
dependencies:
|
||||
is-bigint "^1.0.0"
|
||||
is-boolean-object "^1.0.0"
|
||||
is-number-object "^1.0.3"
|
||||
is-string "^1.0.4"
|
||||
is-symbol "^1.0.2"
|
||||
|
||||
which-collection@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.1.tgz#70eab71ebbbd2aefaf32f917082fc62cdcb70906"
|
||||
integrity sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==
|
||||
dependencies:
|
||||
is-map "^2.0.1"
|
||||
is-set "^2.0.1"
|
||||
is-weakmap "^2.0.1"
|
||||
is-weakset "^2.0.1"
|
||||
|
||||
which-module@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"
|
||||
integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=
|
||||
|
||||
which-typed-array@^1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2"
|
||||
integrity sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ==
|
||||
dependencies:
|
||||
available-typed-arrays "^1.0.2"
|
||||
es-abstract "^1.17.5"
|
||||
foreach "^2.0.5"
|
||||
function-bind "^1.1.1"
|
||||
has-symbols "^1.0.1"
|
||||
is-typed-array "^1.1.3"
|
||||
|
||||
which@^1.2.9, which@^1.3.0:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a"
|
||||
|
|
Loading…
Reference in New Issue