@budibase/backend-core 3.2.4 → 3.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js.map +1 -1
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +11 -4
- package/dist/plugins.js.meta.json +1 -1
- package/package.json +11 -4
- package/src/accounts/accounts.ts +0 -82
- package/src/accounts/api.ts +0 -59
- package/src/accounts/index.ts +0 -1
- package/src/auth/auth.ts +0 -210
- package/src/auth/index.ts +0 -1
- package/src/auth/tests/auth.spec.ts +0 -14
- package/src/blacklist/blacklist.ts +0 -54
- package/src/blacklist/index.ts +0 -1
- package/src/blacklist/tests/blacklist.spec.ts +0 -46
- package/src/cache/appMetadata.ts +0 -88
- package/src/cache/base/index.ts +0 -150
- package/src/cache/docWritethrough.ts +0 -105
- package/src/cache/generic.ts +0 -33
- package/src/cache/index.ts +0 -8
- package/src/cache/invite.ts +0 -86
- package/src/cache/passwordReset.ts +0 -49
- package/src/cache/tests/docWritethrough.spec.ts +0 -296
- package/src/cache/tests/user.spec.ts +0 -145
- package/src/cache/tests/writethrough.spec.ts +0 -139
- package/src/cache/user.ts +0 -154
- package/src/cache/writethrough.ts +0 -133
- package/src/configs/configs.ts +0 -263
- package/src/configs/index.ts +0 -1
- package/src/configs/tests/configs.spec.ts +0 -184
- package/src/constants/db.ts +0 -75
- package/src/constants/index.ts +0 -2
- package/src/constants/misc.ts +0 -36
- package/src/context/Context.ts +0 -14
- package/src/context/identity.ts +0 -58
- package/src/context/index.ts +0 -3
- package/src/context/mainContext.ts +0 -422
- package/src/context/tests/index.spec.ts +0 -255
- package/src/context/types.ts +0 -26
- package/src/db/Replication.ts +0 -94
- package/src/db/couch/DatabaseImpl.ts +0 -511
- package/src/db/couch/connections.ts +0 -89
- package/src/db/couch/index.ts +0 -4
- package/src/db/couch/pouchDB.ts +0 -97
- package/src/db/couch/pouchDump.ts +0 -0
- package/src/db/couch/tests/DatabaseImpl.spec.ts +0 -118
- package/src/db/couch/utils.ts +0 -55
- package/src/db/db.ts +0 -34
- package/src/db/errors.ts +0 -14
- package/src/db/index.ts +0 -12
- package/src/db/instrumentation.ts +0 -199
- package/src/db/lucene.ts +0 -721
- package/src/db/searchIndexes/index.ts +0 -1
- package/src/db/searchIndexes/searchIndexes.ts +0 -62
- package/src/db/tests/DatabaseImpl.spec.ts +0 -55
- package/src/db/tests/connections.spec.ts +0 -22
- package/src/db/tests/index.spec.ts +0 -32
- package/src/db/tests/lucene.spec.ts +0 -400
- package/src/db/tests/pouch.spec.js +0 -62
- package/src/db/tests/utils.spec.ts +0 -63
- package/src/db/utils.ts +0 -208
- package/src/db/views.ts +0 -245
- package/src/docIds/conversions.ts +0 -60
- package/src/docIds/ids.ts +0 -126
- package/src/docIds/index.ts +0 -2
- package/src/docIds/newid.ts +0 -5
- package/src/docIds/params.ts +0 -189
- package/src/docUpdates/index.ts +0 -24
- package/src/environment.ts +0 -293
- package/src/errors/errors.ts +0 -119
- package/src/errors/index.ts +0 -1
- package/src/events/analytics.ts +0 -6
- package/src/events/asyncEvents/index.ts +0 -2
- package/src/events/asyncEvents/publisher.ts +0 -12
- package/src/events/asyncEvents/queue.ts +0 -22
- package/src/events/backfill.ts +0 -183
- package/src/events/documentId.ts +0 -56
- package/src/events/events.ts +0 -47
- package/src/events/identification.ts +0 -311
- package/src/events/index.ts +0 -15
- package/src/events/processors/AnalyticsProcessor.ts +0 -64
- package/src/events/processors/AuditLogsProcessor.ts +0 -92
- package/src/events/processors/LoggingProcessor.ts +0 -36
- package/src/events/processors/Processors.ts +0 -52
- package/src/events/processors/async/DocumentUpdateProcessor.ts +0 -38
- package/src/events/processors/index.ts +0 -19
- package/src/events/processors/posthog/PosthogProcessor.ts +0 -118
- package/src/events/processors/posthog/index.ts +0 -3
- package/src/events/processors/posthog/rateLimiting.ts +0 -106
- package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +0 -164
- package/src/events/processors/types.ts +0 -1
- package/src/events/publishers/account.ts +0 -41
- package/src/events/publishers/ai.ts +0 -21
- package/src/events/publishers/app.ts +0 -168
- package/src/events/publishers/auditLog.ts +0 -26
- package/src/events/publishers/auth.ts +0 -73
- package/src/events/publishers/automation.ts +0 -110
- package/src/events/publishers/backfill.ts +0 -74
- package/src/events/publishers/backup.ts +0 -42
- package/src/events/publishers/datasource.ts +0 -48
- package/src/events/publishers/email.ts +0 -17
- package/src/events/publishers/environmentVariable.ts +0 -38
- package/src/events/publishers/group.ts +0 -99
- package/src/events/publishers/index.ts +0 -25
- package/src/events/publishers/installation.ts +0 -38
- package/src/events/publishers/layout.ts +0 -26
- package/src/events/publishers/license.ts +0 -84
- package/src/events/publishers/org.ts +0 -37
- package/src/events/publishers/plugin.ts +0 -47
- package/src/events/publishers/query.ts +0 -89
- package/src/events/publishers/role.ts +0 -62
- package/src/events/publishers/rows.ts +0 -29
- package/src/events/publishers/screen.ts +0 -36
- package/src/events/publishers/serve.ts +0 -43
- package/src/events/publishers/table.ts +0 -70
- package/src/events/publishers/user.ts +0 -202
- package/src/events/publishers/view.ts +0 -107
- package/src/features/features.ts +0 -277
- package/src/features/index.ts +0 -2
- package/src/features/tests/features.spec.ts +0 -267
- package/src/features/tests/utils.ts +0 -64
- package/src/helpers.ts +0 -9
- package/src/index.ts +0 -59
- package/src/installation.ts +0 -115
- package/src/logging/alerts.ts +0 -26
- package/src/logging/correlation/correlation.ts +0 -15
- package/src/logging/correlation/index.ts +0 -1
- package/src/logging/correlation/middleware.ts +0 -18
- package/src/logging/index.ts +0 -4
- package/src/logging/pino/logger.ts +0 -239
- package/src/logging/pino/middleware.ts +0 -48
- package/src/logging/system.ts +0 -81
- package/src/logging/tests/system.spec.ts +0 -61
- package/src/middleware/adminOnly.ts +0 -9
- package/src/middleware/auditLog.ts +0 -6
- package/src/middleware/authenticated.ts +0 -247
- package/src/middleware/builderOnly.ts +0 -21
- package/src/middleware/builderOrAdmin.ts +0 -21
- package/src/middleware/contentSecurityPolicy.ts +0 -113
- package/src/middleware/csrf.ts +0 -81
- package/src/middleware/errorHandling.ts +0 -43
- package/src/middleware/index.ts +0 -24
- package/src/middleware/internalApi.ts +0 -23
- package/src/middleware/ip.ts +0 -12
- package/src/middleware/joi-validator.ts +0 -58
- package/src/middleware/matchers.ts +0 -39
- package/src/middleware/passport/datasource/google.ts +0 -102
- package/src/middleware/passport/local.ts +0 -54
- package/src/middleware/passport/sso/google.ts +0 -77
- package/src/middleware/passport/sso/oidc.ts +0 -152
- package/src/middleware/passport/sso/sso.ts +0 -138
- package/src/middleware/passport/sso/tests/google.spec.ts +0 -68
- package/src/middleware/passport/sso/tests/oidc.spec.ts +0 -144
- package/src/middleware/passport/sso/tests/sso.spec.ts +0 -197
- package/src/middleware/passport/utils.ts +0 -38
- package/src/middleware/querystringToBody.ts +0 -28
- package/src/middleware/tenancy.ts +0 -36
- package/src/middleware/tests/builder.spec.ts +0 -181
- package/src/middleware/tests/contentSecurityPolicy.spec.ts +0 -75
- package/src/middleware/tests/matchers.spec.ts +0 -100
- package/src/migrations/definitions.ts +0 -40
- package/src/migrations/index.ts +0 -2
- package/src/migrations/migrations.ts +0 -186
- package/src/migrations/tests/__snapshots__/migrations.spec.ts.snap +0 -11
- package/src/migrations/tests/migrations.spec.ts +0 -64
- package/src/objectStore/buckets/app.ts +0 -53
- package/src/objectStore/buckets/global.ts +0 -29
- package/src/objectStore/buckets/index.ts +0 -3
- package/src/objectStore/buckets/plugins.ts +0 -71
- package/src/objectStore/buckets/tests/app.spec.ts +0 -161
- package/src/objectStore/buckets/tests/global.spec.ts +0 -74
- package/src/objectStore/buckets/tests/plugins.spec.ts +0 -111
- package/src/objectStore/cloudfront.ts +0 -41
- package/src/objectStore/index.ts +0 -3
- package/src/objectStore/objectStore.ts +0 -585
- package/src/objectStore/utils.ts +0 -113
- package/src/platform/index.ts +0 -3
- package/src/platform/platformDb.ts +0 -6
- package/src/platform/tenants.ts +0 -101
- package/src/platform/tests/tenants.spec.ts +0 -26
- package/src/platform/users.ts +0 -129
- package/src/plugin/index.ts +0 -1
- package/src/plugin/tests/validation.spec.ts +0 -209
- package/src/plugin/utils.ts +0 -175
- package/src/queue/constants.ts +0 -8
- package/src/queue/inMemoryQueue.ts +0 -189
- package/src/queue/index.ts +0 -2
- package/src/queue/listeners.ts +0 -199
- package/src/queue/queue.ts +0 -84
- package/src/redis/index.ts +0 -6
- package/src/redis/init.ts +0 -118
- package/src/redis/redis.ts +0 -358
- package/src/redis/redlockImpl.ts +0 -155
- package/src/redis/tests/redis.spec.ts +0 -207
- package/src/redis/tests/redlockImpl.spec.ts +0 -105
- package/src/redis/utils.ts +0 -128
- package/src/security/auth.ts +0 -24
- package/src/security/encryption.ts +0 -185
- package/src/security/index.ts +0 -1
- package/src/security/permissions.ts +0 -166
- package/src/security/roles.ts +0 -655
- package/src/security/secrets.ts +0 -20
- package/src/security/sessions.ts +0 -123
- package/src/security/tests/auth.spec.ts +0 -45
- package/src/security/tests/encryption.spec.ts +0 -31
- package/src/security/tests/permissions.spec.ts +0 -146
- package/src/security/tests/secrets.spec.ts +0 -35
- package/src/security/tests/sessions.spec.ts +0 -12
- package/src/sql/designDoc.ts +0 -17
- package/src/sql/index.ts +0 -5
- package/src/sql/sql.ts +0 -1854
- package/src/sql/sqlTable.ts +0 -319
- package/src/sql/utils.ts +0 -193
- package/src/tenancy/db.ts +0 -6
- package/src/tenancy/index.ts +0 -2
- package/src/tenancy/tenancy.ts +0 -148
- package/src/tenancy/tests/tenancy.spec.ts +0 -184
- package/src/timers/index.ts +0 -1
- package/src/timers/timers.ts +0 -22
- package/src/users/db.ts +0 -582
- package/src/users/events.ts +0 -176
- package/src/users/index.ts +0 -4
- package/src/users/lookup.ts +0 -99
- package/src/users/test/db.spec.ts +0 -188
- package/src/users/test/utils.spec.ts +0 -67
- package/src/users/users.ts +0 -353
- package/src/users/utils.ts +0 -81
- package/src/utils/Duration.ts +0 -56
- package/src/utils/hashing.ts +0 -15
- package/src/utils/index.ts +0 -4
- package/src/utils/stringUtils.ts +0 -8
- package/src/utils/tests/Duration.spec.ts +0 -19
- package/src/utils/tests/utils.spec.ts +0 -204
- package/src/utils/utils.ts +0 -249
- package/tests/core/logging.ts +0 -34
- package/tests/core/users/users.spec.js +0 -53
- package/tests/core/utilities/index.ts +0 -7
- package/tests/core/utilities/jestUtils.ts +0 -33
- package/tests/core/utilities/mocks/alerts.ts +0 -4
- package/tests/core/utilities/mocks/date.ts +0 -3
- package/tests/core/utilities/mocks/events.ts +0 -132
- package/tests/core/utilities/mocks/index.ts +0 -9
- package/tests/core/utilities/mocks/licenses.ts +0 -119
- package/tests/core/utilities/queue.ts +0 -9
- package/tests/core/utilities/structures/Chance.ts +0 -20
- package/tests/core/utilities/structures/accounts.ts +0 -80
- package/tests/core/utilities/structures/apps.ts +0 -21
- package/tests/core/utilities/structures/common.ts +0 -7
- package/tests/core/utilities/structures/db.ts +0 -12
- package/tests/core/utilities/structures/documents/index.ts +0 -1
- package/tests/core/utilities/structures/documents/platform/index.ts +0 -1
- package/tests/core/utilities/structures/documents/platform/installation.ts +0 -12
- package/tests/core/utilities/structures/generator.ts +0 -3
- package/tests/core/utilities/structures/index.ts +0 -15
- package/tests/core/utilities/structures/koa.ts +0 -16
- package/tests/core/utilities/structures/licenses.ts +0 -190
- package/tests/core/utilities/structures/plugins.ts +0 -19
- package/tests/core/utilities/structures/quotas.ts +0 -72
- package/tests/core/utilities/structures/scim.ts +0 -80
- package/tests/core/utilities/structures/sso.ts +0 -118
- package/tests/core/utilities/structures/tenants.ts +0 -5
- package/tests/core/utilities/structures/userGroups.ts +0 -10
- package/tests/core/utilities/structures/users.ts +0 -89
- package/tests/core/utilities/testContainerUtils.ts +0 -165
- package/tests/core/utilities/utils/index.ts +0 -2
- package/tests/core/utilities/utils/queue.ts +0 -27
- package/tests/core/utilities/utils/time.ts +0 -3
- package/tests/extra/DBTestConfiguration.ts +0 -36
- package/tests/extra/index.ts +0 -2
- package/tests/extra/testEnv.ts +0 -95
- package/tests/index.ts +0 -2
- package/tests/jestEnv.ts +0 -10
- package/tests/jestSetup.ts +0 -36
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { User, SearchIndex } from "@budibase/types"
|
|
2
|
-
import { getGlobalDB } from "../../context"
|
|
3
|
-
|
|
4
|
-
export async function createUserIndex() {
|
|
5
|
-
const db = getGlobalDB()
|
|
6
|
-
let designDoc
|
|
7
|
-
try {
|
|
8
|
-
designDoc = await db.get<any>("_design/database")
|
|
9
|
-
} catch (err: any) {
|
|
10
|
-
if (err.status === 404) {
|
|
11
|
-
designDoc = { _id: "_design/database" }
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const fn = function (user: User) {
|
|
16
|
-
if (user._id && !user._id.startsWith("us_")) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
const ignoredFields = [
|
|
20
|
-
"_id",
|
|
21
|
-
"_rev",
|
|
22
|
-
"password",
|
|
23
|
-
"account",
|
|
24
|
-
"license",
|
|
25
|
-
"budibaseAccess",
|
|
26
|
-
"accountPortalAccess",
|
|
27
|
-
"csrfToken",
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
function idx(input: Record<string, any>, prev?: string) {
|
|
31
|
-
for (let key of Object.keys(input)) {
|
|
32
|
-
if (ignoredFields.includes(key)) {
|
|
33
|
-
continue
|
|
34
|
-
}
|
|
35
|
-
let idxKey = prev != null ? `${prev}.${key}` : key
|
|
36
|
-
if (typeof input[key] === "string") {
|
|
37
|
-
// @ts-expect-error index is available in a CouchDB map function
|
|
38
|
-
// eslint-disable-next-line no-undef
|
|
39
|
-
index(idxKey, input[key].toLowerCase(), { facet: true })
|
|
40
|
-
} else if (typeof input[key] !== "object") {
|
|
41
|
-
// @ts-expect-error index is available in a CouchDB map function
|
|
42
|
-
// eslint-disable-next-line no-undef
|
|
43
|
-
index(idxKey, input[key], { facet: true })
|
|
44
|
-
} else {
|
|
45
|
-
idx(input[key], idxKey)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
idx(user)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
designDoc.indexes = {
|
|
53
|
-
[SearchIndex.USER]: {
|
|
54
|
-
index: fn.toString(),
|
|
55
|
-
analyzer: {
|
|
56
|
-
default: "keyword",
|
|
57
|
-
name: "perfield",
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
}
|
|
61
|
-
await db.put(designDoc)
|
|
62
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import _ from "lodash"
|
|
2
|
-
import { AnyDocument } from "@budibase/types"
|
|
3
|
-
import { generator } from "../../../tests"
|
|
4
|
-
import { DatabaseImpl } from "../couch"
|
|
5
|
-
import { newid } from "../../utils"
|
|
6
|
-
|
|
7
|
-
describe("DatabaseImpl", () => {
|
|
8
|
-
const database = new DatabaseImpl(generator.word())
|
|
9
|
-
const documents: AnyDocument[] = []
|
|
10
|
-
|
|
11
|
-
beforeAll(async () => {
|
|
12
|
-
const docsToCreate = Array.from({ length: 10 }).map(() => ({
|
|
13
|
-
_id: newid(),
|
|
14
|
-
}))
|
|
15
|
-
const createdDocs = await database.bulkDocs(docsToCreate)
|
|
16
|
-
|
|
17
|
-
documents.push(...createdDocs.map((x: any) => ({ _id: x.id, _rev: x.rev })))
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
describe("document exists", () => {
|
|
21
|
-
it("can check existing docs by id", async () => {
|
|
22
|
-
const existingDoc = _.sample(documents)
|
|
23
|
-
const result = await database.exists(existingDoc!._id!)
|
|
24
|
-
|
|
25
|
-
expect(result).toBe(true)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it("can check non existing docs by id", async () => {
|
|
29
|
-
const result = await database.exists(newid())
|
|
30
|
-
|
|
31
|
-
expect(result).toBe(false)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it("can check an existing doc by id multiple times", async () => {
|
|
35
|
-
const existingDoc = _.sample(documents)
|
|
36
|
-
const id = existingDoc!._id!
|
|
37
|
-
|
|
38
|
-
const results = []
|
|
39
|
-
results.push(await database.exists(id))
|
|
40
|
-
results.push(await database.exists(id))
|
|
41
|
-
results.push(await database.exists(id))
|
|
42
|
-
|
|
43
|
-
expect(results).toEqual([true, true, true])
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it("returns false after the doc is deleted", async () => {
|
|
47
|
-
const existingDoc = _.sample(documents)
|
|
48
|
-
const id = existingDoc!._id!
|
|
49
|
-
expect(await database.exists(id)).toBe(true)
|
|
50
|
-
|
|
51
|
-
await database.remove(existingDoc!)
|
|
52
|
-
expect(await database.exists(id)).toBe(false)
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import env from "../../environment"
|
|
2
|
-
import { getCouchInfo } from "../couch"
|
|
3
|
-
|
|
4
|
-
const MAIN_COUCH_URL = "http://user:test@localhost:5984"
|
|
5
|
-
|
|
6
|
-
describe("connections", () => {
|
|
7
|
-
beforeAll(() => {
|
|
8
|
-
env._set("COUCH_DB_SQL_URL", "https://user:test@localhost:4984")
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it("should strip URL credentials", () => {
|
|
12
|
-
const response = getCouchInfo(MAIN_COUCH_URL)
|
|
13
|
-
expect(response.url).toBe("http://localhost:5984")
|
|
14
|
-
expect(response.sqlUrl).toBe("https://localhost:4984")
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it("should return separate auth credentials", () => {
|
|
18
|
-
const response = getCouchInfo(MAIN_COUCH_URL)
|
|
19
|
-
expect(response.auth.username).toBe("user")
|
|
20
|
-
expect(response.auth.password).toBe("test")
|
|
21
|
-
})
|
|
22
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { doInTenant } from "../../context"
|
|
2
|
-
import { structures } from "../../../tests"
|
|
3
|
-
import { getDB } from "../db"
|
|
4
|
-
|
|
5
|
-
interface Doc {
|
|
6
|
-
_id: string
|
|
7
|
-
createdAt?: string
|
|
8
|
-
updatedAt?: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe("db", () => {
|
|
12
|
-
describe("getDB", () => {
|
|
13
|
-
it("returns a db", async () => {
|
|
14
|
-
const dbName = structures.db.id()
|
|
15
|
-
const db = getDB(dbName)
|
|
16
|
-
expect(db).toBeDefined()
|
|
17
|
-
expect(db.name).toBe(dbName)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
it("uses the custom put function", async () => {
|
|
21
|
-
await doInTenant("foo", async () => {
|
|
22
|
-
const db = getDB(structures.db.id())
|
|
23
|
-
let doc: Doc = { _id: "test" }
|
|
24
|
-
await db.put(doc)
|
|
25
|
-
doc = await db.get(doc._id)
|
|
26
|
-
expect(doc.createdAt).toBe(new Date().toISOString())
|
|
27
|
-
expect(doc.updatedAt).toBe(new Date().toISOString())
|
|
28
|
-
await db.destroy()
|
|
29
|
-
})
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
})
|
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
import { newid } from "../../docIds/newid"
|
|
2
|
-
import { getDB } from "../db"
|
|
3
|
-
import {
|
|
4
|
-
Database,
|
|
5
|
-
EmptyFilterOption,
|
|
6
|
-
SortOrder,
|
|
7
|
-
SortType,
|
|
8
|
-
DocumentType,
|
|
9
|
-
SEPARATOR,
|
|
10
|
-
} from "@budibase/types"
|
|
11
|
-
import { fullSearch, paginatedSearch, QueryBuilder } from "../lucene"
|
|
12
|
-
|
|
13
|
-
const INDEX_NAME = "main"
|
|
14
|
-
const TABLE_ID = DocumentType.TABLE + SEPARATOR + newid()
|
|
15
|
-
|
|
16
|
-
const index = `function(doc) {
|
|
17
|
-
if (!doc._id.startsWith("ro_")) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
let keys = Object.keys(doc).filter(key => !key.startsWith("_"))
|
|
21
|
-
for (let key of keys) {
|
|
22
|
-
const value = doc[key]
|
|
23
|
-
if (Array.isArray(value)) {
|
|
24
|
-
for (let val of value) {
|
|
25
|
-
index(key, val)
|
|
26
|
-
}
|
|
27
|
-
} else if (value) {
|
|
28
|
-
index(key, value)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}`
|
|
32
|
-
|
|
33
|
-
function rowId(id?: string) {
|
|
34
|
-
return DocumentType.ROW + SEPARATOR + (id || newid())
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe("lucene", () => {
|
|
38
|
-
let db: Database, dbName: string
|
|
39
|
-
|
|
40
|
-
beforeAll(async () => {
|
|
41
|
-
dbName = `db-${newid()}`
|
|
42
|
-
// create the DB for testing
|
|
43
|
-
db = getDB(dbName)
|
|
44
|
-
await db.put({
|
|
45
|
-
_id: rowId(),
|
|
46
|
-
tableId: TABLE_ID,
|
|
47
|
-
property: "word",
|
|
48
|
-
array: ["1", "4"],
|
|
49
|
-
})
|
|
50
|
-
await db.put({
|
|
51
|
-
_id: rowId(),
|
|
52
|
-
tableId: TABLE_ID,
|
|
53
|
-
property: "word2",
|
|
54
|
-
array: ["3", "1"],
|
|
55
|
-
})
|
|
56
|
-
await db.put({
|
|
57
|
-
_id: rowId(),
|
|
58
|
-
tableId: TABLE_ID,
|
|
59
|
-
property: "word3",
|
|
60
|
-
number: 1,
|
|
61
|
-
array: ["1", "2"],
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
it("should be able to create a lucene index", async () => {
|
|
66
|
-
const response = await db.put({
|
|
67
|
-
_id: "_design/database",
|
|
68
|
-
indexes: {
|
|
69
|
-
[INDEX_NAME]: {
|
|
70
|
-
index: index,
|
|
71
|
-
analyzer: "standard",
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
})
|
|
75
|
-
expect(response.ok).toBe(true)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
describe("query builder", () => {
|
|
79
|
-
it("should be able to perform a basic query", async () => {
|
|
80
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
81
|
-
builder.setSort("property")
|
|
82
|
-
builder.setSortOrder("desc")
|
|
83
|
-
builder.setSortType("string")
|
|
84
|
-
const resp = await builder.run()
|
|
85
|
-
expect(resp.rows.length).toBe(3)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it("should handle limits", async () => {
|
|
89
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
90
|
-
builder.setLimit(1)
|
|
91
|
-
const resp = await builder.run()
|
|
92
|
-
expect(resp.rows.length).toBe(1)
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it("should be able to perform a string search", async () => {
|
|
96
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
97
|
-
builder.addString("property", "wo")
|
|
98
|
-
const resp = await builder.run()
|
|
99
|
-
expect(resp.rows.length).toBe(3)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it("should be able to perform a range search", async () => {
|
|
103
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
104
|
-
builder.addRange("number", 0, 1)
|
|
105
|
-
const resp = await builder.run()
|
|
106
|
-
expect(resp.rows.length).toBe(1)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it("should be able to perform an equal search", async () => {
|
|
110
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
111
|
-
builder.addEqual("property", "word2")
|
|
112
|
-
const resp = await builder.run()
|
|
113
|
-
expect(resp.rows.length).toBe(1)
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it("should be able to perform a not equal search", async () => {
|
|
117
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
118
|
-
builder.addNotEqual("property", "word2")
|
|
119
|
-
const resp = await builder.run()
|
|
120
|
-
expect(resp.rows.length).toBe(2)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it("should be able to perform an empty search", async () => {
|
|
124
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
125
|
-
builder.addEmpty("number", true)
|
|
126
|
-
const resp = await builder.run()
|
|
127
|
-
expect(resp.rows.length).toBe(2)
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
it("should be able to perform a not empty search", async () => {
|
|
131
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
132
|
-
builder.addNotEmpty("number", true)
|
|
133
|
-
const resp = await builder.run()
|
|
134
|
-
expect(resp.rows.length).toBe(1)
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
it("should be able to perform a one of search", async () => {
|
|
138
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
139
|
-
builder.addOneOf("property", ["word", "word2"])
|
|
140
|
-
const resp = await builder.run()
|
|
141
|
-
expect(resp.rows.length).toBe(2)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it("should return all rows when doing a one of search against falsey value", async () => {
|
|
145
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
146
|
-
builder.addOneOf("property", null)
|
|
147
|
-
let resp = await builder.run()
|
|
148
|
-
expect(resp.rows.length).toBe(3)
|
|
149
|
-
|
|
150
|
-
builder.addOneOf("property", undefined)
|
|
151
|
-
resp = await builder.run()
|
|
152
|
-
expect(resp.rows.length).toBe(3)
|
|
153
|
-
|
|
154
|
-
builder.addOneOf("property", "")
|
|
155
|
-
resp = await builder.run()
|
|
156
|
-
expect(resp.rows.length).toBe(3)
|
|
157
|
-
|
|
158
|
-
builder.addOneOf("property", [])
|
|
159
|
-
resp = await builder.run()
|
|
160
|
-
expect(resp.rows.length).toBe(0)
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
it("should be able to perform a contains search", async () => {
|
|
164
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
165
|
-
builder.addContains("property", ["word"])
|
|
166
|
-
const resp = await builder.run()
|
|
167
|
-
expect(resp.rows.length).toBe(1)
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it("should be able to perform a not contains search", async () => {
|
|
171
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
172
|
-
builder.addNotContains("property", ["word2"])
|
|
173
|
-
const resp = await builder.run()
|
|
174
|
-
expect(resp.rows.length).toBe(2)
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
it("should be able to perform an or not contains search", async () => {
|
|
178
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
179
|
-
builder.addNotContains("array", ["1"])
|
|
180
|
-
builder.addNotContains("array", ["2"])
|
|
181
|
-
builder.setAllOr()
|
|
182
|
-
const resp = await builder.run()
|
|
183
|
-
expect(resp.rows.length).toBe(2)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
describe("empty filters behaviour", () => {
|
|
187
|
-
it("should return all rows by default", async () => {
|
|
188
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
189
|
-
builder.addEqual("property", "")
|
|
190
|
-
builder.addEqual("number", null)
|
|
191
|
-
builder.addString("property", "")
|
|
192
|
-
builder.addFuzzy("property", "")
|
|
193
|
-
builder.addNotEqual("number", undefined)
|
|
194
|
-
builder.addOneOf("number", null)
|
|
195
|
-
builder.addContains("array", undefined)
|
|
196
|
-
builder.addNotContains("array", null)
|
|
197
|
-
builder.addContainsAny("array", null)
|
|
198
|
-
|
|
199
|
-
const resp = await builder.run()
|
|
200
|
-
expect(resp.rows.length).toBe(3)
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
it("should return all rows when onEmptyFilter is ALL", async () => {
|
|
204
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
205
|
-
builder.setOnEmptyFilter(EmptyFilterOption.RETURN_ALL)
|
|
206
|
-
builder.setAllOr()
|
|
207
|
-
builder.addEqual("property", "")
|
|
208
|
-
builder.addEqual("number", null)
|
|
209
|
-
builder.addString("property", "")
|
|
210
|
-
builder.addFuzzy("property", "")
|
|
211
|
-
builder.addNotEqual("number", undefined)
|
|
212
|
-
builder.addOneOf("number", null)
|
|
213
|
-
builder.addContains("array", undefined)
|
|
214
|
-
builder.addNotContains("array", null)
|
|
215
|
-
builder.addContainsAny("array", null)
|
|
216
|
-
|
|
217
|
-
const resp = await builder.run()
|
|
218
|
-
expect(resp.rows.length).toBe(3)
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
it("should return no rows when onEmptyFilter is NONE", async () => {
|
|
222
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
223
|
-
builder.setOnEmptyFilter(EmptyFilterOption.RETURN_NONE)
|
|
224
|
-
builder.addEqual("property", "")
|
|
225
|
-
builder.addEqual("number", null)
|
|
226
|
-
builder.addString("property", "")
|
|
227
|
-
builder.addFuzzy("property", "")
|
|
228
|
-
builder.addNotEqual("number", undefined)
|
|
229
|
-
builder.addOneOf("number", null)
|
|
230
|
-
builder.addContains("array", undefined)
|
|
231
|
-
builder.addNotContains("array", null)
|
|
232
|
-
builder.addContainsAny("array", null)
|
|
233
|
-
|
|
234
|
-
const resp = await builder.run()
|
|
235
|
-
expect(resp.rows.length).toBe(0)
|
|
236
|
-
})
|
|
237
|
-
|
|
238
|
-
it("should return all matching rows when onEmptyFilter is NONE, but a filter value is provided", async () => {
|
|
239
|
-
const builder = new QueryBuilder(dbName, INDEX_NAME)
|
|
240
|
-
builder.setOnEmptyFilter(EmptyFilterOption.RETURN_NONE)
|
|
241
|
-
builder.addEqual("property", "")
|
|
242
|
-
builder.addEqual("number", 1)
|
|
243
|
-
builder.addString("property", "")
|
|
244
|
-
builder.addFuzzy("property", "")
|
|
245
|
-
builder.addNotEqual("number", undefined)
|
|
246
|
-
builder.addOneOf("number", null)
|
|
247
|
-
builder.addContains("array", undefined)
|
|
248
|
-
builder.addNotContains("array", null)
|
|
249
|
-
builder.addContainsAny("array", null)
|
|
250
|
-
|
|
251
|
-
const resp = await builder.run()
|
|
252
|
-
expect(resp.rows.length).toBe(1)
|
|
253
|
-
})
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
describe("skip", () => {
|
|
257
|
-
const skipDbName = `db-${newid()}`
|
|
258
|
-
let docs: {
|
|
259
|
-
_id: string
|
|
260
|
-
property: string
|
|
261
|
-
array: string[]
|
|
262
|
-
}[]
|
|
263
|
-
|
|
264
|
-
beforeAll(async () => {
|
|
265
|
-
const db = getDB(skipDbName)
|
|
266
|
-
|
|
267
|
-
docs = Array(QueryBuilder.maxLimit * 2.5)
|
|
268
|
-
.fill(0)
|
|
269
|
-
.map((_, i) => ({
|
|
270
|
-
_id: rowId(i.toString().padStart(3, "0")),
|
|
271
|
-
tableId: TABLE_ID,
|
|
272
|
-
property: `value_${i.toString().padStart(3, "0")}`,
|
|
273
|
-
array: [],
|
|
274
|
-
}))
|
|
275
|
-
await db.bulkDocs(docs)
|
|
276
|
-
|
|
277
|
-
await db.put({
|
|
278
|
-
_id: "_design/database",
|
|
279
|
-
indexes: {
|
|
280
|
-
[INDEX_NAME]: {
|
|
281
|
-
index: index,
|
|
282
|
-
analyzer: "standard",
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
})
|
|
286
|
-
})
|
|
287
|
-
|
|
288
|
-
it("should be able to apply skip", async () => {
|
|
289
|
-
const builder = new QueryBuilder(skipDbName, INDEX_NAME)
|
|
290
|
-
const firstResponse = await builder.run()
|
|
291
|
-
builder.setSkip(40)
|
|
292
|
-
const secondResponse = await builder.run()
|
|
293
|
-
|
|
294
|
-
// Return the default limit
|
|
295
|
-
expect(firstResponse.rows.length).toBe(50)
|
|
296
|
-
expect(secondResponse.rows.length).toBe(50)
|
|
297
|
-
|
|
298
|
-
// Should have the expected overlap
|
|
299
|
-
expect(firstResponse.rows.slice(40)).toEqual(
|
|
300
|
-
secondResponse.rows.slice(0, 10)
|
|
301
|
-
)
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
it("should handle limits", async () => {
|
|
305
|
-
const builder = new QueryBuilder(skipDbName, INDEX_NAME)
|
|
306
|
-
builder.setLimit(10)
|
|
307
|
-
builder.setSkip(50)
|
|
308
|
-
builder.setSort("_id")
|
|
309
|
-
|
|
310
|
-
const resp = await builder.run()
|
|
311
|
-
expect(resp.rows.length).toBe(10)
|
|
312
|
-
expect(resp.rows).toEqual(
|
|
313
|
-
docs.slice(50, 60).map(expect.objectContaining)
|
|
314
|
-
)
|
|
315
|
-
})
|
|
316
|
-
|
|
317
|
-
it("should be able to skip searching through multiple responses", async () => {
|
|
318
|
-
const builder = new QueryBuilder(skipDbName, INDEX_NAME)
|
|
319
|
-
// Skipping 2 max limits plus a little bit more
|
|
320
|
-
const skip = QueryBuilder.maxLimit * 2 + 37
|
|
321
|
-
builder.setSkip(skip)
|
|
322
|
-
builder.setSort("_id")
|
|
323
|
-
const resp = await builder.run()
|
|
324
|
-
|
|
325
|
-
expect(resp.rows.length).toBe(50)
|
|
326
|
-
expect(resp.rows).toEqual(
|
|
327
|
-
docs.slice(skip, skip + resp.rows.length).map(expect.objectContaining)
|
|
328
|
-
)
|
|
329
|
-
})
|
|
330
|
-
|
|
331
|
-
it("should not return results if skipping all docs", async () => {
|
|
332
|
-
const builder = new QueryBuilder(skipDbName, INDEX_NAME)
|
|
333
|
-
// Skipping 2 max limits plus a little bit more
|
|
334
|
-
const skip = docs.length + 1
|
|
335
|
-
builder.setSkip(skip)
|
|
336
|
-
|
|
337
|
-
const resp = await builder.run()
|
|
338
|
-
|
|
339
|
-
expect(resp.rows.length).toBe(0)
|
|
340
|
-
})
|
|
341
|
-
|
|
342
|
-
it("skip should respect with filters", async () => {
|
|
343
|
-
const builder = new QueryBuilder(skipDbName, INDEX_NAME)
|
|
344
|
-
builder.setLimit(10)
|
|
345
|
-
builder.setSkip(50)
|
|
346
|
-
builder.addString("property", "value_1")
|
|
347
|
-
builder.setSort("property")
|
|
348
|
-
|
|
349
|
-
const resp = await builder.run()
|
|
350
|
-
expect(resp.rows.length).toBe(10)
|
|
351
|
-
expect(resp.rows).toEqual(
|
|
352
|
-
docs.slice(150, 160).map(expect.objectContaining)
|
|
353
|
-
)
|
|
354
|
-
})
|
|
355
|
-
})
|
|
356
|
-
})
|
|
357
|
-
|
|
358
|
-
describe("paginated search", () => {
|
|
359
|
-
it("should be able to perform a paginated search", async () => {
|
|
360
|
-
const page = await paginatedSearch(
|
|
361
|
-
dbName,
|
|
362
|
-
INDEX_NAME,
|
|
363
|
-
{
|
|
364
|
-
string: {
|
|
365
|
-
property: "wo",
|
|
366
|
-
},
|
|
367
|
-
},
|
|
368
|
-
{
|
|
369
|
-
tableId: TABLE_ID,
|
|
370
|
-
limit: 1,
|
|
371
|
-
sort: "property",
|
|
372
|
-
sortType: SortType.STRING,
|
|
373
|
-
sortOrder: SortOrder.DESCENDING,
|
|
374
|
-
}
|
|
375
|
-
)
|
|
376
|
-
expect(page.rows.length).toBe(1)
|
|
377
|
-
expect(page.hasNextPage).toBe(true)
|
|
378
|
-
expect(page.bookmark).toBeDefined()
|
|
379
|
-
})
|
|
380
|
-
})
|
|
381
|
-
|
|
382
|
-
describe("full search", () => {
|
|
383
|
-
it("should be able to perform a full search", async () => {
|
|
384
|
-
const page = await fullSearch(
|
|
385
|
-
dbName,
|
|
386
|
-
INDEX_NAME,
|
|
387
|
-
{
|
|
388
|
-
string: {
|
|
389
|
-
property: "wo",
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
{
|
|
393
|
-
tableId: TABLE_ID,
|
|
394
|
-
query: {},
|
|
395
|
-
}
|
|
396
|
-
)
|
|
397
|
-
expect(page.rows.length).toBe(3)
|
|
398
|
-
})
|
|
399
|
-
})
|
|
400
|
-
})
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
require("../../../tests")
|
|
2
|
-
const getUrlInfo = require("../couch").getUrlInfo
|
|
3
|
-
|
|
4
|
-
describe("pouch", () => {
|
|
5
|
-
describe("Couch DB URL parsing", () => {
|
|
6
|
-
it("should handle a null Couch DB URL", () => {
|
|
7
|
-
const info = getUrlInfo(null)
|
|
8
|
-
expect(info.url).toBeUndefined()
|
|
9
|
-
expect(info.auth.username).toBeUndefined()
|
|
10
|
-
})
|
|
11
|
-
it("should be able to parse a basic Couch DB URL", () => {
|
|
12
|
-
const info = getUrlInfo("http://host.com")
|
|
13
|
-
expect(info.url).toBe("http://host.com")
|
|
14
|
-
expect(info.auth.username).toBeUndefined()
|
|
15
|
-
})
|
|
16
|
-
it("should be able to parse a Couch DB basic URL with HTTPS", () => {
|
|
17
|
-
const info = getUrlInfo("https://host.com")
|
|
18
|
-
expect(info.url).toBe("https://host.com")
|
|
19
|
-
expect(info.auth.username).toBeUndefined()
|
|
20
|
-
})
|
|
21
|
-
it("should be able to parse a basic Couch DB URL with a custom port", () => {
|
|
22
|
-
const info = getUrlInfo("https://host.com:1234")
|
|
23
|
-
expect(info.url).toBe("https://host.com:1234")
|
|
24
|
-
expect(info.auth.username).toBeUndefined()
|
|
25
|
-
})
|
|
26
|
-
it("should be able to parse a Couch DB URL with auth", () => {
|
|
27
|
-
const info = getUrlInfo("https://user:pass@host.com:1234")
|
|
28
|
-
expect(info.url).toBe("https://host.com:1234")
|
|
29
|
-
expect(info.auth.username).toBe("user")
|
|
30
|
-
expect(info.auth.password).toBe("pass")
|
|
31
|
-
})
|
|
32
|
-
it("should be able to parse a Couch DB URL with auth and special chars", () => {
|
|
33
|
-
const info = getUrlInfo("https://user:s:p@s://@://:d@;][~s@host.com:1234")
|
|
34
|
-
expect(info.url).toBe("https://host.com:1234")
|
|
35
|
-
expect(info.auth.username).toBe("user")
|
|
36
|
-
expect(info.auth.password).toBe("s:p@s://@://:d@;][~s")
|
|
37
|
-
})
|
|
38
|
-
it("should be able to parse a Couch DB URL without a protocol", () => {
|
|
39
|
-
const info = getUrlInfo("host.com:1234")
|
|
40
|
-
expect(info.url).toBe("http://host.com:1234")
|
|
41
|
-
expect(info.auth.username).toBeUndefined()
|
|
42
|
-
})
|
|
43
|
-
it("should be able to parse a Couch DB URL with auth and without a protocol", () => {
|
|
44
|
-
const info = getUrlInfo("user:s:p@s://@://:d@;][~s@host.com:1234")
|
|
45
|
-
expect(info.url).toBe("http://host.com:1234")
|
|
46
|
-
expect(info.auth.username).toBe("user")
|
|
47
|
-
expect(info.auth.password).toBe("s:p@s://@://:d@;][~s")
|
|
48
|
-
})
|
|
49
|
-
it("should be able to parse a Couch DB URL with only username auth", () => {
|
|
50
|
-
const info = getUrlInfo("https://user@host.com:1234")
|
|
51
|
-
expect(info.url).toBe("https://host.com:1234")
|
|
52
|
-
expect(info.auth.username).toBe("user")
|
|
53
|
-
expect(info.auth.password).toBeUndefined()
|
|
54
|
-
})
|
|
55
|
-
it("should be able to parse a Couch DB URL with only username auth and without a protocol", () => {
|
|
56
|
-
const info = getUrlInfo("user@host.com:1234")
|
|
57
|
-
expect(info.url).toBe("http://host.com:1234")
|
|
58
|
-
expect(info.auth.username).toBe("user")
|
|
59
|
-
expect(info.auth.password).toBeUndefined()
|
|
60
|
-
})
|
|
61
|
-
})
|
|
62
|
-
})
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getDevelopmentAppID,
|
|
3
|
-
getProdAppID,
|
|
4
|
-
isDevAppID,
|
|
5
|
-
isProdAppID,
|
|
6
|
-
} from "../../docIds/conversions"
|
|
7
|
-
import { generateAppID } from "../utils"
|
|
8
|
-
|
|
9
|
-
describe("utils", () => {
|
|
10
|
-
describe("generateAppID", () => {
|
|
11
|
-
function getID() {
|
|
12
|
-
const appId = generateAppID()
|
|
13
|
-
const split = appId.split("_")
|
|
14
|
-
const uuid = split[split.length - 1]
|
|
15
|
-
const devAppId = `app_dev_${uuid}`
|
|
16
|
-
return { appId, devAppId, split, uuid }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
it("should be able to generate a new app ID", () => {
|
|
20
|
-
expect(generateAppID().startsWith("app_")).toEqual(true)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it("should be able to convert a production app ID to development", () => {
|
|
24
|
-
const { appId, uuid } = getID()
|
|
25
|
-
expect(getDevelopmentAppID(appId)).toEqual(`app_dev_${uuid}`)
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
it("should be able to convert a development app ID to development", () => {
|
|
29
|
-
const { devAppId, uuid } = getID()
|
|
30
|
-
expect(getDevelopmentAppID(devAppId)).toEqual(`app_dev_${uuid}`)
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
it("should be able to convert a development ID to a production", () => {
|
|
34
|
-
const { devAppId, uuid } = getID()
|
|
35
|
-
expect(getProdAppID(devAppId)).toEqual(`app_${uuid}`)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it("should be able to convert a production ID to production", () => {
|
|
39
|
-
const { appId, uuid } = getID()
|
|
40
|
-
expect(getProdAppID(appId)).toEqual(`app_${uuid}`)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it("should be able to confirm dev app ID is development", () => {
|
|
44
|
-
const { devAppId } = getID()
|
|
45
|
-
expect(isDevAppID(devAppId)).toEqual(true)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it("should be able to confirm prod app ID is not development", () => {
|
|
49
|
-
const { appId } = getID()
|
|
50
|
-
expect(isDevAppID(appId)).toEqual(false)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it("should be able to confirm prod app ID is prod", () => {
|
|
54
|
-
const { appId } = getID()
|
|
55
|
-
expect(isProdAppID(appId)).toEqual(true)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it("should be able to confirm dev app ID is not prod", () => {
|
|
59
|
-
const { devAppId } = getID()
|
|
60
|
-
expect(isProdAppID(devAppId)).toEqual(false)
|
|
61
|
-
})
|
|
62
|
-
})
|
|
63
|
-
})
|