fix circular dependency issues
This commit is contained in:
parent
d7737b90c7
commit
c4f424cb80
|
@ -2,7 +2,8 @@ import { newid } from "../hashing"
|
||||||
import { DEFAULT_TENANT_ID, Configs } from "../constants"
|
import { DEFAULT_TENANT_ID, Configs } from "../constants"
|
||||||
import env from "../environment"
|
import env from "../environment"
|
||||||
import { SEPARATOR, DocumentType, UNICODE_MAX, ViewName } from "./constants"
|
import { SEPARATOR, DocumentType, UNICODE_MAX, ViewName } from "./constants"
|
||||||
import { getTenantId, getGlobalDBName, getGlobalDB } from "../tenancy"
|
import { getTenantId, getGlobalDB } from "../context"
|
||||||
|
import { getGlobalDBName } from "../tenancy/utils"
|
||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
import { doWithDB, allDbs } from "./index"
|
import { doWithDB, allDbs } from "./index"
|
||||||
import { getCouchInfo } from "./pouch"
|
import { getCouchInfo } from "./pouch"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { DocumentType, ViewName, DeprecatedViews, SEPARATOR } from "./utils"
|
import { DocumentType, ViewName, DeprecatedViews, SEPARATOR } from "./utils"
|
||||||
import { getGlobalDB } from "../tenancy"
|
import { getGlobalDB } from "../context"
|
||||||
import { StaticDatabases } from "./constants"
|
import { StaticDatabases } from "./constants"
|
||||||
import { doWithDB } from "./"
|
import { doWithDB } from "./"
|
||||||
|
|
||||||
|
@ -256,5 +256,5 @@ export const queryGlobalView = async <T>(
|
||||||
if (!db) {
|
if (!db) {
|
||||||
db = getGlobalDB() as PouchDB.Database
|
db = getGlobalDB() as PouchDB.Database
|
||||||
}
|
}
|
||||||
return queryView(viewName, params, db, CreateFuncByName)
|
return queryView(viewName, params, db, CreateFuncByName, opts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import * as context from "../context"
|
import * as context from "../context"
|
||||||
import * as tenancy from "./tenancy"
|
import * as tenancy from "./tenancy"
|
||||||
|
import * as utils from "./utils"
|
||||||
|
|
||||||
const pkg = {
|
const pkg = {
|
||||||
...context,
|
...context,
|
||||||
...tenancy,
|
...tenancy,
|
||||||
|
...utils,
|
||||||
}
|
}
|
||||||
|
|
||||||
export = pkg
|
export = pkg
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { doWithDB } from "../db"
|
import { doWithDB } from "../db"
|
||||||
import { queryPlatformView } from "../db/views"
|
import { queryPlatformView } from "../db/views"
|
||||||
import { StaticDatabases, ViewName } from "../db/constants"
|
import { StaticDatabases, ViewName } from "../db/constants"
|
||||||
import { baseGlobalDBName } from "./utils"
|
import { getGlobalDBName } from "./utils"
|
||||||
import {
|
import {
|
||||||
getTenantId,
|
getTenantId,
|
||||||
DEFAULT_TENANT_ID,
|
DEFAULT_TENANT_ID,
|
||||||
|
@ -88,15 +88,6 @@ export const tryAddTenant = async (
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getGlobalDBName = (tenantId?: string) => {
|
|
||||||
// tenant ID can be set externally, for example user API where
|
|
||||||
// new tenants are being created, this may be the case
|
|
||||||
if (!tenantId) {
|
|
||||||
tenantId = getTenantId()
|
|
||||||
}
|
|
||||||
return baseGlobalDBName(tenantId)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const doWithGlobalDB = (tenantId: string, cb: any) => {
|
export const doWithGlobalDB = (tenantId: string, cb: any) => {
|
||||||
return doWithDB(getGlobalDBName(tenantId), cb)
|
return doWithDB(getGlobalDBName(tenantId), cb)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
import { DEFAULT_TENANT_ID } from "../constants"
|
import { DEFAULT_TENANT_ID } from "../constants"
|
||||||
import { StaticDatabases, SEPARATOR } from "../db/constants"
|
import { StaticDatabases, SEPARATOR } from "../db/constants"
|
||||||
|
import { getTenantId } from "../context"
|
||||||
|
|
||||||
|
export const getGlobalDBName = (tenantId?: string) => {
|
||||||
|
// tenant ID can be set externally, for example user API where
|
||||||
|
// new tenants are being created, this may be the case
|
||||||
|
if (!tenantId) {
|
||||||
|
tenantId = getTenantId()
|
||||||
|
}
|
||||||
|
return baseGlobalDBName(tenantId)
|
||||||
|
}
|
||||||
|
|
||||||
export const baseGlobalDBName = (tenantId: string | undefined | null) => {
|
export const baseGlobalDBName = (tenantId: string | undefined | null) => {
|
||||||
let dbName
|
let dbName
|
||||||
|
|
Loading…
Reference in New Issue