@budibase/backend-core 2.17.8 → 2.18.0
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 +50182 -39
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +8 -8
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/context/types.d.ts +2 -3
- package/dist/src/timers/timers.d.ts +0 -12
- package/dist/src/timers/timers.js +1 -38
- package/dist/src/timers/timers.js.map +1 -1
- package/dist/tests/core/utilities/structures/common.js +1 -1
- package/dist/tests/core/utilities/structures/common.js.map +1 -1
- package/dist/tests/core/utilities/structures/sso.js +1 -1
- package/dist/tests/core/utilities/structures/sso.js.map +1 -1
- package/dist/tests/core/utilities/structures/users.js +1 -1
- package/dist/tests/core/utilities/structures/users.js.map +1 -1
- package/package.json +8 -8
- package/src/context/types.ts +2 -3
- package/src/timers/timers.ts +0 -38
- package/src/utils/tests/utils.spec.ts +4 -4
- package/tests/core/utilities/structures/common.ts +1 -1
- package/tests/core/utilities/structures/sso.ts +1 -1
- package/tests/core/utilities/structures/users.ts +1 -1
package/src/timers/timers.ts
CHANGED
|
@@ -20,41 +20,3 @@ export function cleanup() {
|
|
|
20
20
|
}
|
|
21
21
|
intervals = []
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
export class ExecutionTimeoutError extends Error {
|
|
25
|
-
public readonly name = "ExecutionTimeoutError"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export class ExecutionTimeTracker {
|
|
29
|
-
static withLimit(limitMs: number) {
|
|
30
|
-
return new ExecutionTimeTracker(limitMs)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
constructor(readonly limitMs: number) {}
|
|
34
|
-
|
|
35
|
-
private totalTimeMs = 0
|
|
36
|
-
|
|
37
|
-
track<T>(f: () => T): T {
|
|
38
|
-
this.checkLimit()
|
|
39
|
-
const start = process.hrtime.bigint()
|
|
40
|
-
try {
|
|
41
|
-
return f()
|
|
42
|
-
} finally {
|
|
43
|
-
const end = process.hrtime.bigint()
|
|
44
|
-
this.totalTimeMs += Number(end - start) / 1e6
|
|
45
|
-
this.checkLimit()
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
get elapsedMS() {
|
|
50
|
-
return this.totalTimeMs
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
checkLimit() {
|
|
54
|
-
if (this.totalTimeMs > this.limitMs) {
|
|
55
|
-
throw new ExecutionTimeoutError(
|
|
56
|
-
`Execution time limit of ${this.limitMs}ms exceeded: ${this.totalTimeMs}ms`
|
|
57
|
-
)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -44,11 +44,11 @@ describe("utils", () => {
|
|
|
44
44
|
|
|
45
45
|
it("gets appId from url", async () => {
|
|
46
46
|
await config.doInTenant(async () => {
|
|
47
|
-
const url = "http://
|
|
47
|
+
const url = "http://example.com"
|
|
48
48
|
env._set("PLATFORM_URL", url)
|
|
49
49
|
|
|
50
50
|
const ctx = structures.koa.newContext()
|
|
51
|
-
ctx.host = `${config.tenantId}.
|
|
51
|
+
ctx.host = `${config.tenantId}.example.com`
|
|
52
52
|
|
|
53
53
|
const expected = db.generateAppID(config.tenantId)
|
|
54
54
|
const app = structures.apps.app(expected)
|
|
@@ -89,7 +89,7 @@ describe("utils", () => {
|
|
|
89
89
|
const ctx = structures.koa.newContext()
|
|
90
90
|
const expected = db.generateAppID()
|
|
91
91
|
ctx.request.headers = {
|
|
92
|
-
referer: `http://
|
|
92
|
+
referer: `http://example.com/builder/app/${expected}/design/screen_123/screens`,
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
const actual = await utils.getAppIdFromCtx(ctx)
|
|
@@ -100,7 +100,7 @@ describe("utils", () => {
|
|
|
100
100
|
const ctx = structures.koa.newContext()
|
|
101
101
|
const appId = db.generateAppID()
|
|
102
102
|
ctx.request.headers = {
|
|
103
|
-
referer: `http://
|
|
103
|
+
referer: `http://example.com/foo/app/${appId}/bar`,
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
const actual = await utils.getAppIdFromCtx(ctx)
|
|
@@ -25,7 +25,7 @@ export const user = (userProps?: Partial<Omit<User, "userId">>): User => {
|
|
|
25
25
|
roles: { app_test: "admin" },
|
|
26
26
|
firstName: generator.first(),
|
|
27
27
|
lastName: generator.last(),
|
|
28
|
-
pictureUrl: "http://
|
|
28
|
+
pictureUrl: "http://example.com",
|
|
29
29
|
tenantId: tenant.id(),
|
|
30
30
|
...userProps,
|
|
31
31
|
}
|