@budibase/server 2.7.7-alpha.5 → 2.7.7-alpha.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.7.7-alpha.5",
4
+ "version": "2.7.7-alpha.7",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -46,12 +46,12 @@
46
46
  "license": "GPL-3.0",
47
47
  "dependencies": {
48
48
  "@apidevtools/swagger-parser": "10.0.3",
49
- "@budibase/backend-core": "2.7.7-alpha.5",
50
- "@budibase/client": "2.7.7-alpha.5",
51
- "@budibase/pro": "2.7.7-alpha.5",
52
- "@budibase/shared-core": "2.7.7-alpha.5",
53
- "@budibase/string-templates": "2.7.7-alpha.5",
54
- "@budibase/types": "2.7.7-alpha.5",
49
+ "@budibase/backend-core": "2.7.7-alpha.7",
50
+ "@budibase/client": "2.7.7-alpha.7",
51
+ "@budibase/pro": "2.7.7-alpha.7",
52
+ "@budibase/shared-core": "2.7.7-alpha.7",
53
+ "@budibase/string-templates": "2.7.7-alpha.7",
54
+ "@budibase/types": "2.7.7-alpha.7",
55
55
  "@bull-board/api": "3.7.0",
56
56
  "@bull-board/koa": "3.9.4",
57
57
  "@elastic/elasticsearch": "7.10.0",
@@ -195,5 +195,5 @@
195
195
  }
196
196
  }
197
197
  },
198
- "gitHead": "3864187987faae18d05f7a056b7d152c651ca288"
198
+ "gitHead": "9d9022ad8b10316acdce141458bfb434140cdde6"
199
199
  }
@@ -1,14 +1,22 @@
1
1
  import sdk from "../../sdk"
2
- import { events, context } from "@budibase/backend-core"
2
+ import { events, context, db } from "@budibase/backend-core"
3
3
  import { DocumentType } from "../../db/utils"
4
- import { isQsTrue } from "../../utilities"
4
+ import { Ctx } from "@budibase/types"
5
+
6
+ interface ExportAppDumpRequest {
7
+ excludeRows: boolean
8
+ }
9
+
10
+ export async function exportAppDump(ctx: Ctx<ExportAppDumpRequest>) {
11
+ const { appId } = ctx.query as any
12
+ const { excludeRows } = ctx.request.body
13
+
14
+ const [app] = await db.getAppsByIDs([appId])
15
+ const appName = app.name
5
16
 
6
- export async function exportAppDump(ctx: any) {
7
- let { appId, excludeRows } = ctx.query
8
17
  // remove the 120 second limit for the request
9
18
  ctx.req.setTimeout(0)
10
- const appName = decodeURI(ctx.query.appname)
11
- excludeRows = isQsTrue(excludeRows)
19
+
12
20
  const backupIdentifier = `${appName}-export-${new Date().getTime()}.tar.gz`
13
21
  ctx.attachment(backupIdentifier)
14
22
  ctx.body = await sdk.backups.streamExportApp(appId, excludeRows)
@@ -5,7 +5,7 @@ import { permissions } from "@budibase/backend-core"
5
5
 
6
6
  const router: Router = new Router()
7
7
 
8
- router.get(
8
+ router.post(
9
9
  "/api/backups/export",
10
10
  authorized(permissions.BUILDER),
11
11
  controller.exportAppDump
@@ -1,7 +1,9 @@
1
+ import tk from "timekeeper"
1
2
  import * as setup from "./utilities"
2
3
  import { events } from "@budibase/backend-core"
3
4
  import sdk from "../../../sdk"
4
5
  import { checkBuilderEndpoint } from "./utilities/TestFunctions"
6
+ import { mocks } from "@budibase/backend-core/tests"
5
7
 
6
8
  describe("/backups", () => {
7
9
  let request = setup.getRequest()
@@ -16,7 +18,7 @@ describe("/backups", () => {
16
18
  describe("exportAppDump", () => {
17
19
  it("should be able to export app", async () => {
18
20
  const res = await request
19
- .get(`/api/backups/export?appId=${config.getAppId()}&appname=test`)
21
+ .post(`/api/backups/export?appId=${config.getAppId()}`)
20
22
  .set(config.defaultHeaders())
21
23
  .expect(200)
22
24
  expect(res.headers["content-type"]).toEqual("application/gzip")
@@ -26,10 +28,24 @@ describe("/backups", () => {
26
28
  it("should apply authorization to endpoint", async () => {
27
29
  await checkBuilderEndpoint({
28
30
  config,
29
- method: "GET",
31
+ method: "POST",
30
32
  url: `/api/backups/export?appId=${config.getAppId()}`,
31
33
  })
32
34
  })
35
+
36
+ it("should infer the app name from the app", async () => {
37
+ tk.freeze(mocks.date.MOCK_DATE)
38
+
39
+ const res = await request
40
+ .post(`/api/backups/export?appId=${config.getAppId()}`)
41
+ .set(config.defaultHeaders())
42
+
43
+ expect(res.headers["content-disposition"]).toEqual(
44
+ `attachment; filename="${
45
+ config.getApp()!.name
46
+ }-export-${mocks.date.MOCK_DATE.getTime()}.tar.gz"`
47
+ )
48
+ })
33
49
  })
34
50
 
35
51
  describe("calculateBackupStats", () => {