Addressing majority of PR comments.
This commit is contained in:
parent
41c68ae891
commit
4daf9c2615
|
@ -64,7 +64,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/chance": "1.1.3",
|
||||
"@types/ioredis": "4.28.10",
|
||||
"@types/ioredis": "4.28.0",
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/koa": "2.0.52",
|
||||
"@types/lodash": "4.14.180",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { AppBackup, AppBackupRevertEvent, Event } from "@budibase/types"
|
||||
import { AppBackup, AppBackupRestoreEvent, Event } from "@budibase/types"
|
||||
import { publishEvent } from "../events"
|
||||
|
||||
export async function appBackupRestored(backup: AppBackup) {
|
||||
const properties: AppBackupRevertEvent = {
|
||||
const properties: AppBackupRestoreEvent = {
|
||||
appId: backup.appId,
|
||||
backupName: backup.name!,
|
||||
backupCreatedAt: backup.timestamp,
|
||||
|
|
|
@ -6,18 +6,18 @@ export type StalledFn = (job: Job) => Promise<void>
|
|||
export function addListeners(
|
||||
queue: Queue,
|
||||
jobQueue: JobQueue,
|
||||
removeStalled?: StalledFn
|
||||
removeStalledCb?: StalledFn
|
||||
) {
|
||||
logging(queue, jobQueue)
|
||||
if (removeStalled) {
|
||||
handleStalled(queue, removeStalled)
|
||||
if (removeStalledCb) {
|
||||
handleStalled(queue, removeStalledCb)
|
||||
}
|
||||
}
|
||||
|
||||
function handleStalled(queue: Queue, removeStalled?: StalledFn) {
|
||||
function handleStalled(queue: Queue, removeStalledCb?: StalledFn) {
|
||||
queue.on("stalled", async (job: Job) => {
|
||||
if (removeStalled) {
|
||||
await removeStalled(job)
|
||||
if (removeStalledCb) {
|
||||
await removeStalledCb(job)
|
||||
} else if (job.opts.repeat) {
|
||||
const jobId = job.id
|
||||
const repeatJobs = await queue.getRepeatableJobs()
|
||||
|
|
|
@ -18,7 +18,7 @@ async function cleanup() {
|
|||
|
||||
export function createQueue<T>(
|
||||
jobQueue: JobQueue,
|
||||
removeStalled?: StalledFn
|
||||
opts: { removeStalledCb?: StalledFn }
|
||||
): BullQueue.Queue<T> {
|
||||
const queueConfig: any = redisProtocolUrl || { redis: opts }
|
||||
let queue: any
|
||||
|
@ -27,7 +27,7 @@ export function createQueue<T>(
|
|||
} else {
|
||||
queue = new InMemoryQueue(jobQueue, queueConfig)
|
||||
}
|
||||
addListeners(queue, jobQueue, removeStalled)
|
||||
addListeners(queue, jobQueue, opts?.removeStalledCb)
|
||||
QUEUES.push(queue)
|
||||
if (!cleanupInterval) {
|
||||
cleanupInterval = setInterval(cleanup, CLEANUP_PERIOD_MS)
|
||||
|
|
|
@ -291,11 +291,6 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/types@2.0.30-alpha.3":
|
||||
version "2.0.30-alpha.3"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/types/-/types-2.0.30-alpha.3.tgz#cb55bcced75b711cc8a675284fbacaa8ebf1c0f2"
|
||||
integrity sha512-rHeFVuNbSSE4fMnX6uyrM2r47m+neqFXlVNOkhHU9i7KoIcIZbEYInU8CjUFR2da3ruST9ajXjJ5UenX2+MnTg==
|
||||
|
||||
"@hapi/hoek@^9.0.0":
|
||||
version "9.3.0"
|
||||
resolved "https://registry.yarnpkg.com/@hapi/hoek/-/hoek-9.3.0.tgz#8368869dcb735be2e7f5cb7647de78e167a251fb"
|
||||
|
@ -698,14 +693,6 @@
|
|||
"@types/connect" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/bull@^3.15.9":
|
||||
version "3.15.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/bull/-/bull-3.15.9.tgz#e10e0901ec3762bff85716b3c580277960751c93"
|
||||
integrity sha512-MPUcyPPQauAmynoO3ezHAmCOhbB0pWmYyijr/5ctaCqhbKWsjW0YCod38ZcLzUBprosfZ9dPqfYIcfdKjk7RNQ==
|
||||
dependencies:
|
||||
"@types/ioredis" "*"
|
||||
"@types/redis" "^2.8.0"
|
||||
|
||||
"@types/chance@1.1.3":
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/chance/-/chance-1.1.3.tgz#d19fe9391288d60fdccd87632bfc9ab2b4523fea"
|
||||
|
@ -776,10 +763,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-1.8.2.tgz#7315b4c4c54f82d13fa61c228ec5c2ea5cc9e0e1"
|
||||
integrity sha512-EqX+YQxINb+MeXaIqYDASb6U6FCHbWjkj4a1CKDBks3d/QiB2+PqBLyO72vLDgAO1wUI4O+9gweRcQK11bTL/w==
|
||||
|
||||
"@types/ioredis@*", "@types/ioredis@^4.28.10":
|
||||
version "4.28.10"
|
||||
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.10.tgz#40ceb157a4141088d1394bb87c98ed09a75a06ff"
|
||||
integrity sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ==
|
||||
"@types/ioredis@4.28.0":
|
||||
version "4.28.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.0.tgz#609b2ea0d91231df2dd7f67dd77436bc72584911"
|
||||
integrity sha512-HSA/JQivJgV0e+353gvgu6WVoWvGRe0HyHOnAN2AvbVIhUlJBhNnnkP8gEEokrDWrxywrBkwo8NuDZ6TVPL9XA==
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
|
@ -1547,7 +1534,7 @@ buffer@^5.5.0, buffer@^5.6.0:
|
|||
base64-js "^1.3.1"
|
||||
ieee754 "^1.1.13"
|
||||
|
||||
bull@^4.10.1:
|
||||
bull@4.10.1:
|
||||
version "4.10.1"
|
||||
resolved "https://registry.yarnpkg.com/bull/-/bull-4.10.1.tgz#f14974b6089358b62b495a2cbf838aadc098e43f"
|
||||
integrity sha512-Fp21tRPb2EaZPVfmM+ONZKVz2RA+to+zGgaTLyCKt3JMSU8OOBqK8143OQrnGuGpsyE5G+9FevFAGhdZZfQP2g==
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
"@types/google-spreadsheet": "3.1.5",
|
||||
"@types/ioredis": "4.28.10",
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/koa": "2.13.5",
|
||||
"@types/koa": "2.13.4",
|
||||
"@types/koa__router": "8.0.11",
|
||||
"@types/lodash": "4.14.180",
|
||||
"@types/node": "14.18.20",
|
||||
|
|
|
@ -35,9 +35,9 @@ async function getAllDocType(db, docType) {
|
|||
}
|
||||
|
||||
exports.exportApps = async ctx => {
|
||||
// if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
||||
// ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
|
||||
// }
|
||||
if (env.SELF_HOSTED || !env.MULTI_TENANCY) {
|
||||
ctx.throw(400, "Exporting only allowed in multi-tenant cloud environments.")
|
||||
}
|
||||
const apps = await getAllApps({ all: true })
|
||||
const globalDBString = await sdk.backups.exportDB(getGlobalDBName(), {
|
||||
filter: doc => !doc._id.startsWith(DocumentType.USER),
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import { default as backups } from "./app/backups"
|
||||
import { default as tables } from "./app/tables"
|
||||
|
||||
const toExport = {
|
||||
const sdk = {
|
||||
backups,
|
||||
tables,
|
||||
}
|
||||
|
||||
// default export for TS
|
||||
export default toExport
|
||||
export default sdk
|
||||
|
||||
// default export for JS
|
||||
module.exports = toExport
|
||||
module.exports = sdk
|
||||
|
|
|
@ -2831,7 +2831,7 @@
|
|||
dependencies:
|
||||
"@types/koa" "*"
|
||||
|
||||
"@types/koa@*":
|
||||
"@types/koa@*", "@types/koa@2.13.4":
|
||||
version "2.13.4"
|
||||
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.13.4.tgz#10620b3f24a8027ef5cbae88b393d1b31205726b"
|
||||
integrity sha512-dfHYMfU+z/vKtQB7NUrthdAEiSvnLebvBjwHtfFmpZmB7em2N3WVQdHgnFq+xvyVgxW5jKDmjWfLD3lw4g4uTw==
|
||||
|
@ -2845,20 +2845,6 @@
|
|||
"@types/koa-compose" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/koa@2.13.5":
|
||||
version "2.13.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/koa/-/koa-2.13.5.tgz#64b3ca4d54e08c0062e89ec666c9f45443b21a61"
|
||||
integrity sha512-HSUOdzKz3by4fnqagwthW/1w/yJspTgppyyalPVbgZf8jQWvdIXcVW5h2DGtw4zYntOaeRGx49r1hxoPWrD4aA==
|
||||
dependencies:
|
||||
"@types/accepts" "*"
|
||||
"@types/content-disposition" "*"
|
||||
"@types/cookies" "*"
|
||||
"@types/http-assert" "*"
|
||||
"@types/http-errors" "*"
|
||||
"@types/keygrip" "*"
|
||||
"@types/koa-compose" "*"
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/koa__router@8.0.11":
|
||||
version "8.0.11"
|
||||
resolved "https://registry.yarnpkg.com/@types/koa__router/-/koa__router-8.0.11.tgz#d7b37e6db934fc072ea1baa2ab92bc8ac4564f3e"
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
export * from "./db"
|
|
@ -1,6 +1,6 @@
|
|||
import { BaseEvent } from "./event"
|
||||
|
||||
export interface AppBackupRevertEvent extends BaseEvent {
|
||||
export interface AppBackupRestoreEvent extends BaseEvent {
|
||||
appId: string
|
||||
backupName: string
|
||||
backupCreatedAt: string
|
||||
|
|
|
@ -8,3 +8,4 @@ export * from "./search"
|
|||
export * from "./koa"
|
||||
export * from "./auth"
|
||||
export * from "./locks"
|
||||
export * from "./db"
|
||||
|
|
|
@ -79,9 +79,6 @@ export const paginatedUsers = async ({
|
|||
} else if (email) {
|
||||
userList = await usersCore.searchGlobalUsersByEmail(email, opts)
|
||||
property = "email"
|
||||
}
|
||||
if (userIds) {
|
||||
// TODO: search users by userIds
|
||||
} else {
|
||||
// no search, query allDocs
|
||||
const response = await db.allDocs(dbUtils.getGlobalUserParams(null, opts))
|
||||
|
|
Loading…
Reference in New Issue