@budibase/backend-core 2.8.22-alpha.1 → 2.8.22-alpha.2
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/package.json +3 -3
- package/dist/src/environment.d.ts +1 -0
- package/dist/src/environment.js +1 -1
- package/dist/src/environment.js.map +1 -1
- package/dist/src/errors/errors.d.ts +6 -0
- package/dist/src/errors/errors.js +13 -1
- package/dist/src/errors/errors.js.map +1 -1
- package/dist/src/events/identification.d.ts +1 -0
- package/dist/src/events/identification.js +4 -2
- package/dist/src/events/identification.js.map +1 -1
- package/dist/tests/core/utilities/structures/accounts.d.ts +1 -1
- package/dist/tests/core/utilities/structures/accounts.js +2 -17
- package/dist/tests/core/utilities/structures/accounts.js.map +1 -1
- package/dist/tests/core/utilities/structures/db.js +3 -3
- package/dist/tests/core/utilities/structures/db.js.map +1 -1
- package/dist/tests/core/utilities/structures/documents/index.d.ts +1 -0
- package/dist/tests/core/utilities/structures/documents/index.js +18 -0
- package/dist/tests/core/utilities/structures/documents/index.js.map +1 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.d.ts +1 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js +28 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js.map +1 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.d.ts +2 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js +38 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +1 -0
- package/dist/tests/core/utilities/structures/index.d.ts +1 -0
- package/dist/tests/core/utilities/structures/index.js +2 -1
- package/dist/tests/core/utilities/structures/index.js.map +1 -1
- package/dist/tests/core/utilities/structures/licenses.d.ts +7 -3
- package/dist/tests/core/utilities/structures/licenses.js +14 -1
- package/dist/tests/core/utilities/structures/licenses.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/environment.ts +1 -0
- package/src/errors/errors.ts +12 -0
- package/src/events/identification.ts +1 -1
- package/tests/core/utilities/structures/accounts.ts +2 -1
- package/tests/core/utilities/structures/db.ts +3 -3
- package/tests/core/utilities/structures/documents/index.ts +1 -0
- package/tests/core/utilities/structures/documents/platform/index.ts +1 -0
- package/tests/core/utilities/structures/documents/platform/installation.ts +12 -0
- package/tests/core/utilities/structures/index.ts +1 -0
- package/tests/core/utilities/structures/licenses.ts +31 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.8.22-alpha.
|
|
3
|
+
"version": "2.8.22-alpha.2",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@budibase/nano": "10.1.2",
|
|
24
24
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
25
|
-
"@budibase/types": "2.8.22-alpha.
|
|
25
|
+
"@budibase/types": "2.8.22-alpha.2",
|
|
26
26
|
"@shopify/jest-koa-mocks": "5.0.1",
|
|
27
27
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
28
28
|
"aws-cloudfront-sign": "2.2.0",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "79d65782cd33fc931a3581efd99dd07c7e89b22b"
|
|
106
106
|
}
|
package/src/environment.ts
CHANGED
package/src/errors/errors.ts
CHANGED
|
@@ -55,6 +55,18 @@ export class HTTPError extends BudibaseError {
|
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export class NotFoundError extends HTTPError {
|
|
59
|
+
constructor(message: string) {
|
|
60
|
+
super(message, 404)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export class BadRequestError extends HTTPError {
|
|
65
|
+
constructor(message: string) {
|
|
66
|
+
super(message, 400)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
58
70
|
// LICENSING
|
|
59
71
|
|
|
60
72
|
export class UsageLimitError extends HTTPError {
|
|
@@ -264,7 +264,7 @@ const getEventTenantId = async (tenantId: string): Promise<string> => {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
const getUniqueTenantId = async (tenantId: string): Promise<string> => {
|
|
267
|
+
export const getUniqueTenantId = async (tenantId: string): Promise<string> => {
|
|
268
268
|
// make sure this tenantId always matches the tenantId in context
|
|
269
269
|
return context.doInTenant(tenantId, () => {
|
|
270
270
|
return withCache(CacheKey.UNIQUE_TENANT_ID, TTL.ONE_DAY, async () => {
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from "@budibase/types"
|
|
14
14
|
import _ from "lodash"
|
|
15
15
|
|
|
16
|
-
export const account = (): Account => {
|
|
16
|
+
export const account = (partial: Partial<Account> = {}): Account => {
|
|
17
17
|
return {
|
|
18
18
|
accountId: uuid(),
|
|
19
19
|
tenantId: generator.word(),
|
|
@@ -29,6 +29,7 @@ export const account = (): Account => {
|
|
|
29
29
|
size: "10+",
|
|
30
30
|
profession: "Software Engineer",
|
|
31
31
|
quotaUsage: quotas.usage(),
|
|
32
|
+
...partial,
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generator } from "./generator"
|
|
2
2
|
import { newid } from "../../../../src/docIds/newid"
|
|
3
3
|
|
|
4
4
|
export function id() {
|
|
@@ -6,7 +6,7 @@ export function id() {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function rev() {
|
|
9
|
-
return `${
|
|
9
|
+
return `${generator.character({
|
|
10
10
|
numeric: true,
|
|
11
|
-
})}-${
|
|
11
|
+
})}-${generator.guid().replace(/-/, "")}`
|
|
12
12
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./platform"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as installation from "./installation"
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { generator } from "../../generator"
|
|
2
|
+
import { Installation } from "@budibase/types"
|
|
3
|
+
import * as db from "../../db"
|
|
4
|
+
|
|
5
|
+
export function install(): Installation {
|
|
6
|
+
return {
|
|
7
|
+
_id: "install",
|
|
8
|
+
_rev: db.rev(),
|
|
9
|
+
installId: generator.guid(),
|
|
10
|
+
version: generator.string(),
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -2,6 +2,7 @@ export * from "./common"
|
|
|
2
2
|
export * as accounts from "./accounts"
|
|
3
3
|
export * as apps from "./apps"
|
|
4
4
|
export * as db from "./db"
|
|
5
|
+
export * as docs from "./documents"
|
|
5
6
|
export * as koa from "./koa"
|
|
6
7
|
export * as licenses from "./licenses"
|
|
7
8
|
export * as plugins from "./plugins"
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
Customer,
|
|
4
4
|
Feature,
|
|
5
5
|
License,
|
|
6
|
+
OfflineIdentifier,
|
|
7
|
+
OfflineLicense,
|
|
6
8
|
PlanModel,
|
|
7
9
|
PlanType,
|
|
8
10
|
PriceDuration,
|
|
@@ -11,6 +13,7 @@ import {
|
|
|
11
13
|
Quotas,
|
|
12
14
|
Subscription,
|
|
13
15
|
} from "@budibase/types"
|
|
16
|
+
import { generator } from "./generator"
|
|
14
17
|
|
|
15
18
|
export function price(): PurchasedPrice {
|
|
16
19
|
return {
|
|
@@ -127,15 +130,15 @@ export function subscription(): Subscription {
|
|
|
127
130
|
}
|
|
128
131
|
}
|
|
129
132
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
): License => {
|
|
133
|
+
interface GenerateLicenseOpts {
|
|
134
|
+
quotas?: Quotas
|
|
135
|
+
plan?: PurchasedPlan
|
|
136
|
+
planType?: PlanType
|
|
137
|
+
features?: Feature[]
|
|
138
|
+
billing?: Billing
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export const license = (opts: GenerateLicenseOpts = {}): License => {
|
|
139
142
|
return {
|
|
140
143
|
features: opts.features || [],
|
|
141
144
|
quotas: opts.quotas || quotas(),
|
|
@@ -143,3 +146,22 @@ export const license = (
|
|
|
143
146
|
billing: opts.billing || billing(),
|
|
144
147
|
}
|
|
145
148
|
}
|
|
149
|
+
|
|
150
|
+
export function offlineLicense(opts: GenerateLicenseOpts = {}): OfflineLicense {
|
|
151
|
+
const base = license(opts)
|
|
152
|
+
return {
|
|
153
|
+
...base,
|
|
154
|
+
expireAt: new Date().toISOString(),
|
|
155
|
+
identifier: offlineIdentifier(),
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function offlineIdentifier(
|
|
160
|
+
installId: string = generator.guid(),
|
|
161
|
+
tenantId: string = generator.guid()
|
|
162
|
+
): OfflineIdentifier {
|
|
163
|
+
return {
|
|
164
|
+
installId,
|
|
165
|
+
tenantId,
|
|
166
|
+
}
|
|
167
|
+
}
|