@budibase/server 2.5.6-alpha.38 → 2.5.6-alpha.39

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.5.6-alpha.38",
4
+ "version": "2.5.6-alpha.39",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -45,12 +45,12 @@
45
45
  "license": "GPL-3.0",
46
46
  "dependencies": {
47
47
  "@apidevtools/swagger-parser": "10.0.3",
48
- "@budibase/backend-core": "2.5.6-alpha.38",
49
- "@budibase/client": "2.5.6-alpha.38",
50
- "@budibase/pro": "2.5.6-alpha.37",
51
- "@budibase/shared-core": "2.5.6-alpha.38",
52
- "@budibase/string-templates": "2.5.6-alpha.38",
53
- "@budibase/types": "2.5.6-alpha.38",
48
+ "@budibase/backend-core": "2.5.6-alpha.39",
49
+ "@budibase/client": "2.5.6-alpha.39",
50
+ "@budibase/pro": "2.5.6-alpha.38",
51
+ "@budibase/shared-core": "2.5.6-alpha.39",
52
+ "@budibase/string-templates": "2.5.6-alpha.39",
53
+ "@budibase/types": "2.5.6-alpha.39",
54
54
  "@bull-board/api": "3.7.0",
55
55
  "@bull-board/koa": "3.9.4",
56
56
  "@elastic/elasticsearch": "7.10.0",
@@ -176,5 +176,5 @@
176
176
  "optionalDependencies": {
177
177
  "oracledb": "5.3.0"
178
178
  },
179
- "gitHead": "03695de7840c264f3513663a31c27c05b23b888c"
179
+ "gitHead": "6cc5660f1c6af529fb735084d37a5e0a4a68aa4c"
180
180
  }
package/src/db/utils.ts CHANGED
@@ -27,6 +27,7 @@ export const isProdAppID = dbCore.isProdAppID
27
27
  export const USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${dbCore.InternalTable.USER_METADATA}${SEPARATOR}`
28
28
  export const LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${dbCore.InternalTable.USER_METADATA}${SEPARATOR}`
29
29
  export const TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}`
30
+ export const AUTOMATION_LOG_PREFIX = `${DocumentType.AUTOMATION_LOG}${SEPARATOR}`
30
31
  export const ViewName = dbCore.ViewName
31
32
  export const InternalTables = dbCore.InternalTable
32
33
  export const UNICODE_MAX = dbCore.UNICODE_MAX
@@ -3,6 +3,7 @@ import { budibaseTempDir } from "../../../utilities/budibaseDir"
3
3
  import { streamFile, createTempFolder } from "../../../utilities/fileSystem"
4
4
  import { ObjectStoreBuckets } from "../../../constants"
5
5
  import {
6
+ AUTOMATION_LOG_PREFIX,
6
7
  LINK_USER_METADATA_PREFIX,
7
8
  TABLE_ROW_PREFIX,
8
9
  USER_METDATA_PREFIX,
@@ -20,11 +21,15 @@ const uuid = require("uuid/v4")
20
21
  const tar = require("tar")
21
22
  const MemoryStream = require("memorystream")
22
23
 
23
- type ExportOpts = {
24
+ interface DBDumpOpts {
24
25
  filter?: any
25
26
  exportPath?: string
27
+ }
28
+
29
+ interface ExportOpts extends DBDumpOpts {
26
30
  tar?: boolean
27
31
  excludeRows?: boolean
32
+ excludeLogs?: boolean
28
33
  }
29
34
 
30
35
  function tarFilesToTmp(tmpDir: string, files: string[]) {
@@ -49,7 +54,7 @@ function tarFilesToTmp(tmpDir: string, files: string[]) {
49
54
  * a filter function or the name of the export.
50
55
  * @return {*} either a readable stream or a string
51
56
  */
52
- export async function exportDB(dbName: string, opts: ExportOpts = {}) {
57
+ export async function exportDB(dbName: string, opts: DBDumpOpts = {}) {
53
58
  const exportOpts = {
54
59
  filter: opts?.filter,
55
60
  batch_size: 1000,
@@ -76,11 +81,14 @@ export async function exportDB(dbName: string, opts: ExportOpts = {}) {
76
81
  })
77
82
  }
78
83
 
79
- function defineFilter(excludeRows?: boolean) {
84
+ function defineFilter(excludeRows?: boolean, excludeLogs?: boolean) {
80
85
  const ids = [USER_METDATA_PREFIX, LINK_USER_METADATA_PREFIX]
81
86
  if (excludeRows) {
82
87
  ids.push(TABLE_ROW_PREFIX)
83
88
  }
89
+ if (excludeLogs) {
90
+ ids.push(AUTOMATION_LOG_PREFIX)
91
+ }
84
92
  return (doc: any) =>
85
93
  !ids.map(key => doc._id.includes(key)).reduce((prev, curr) => prev || curr)
86
94
  }
@@ -130,8 +138,7 @@ export async function exportApp(appId: string, config?: ExportOpts) {
130
138
  // enforce an export of app DB to the tmp path
131
139
  const dbPath = join(tmpPath, DB_EXPORT_FILE)
132
140
  await exportDB(appId, {
133
- ...config,
134
- filter: defineFilter(config?.excludeRows),
141
+ filter: defineFilter(config?.excludeRows, config?.excludeLogs),
135
142
  exportPath: dbPath,
136
143
  })
137
144
  // if tar requested, return where the tarball is
@@ -155,6 +162,10 @@ export async function exportApp(appId: string, config?: ExportOpts) {
155
162
  * @returns {*} a readable stream of the backup which is written in real time
156
163
  */
157
164
  export async function streamExportApp(appId: string, excludeRows: boolean) {
158
- const tmpPath = await exportApp(appId, { excludeRows, tar: true })
165
+ const tmpPath = await exportApp(appId, {
166
+ excludeRows,
167
+ excludeLogs: true,
168
+ tar: true,
169
+ })
159
170
  return streamFile(tmpPath)
160
171
  }