Merge pull request #14151 from Budibase/chore/unify-utils

Unify duplicated newid utils
This commit is contained in:
Adria Navarro 2024-07-12 11:46:18 +02:00 committed by GitHub
commit 5ff9599e3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 12 additions and 17 deletions

View File

@ -1,5 +1,4 @@
import newid from "../../../db/newid"
import { context } from "@budibase/backend-core"
import { context, utils } from "@budibase/backend-core"
/**
* This is used to pass around information about the deployment that is occurring
@ -12,7 +11,7 @@ export default class Deployment {
appUrl?: string
constructor(id = null) {
this._id = id || newid()
this._id = id || utils.newid()
}
setVerification(verification: any) {

View File

@ -1,10 +1,9 @@
import { Thread, ThreadType } from "../threads"
import { definitions } from "./triggerInfo"
import { automationQueue } from "./bullboard"
import newid from "../db/newid"
import { updateEntityMetadata } from "../utilities"
import { MetadataTypes } from "../constants"
import { db as dbCore, context } from "@budibase/backend-core"
import { db as dbCore, context, utils } from "@budibase/backend-core"
import { getAutomationMetadataParams } from "../db/utils"
import { cloneDeep } from "lodash/fp"
import { quotas } from "@budibase/pro"
@ -207,7 +206,7 @@ export async function enableCronTrigger(appId: any, automation: Automation) {
)
}
// make a job id rather than letting Bull decide, makes it easier to handle on way out
const jobId = `${appId}_cron_${newid()}`
const jobId = `${appId}_cron_${utils.newid()}`
const job: any = await automationQueue.add(
{
automation,

View File

@ -1,9 +1,8 @@
import newid from "./newid"
import { Row, Document, DBView } from "@budibase/types"
// bypass the main application db config
// use in memory pouchdb directly
import { db as dbCore } from "@budibase/backend-core"
import { db as dbCore, utils } from "@budibase/backend-core"
const Pouch = dbCore.getPouch({ inMemory: true })
@ -16,7 +15,7 @@ export async function runView(
// use a different ID each time for the DB, make sure they
// are always unique for each query, don't want overlap
// which could cause 409s
const db = new Pouch(newid())
const db = new Pouch(utils.newid())
try {
// write all the docs to the in memory Pouch (remove revs)
await db.bulkDocs(

View File

@ -1,5 +0,0 @@
import { v4 } from "uuid"
export default function (): string {
return v4().replace(/-/g, "")
}

View File

@ -1,5 +1,4 @@
import newid from "./newid"
import { context, db as dbCore } from "@budibase/backend-core"
import { context, db as dbCore, utils } from "@budibase/backend-core"
import {
DatabaseQueryOpts,
Datasource,
@ -15,6 +14,8 @@ import {
export { DocumentType, VirtualDocumentType } from "@budibase/types"
const newid = utils.newid
type Optional = string | null
export const enum AppStatus {

View File

@ -26,6 +26,7 @@ import {
roles,
sessions,
tenancy,
utils,
} from "@budibase/backend-core"
import {
app as appController,
@ -40,7 +41,6 @@ import {
} from "./controllers"
import { cleanup } from "../../utilities/fileSystem"
import newid from "../../db/newid"
import { generateUserMetadataID } from "../../db/utils"
import { startup } from "../../startup"
import supertest from "supertest"
@ -74,6 +74,8 @@ import { cloneDeep } from "lodash"
import jwt, { Secret } from "jsonwebtoken"
import { Server } from "http"
const newid = utils.newid
mocks.licenses.init(pro)
// use unlimited license by default