@budibase/server 2.0.30-alpha.14 → 2.0.30-alpha.16
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/builder/assets/backups-default.8c011f1b.png +0 -0
- package/builder/assets/{index.099ad307.js → index.7ebb4fb6.js} +333 -329
- package/builder/assets/{index.acdbfe62.css → index.b15ffe95.css} +1 -1
- package/builder/index.html +2 -2
- package/coverage/clover.xml +254 -313
- package/coverage/coverage-final.json +15 -17
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +74 -62
- package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +17 -32
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +12 -9
- package/coverage/lcov-report/api/controllers/table/external.js.html +10 -10
- package/coverage/lcov-report/api/controllers/table/index.html +16 -16
- package/coverage/lcov-report/api/controllers/table/index.js.html +5 -5
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +3 -3
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +3 -3
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +5 -20
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +1 -1
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +6 -6
- package/coverage/lcov-report/automations/bullboard.js.html +17 -92
- package/coverage/lcov-report/automations/index.html +18 -18
- package/coverage/lcov-report/automations/index.js.html +5 -5
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +5 -5
- package/coverage/lcov-report/constants/index.html +5 -5
- package/coverage/lcov-report/constants/index.js.html +6 -18
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +19 -19
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +35 -308
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +62 -62
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
- package/coverage/lcov-report/middleware/builder.js.html +1 -1
- package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
- package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
- package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +1 -1
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +1 -1
- package/coverage/lcov-report/utilities/plugins.js.html +1 -1
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +52 -52
- package/coverage/lcov-report/utilities/queue/index.html +21 -21
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +2 -2
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +451 -564
- package/dist/api/controllers/application.js +2 -5
- package/dist/api/controllers/backup.js +19 -13
- package/dist/api/controllers/cloud.js +38 -35
- package/dist/api/controllers/deploy/index.js +11 -2
- package/dist/api/controllers/static/index.js +2 -2
- package/dist/api/controllers/table/bulkFormula.js +4 -3
- package/dist/api/controllers/table/external.js +5 -4
- package/dist/api/controllers/table/index.js +4 -4
- package/dist/api/controllers/table/internal.js +2 -1
- package/dist/api/controllers/table/utils.js +4 -48
- package/dist/api/controllers/view/index.js +2 -2
- package/dist/api/routes/backup.js +34 -7
- package/dist/api/routes/index.js +9 -4
- package/dist/app.js +14 -0
- package/dist/automations/automationUtils.js +2 -2
- package/dist/automations/bullboard.js +5 -33
- package/dist/automations/index.js +4 -4
- package/dist/automations/triggers.js +4 -4
- package/dist/automations/utils.js +13 -9
- package/dist/constants/index.js +2 -5
- package/dist/db/utils.js +10 -75
- package/dist/migrations/functions/backfill/app/tables.js +5 -8
- package/dist/package.json +11 -11
- package/dist/sdk/app/backups/constants.js +5 -0
- package/dist/sdk/app/backups/exports.js +172 -0
- package/dist/sdk/app/backups/imports.js +162 -0
- package/dist/sdk/app/backups/index.js +29 -0
- package/dist/sdk/app/backups/statistics.js +73 -0
- package/dist/sdk/app/tables/index.js +61 -0
- package/dist/sdk/index.js +15 -0
- package/dist/tests/utilities/TestConfiguration.js +4 -2
- package/dist/threads/automation.js +12 -17
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/index.js +3 -95
- package/dist/utilities/fileSystem/utilities.js +2 -1
- package/package.json +12 -12
- package/src/api/controllers/application.ts +3 -10
- package/src/api/controllers/{backup.js → backup.ts} +7 -7
- package/src/api/controllers/cloud.js +44 -40
- package/src/api/controllers/deploy/index.ts +20 -7
- package/src/api/controllers/static/index.ts +2 -2
- package/src/api/controllers/table/bulkFormula.js +4 -3
- package/src/api/controllers/table/external.js +4 -4
- package/src/api/controllers/table/index.js +4 -4
- package/src/api/controllers/table/internal.ts +3 -7
- package/src/api/controllers/table/utils.ts +1 -52
- package/src/api/controllers/view/index.js +2 -2
- package/src/api/routes/backup.ts +10 -0
- package/src/api/routes/index.ts +11 -5
- package/src/api/routes/tests/backup.spec.js +1 -1
- package/src/api/routes/tests/{deployment.spec.js → deployment.spec.ts} +4 -4
- package/src/app.ts +15 -0
- package/src/automations/automationUtils.js +2 -2
- package/src/automations/bullboard.js +8 -33
- package/src/automations/index.js +4 -4
- package/src/automations/triggers.js +4 -4
- package/src/automations/utils.ts +12 -8
- package/src/constants/index.js +2 -6
- package/src/db/utils.js +17 -108
- package/src/definitions/automations.ts +0 -12
- package/src/migrations/functions/backfill/app/tables.ts +6 -13
- package/src/sdk/app/backups/constants.ts +2 -0
- package/src/sdk/app/backups/exports.ts +171 -0
- package/src/sdk/app/backups/imports.ts +168 -0
- package/src/sdk/app/backups/index.ts +9 -0
- package/src/sdk/app/backups/statistics.ts +77 -0
- package/src/sdk/app/tables/index.ts +60 -0
- package/src/sdk/index.ts +13 -0
- package/src/tests/utilities/TestConfiguration.js +5 -2
- package/src/threads/automation.ts +20 -27
- package/src/utilities/fileSystem/index.js +2 -119
- package/src/utilities/fileSystem/utilities.js +2 -0
- package/coverage/lcov-report/api/controllers/backup.js.html +0 -142
- package/coverage/lcov-report/api/routes/backup.js.html +0 -115
- package/dist/automations/listeners.js +0 -102
- package/src/api/routes/backup.js +0 -10
- package/src/automations/listeners.ts +0 -78
|
@@ -2,17 +2,11 @@ const { budibaseTempDir } = require("../budibaseDir")
|
|
|
2
2
|
const fs = require("fs")
|
|
3
3
|
const { join } = require("path")
|
|
4
4
|
const uuid = require("uuid/v4")
|
|
5
|
-
const {
|
|
6
|
-
doWithDB,
|
|
7
|
-
dangerousGetDB,
|
|
8
|
-
closeDB,
|
|
9
|
-
} = require("@budibase/backend-core/db")
|
|
10
5
|
const { ObjectStoreBuckets } = require("../../constants")
|
|
11
6
|
const {
|
|
12
7
|
upload,
|
|
13
8
|
retrieve,
|
|
14
9
|
retrieveToTmp,
|
|
15
|
-
streamUpload,
|
|
16
10
|
deleteFolder,
|
|
17
11
|
downloadTarball,
|
|
18
12
|
downloadTarballDirect,
|
|
@@ -21,12 +15,6 @@ const {
|
|
|
21
15
|
const { updateClientLibrary } = require("./clientLibrary")
|
|
22
16
|
const { checkSlashesInUrl } = require("../")
|
|
23
17
|
const env = require("../../environment")
|
|
24
|
-
const {
|
|
25
|
-
USER_METDATA_PREFIX,
|
|
26
|
-
LINK_USER_METADATA_PREFIX,
|
|
27
|
-
TABLE_ROW_PREFIX,
|
|
28
|
-
} = require("../../db/utils")
|
|
29
|
-
const MemoryStream = require("memorystream")
|
|
30
18
|
const { getAppId } = require("@budibase/backend-core/context")
|
|
31
19
|
const tar = require("tar")
|
|
32
20
|
const fetch = require("node-fetch")
|
|
@@ -86,21 +74,6 @@ exports.checkDevelopmentEnvironment = () => {
|
|
|
86
74
|
}
|
|
87
75
|
}
|
|
88
76
|
|
|
89
|
-
/**
|
|
90
|
-
* This function manages temporary template files which are stored by Koa.
|
|
91
|
-
* @param {Object} template The template object retrieved from the Koa context object.
|
|
92
|
-
* @returns {Object} Returns an fs read stream which can be loaded into the database.
|
|
93
|
-
*/
|
|
94
|
-
exports.getTemplateStream = async template => {
|
|
95
|
-
if (template.file) {
|
|
96
|
-
return fs.createReadStream(template.file.path)
|
|
97
|
-
} else {
|
|
98
|
-
const [type, name] = template.key.split("/")
|
|
99
|
-
const tmpPath = await exports.downloadTemplate(type, name)
|
|
100
|
-
return fs.createReadStream(join(tmpPath, name, "db", "dump.txt"))
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
77
|
/**
|
|
105
78
|
* Used to retrieve a handlebars file from the system which will be used as a template.
|
|
106
79
|
* This is allowable as the template handlebars files should be static and identical across
|
|
@@ -124,98 +97,8 @@ exports.apiFileReturn = contents => {
|
|
|
124
97
|
return fs.createReadStream(path)
|
|
125
98
|
}
|
|
126
99
|
|
|
127
|
-
exports.
|
|
128
|
-
|
|
129
|
-
if (excludeRows) {
|
|
130
|
-
ids.push(TABLE_ROW_PREFIX)
|
|
131
|
-
}
|
|
132
|
-
return doc =>
|
|
133
|
-
!ids.map(key => doc._id.includes(key)).reduce((prev, curr) => prev || curr)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Local utility to back up the database state for an app, excluding global user
|
|
138
|
-
* data or user relationships.
|
|
139
|
-
* @param {string} appId The app to backup
|
|
140
|
-
* @param {object} config Config to send to export DB
|
|
141
|
-
* @param {boolean} excludeRows Flag to state whether the export should include data.
|
|
142
|
-
* @returns {*} either a string or a stream of the backup
|
|
143
|
-
*/
|
|
144
|
-
const backupAppData = async (appId, config, excludeRows) => {
|
|
145
|
-
return await exports.exportDB(appId, {
|
|
146
|
-
...config,
|
|
147
|
-
filter: exports.defineFilter(excludeRows),
|
|
148
|
-
})
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Takes a copy of the database state for an app to the object store.
|
|
153
|
-
* @param {string} appId The ID of the app which is to be backed up.
|
|
154
|
-
* @param {string} backupName The name of the backup located in the object store.
|
|
155
|
-
* @return {*} a readable stream to the completed backup file
|
|
156
|
-
*/
|
|
157
|
-
exports.performBackup = async (appId, backupName) => {
|
|
158
|
-
return await backupAppData(appId, { exportName: backupName })
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Streams a backup of the database state for an app
|
|
163
|
-
* @param {string} appId The ID of the app which is to be backed up.
|
|
164
|
-
* @param {boolean} excludeRows Flag to state whether the export should include data.
|
|
165
|
-
* @returns {*} a readable stream of the backup which is written in real time
|
|
166
|
-
*/
|
|
167
|
-
exports.streamBackup = async (appId, excludeRows) => {
|
|
168
|
-
return await backupAppData(appId, { stream: true }, excludeRows)
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Exports a DB to either file or a variable (memory).
|
|
173
|
-
* @param {string} dbName the DB which is to be exported.
|
|
174
|
-
* @param {string} exportName optional - provide a filename to write the backup to a file
|
|
175
|
-
* @param {boolean} stream optional - whether to perform a full backup
|
|
176
|
-
* @param {function} filter optional - a filter function to clear out any un-wanted docs.
|
|
177
|
-
* @return {*} either a readable stream or a string
|
|
178
|
-
*/
|
|
179
|
-
exports.exportDB = async (dbName, { stream, filter, exportName } = {}) => {
|
|
180
|
-
// streaming a DB dump is a bit more complicated, can't close DB
|
|
181
|
-
if (stream) {
|
|
182
|
-
const db = dangerousGetDB(dbName)
|
|
183
|
-
const memStream = new MemoryStream()
|
|
184
|
-
memStream.on("end", async () => {
|
|
185
|
-
await closeDB(db)
|
|
186
|
-
})
|
|
187
|
-
db.dump(memStream, { filter })
|
|
188
|
-
return memStream
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return doWithDB(dbName, async db => {
|
|
192
|
-
// Write the dump to file if required
|
|
193
|
-
if (exportName) {
|
|
194
|
-
const path = join(budibaseTempDir(), exportName)
|
|
195
|
-
const writeStream = fs.createWriteStream(path)
|
|
196
|
-
await db.dump(writeStream, { filter })
|
|
197
|
-
|
|
198
|
-
// Upload the dump to the object store if self hosted
|
|
199
|
-
if (env.SELF_HOSTED) {
|
|
200
|
-
await streamUpload(
|
|
201
|
-
ObjectStoreBuckets.BACKUPS,
|
|
202
|
-
join(dbName, exportName),
|
|
203
|
-
fs.createReadStream(path)
|
|
204
|
-
)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return fs.createReadStream(path)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Stringify the dump in memory if required
|
|
211
|
-
const memStream = new MemoryStream()
|
|
212
|
-
let appString = ""
|
|
213
|
-
memStream.on("data", chunk => {
|
|
214
|
-
appString += chunk.toString()
|
|
215
|
-
})
|
|
216
|
-
await db.dump(memStream, { filter })
|
|
217
|
-
return appString
|
|
218
|
-
})
|
|
100
|
+
exports.streamFile = path => {
|
|
101
|
+
return fs.createReadStream(path)
|
|
219
102
|
}
|
|
220
103
|
|
|
221
104
|
/**
|
|
@@ -6,6 +6,7 @@ const {
|
|
|
6
6
|
streamUpload,
|
|
7
7
|
retrieve,
|
|
8
8
|
retrieveToTmp,
|
|
9
|
+
retrieveDirectory,
|
|
9
10
|
deleteFolder,
|
|
10
11
|
uploadDirectory,
|
|
11
12
|
downloadTarball,
|
|
@@ -27,6 +28,7 @@ exports.upload = upload
|
|
|
27
28
|
exports.streamUpload = streamUpload
|
|
28
29
|
exports.retrieve = retrieve
|
|
29
30
|
exports.retrieveToTmp = retrieveToTmp
|
|
31
|
+
exports.retrieveDirectory = retrieveDirectory
|
|
30
32
|
exports.deleteFolder = deleteFolder
|
|
31
33
|
exports.uploadDirectory = uploadDirectory
|
|
32
34
|
exports.downloadTarball = downloadTarball
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for api/controllers/backup.js</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">api/controllers</a> backup.js</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">100% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>15/15</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">100% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>0/0</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>2/2</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">100% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>15/15</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line high'></div>
|
|
65
|
-
<pre><table class="coverage">
|
|
66
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
75
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
76
|
-
<a name='L11'></a><a href='#L11'>11</a>
|
|
77
|
-
<a name='L12'></a><a href='#L12'>12</a>
|
|
78
|
-
<a name='L13'></a><a href='#L13'>13</a>
|
|
79
|
-
<a name='L14'></a><a href='#L14'>14</a>
|
|
80
|
-
<a name='L15'></a><a href='#L15'>15</a>
|
|
81
|
-
<a name='L16'></a><a href='#L16'>16</a>
|
|
82
|
-
<a name='L17'></a><a href='#L17'>17</a>
|
|
83
|
-
<a name='L18'></a><a href='#L18'>18</a>
|
|
84
|
-
<a name='L19'></a><a href='#L19'>19</a>
|
|
85
|
-
<a name='L20'></a><a href='#L20'>20</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">28x</span>
|
|
86
|
-
<span class="cline-any cline-yes">28x</span>
|
|
87
|
-
<span class="cline-any cline-yes">28x</span>
|
|
88
|
-
<span class="cline-any cline-yes">28x</span>
|
|
89
|
-
<span class="cline-any cline-neutral"> </span>
|
|
90
|
-
<span class="cline-any cline-yes">28x</span>
|
|
91
|
-
<span class="cline-any cline-yes">1x</span>
|
|
92
|
-
<span class="cline-any cline-yes">1x</span>
|
|
93
|
-
<span class="cline-any cline-yes">1x</span>
|
|
94
|
-
<span class="cline-any cline-yes">1x</span>
|
|
95
|
-
<span class="cline-any cline-yes">1x</span>
|
|
96
|
-
<span class="cline-any cline-yes">1x</span>
|
|
97
|
-
<span class="cline-any cline-neutral"> </span>
|
|
98
|
-
<span class="cline-any cline-yes">1x</span>
|
|
99
|
-
<span class="cline-any cline-yes">1x</span>
|
|
100
|
-
<span class="cline-any cline-yes">1x</span>
|
|
101
|
-
<span class="cline-any cline-yes">1x</span>
|
|
102
|
-
<span class="cline-any cline-neutral"> </span>
|
|
103
|
-
<span class="cline-any cline-neutral"> </span>
|
|
104
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">const { streamBackup } = require("../../utilities/fileSystem")
|
|
105
|
-
const { events, context } = require("@budibase/backend-core")
|
|
106
|
-
const { DocumentType } = require("../../db/utils")
|
|
107
|
-
const { isQsTrue } = require("../../utilities")
|
|
108
|
-
|
|
109
|
-
exports.exportAppDump = async function (ctx) {
|
|
110
|
-
let { appId, excludeRows } = ctx.query
|
|
111
|
-
const appName = decodeURI(ctx.query.appname)
|
|
112
|
-
excludeRows = isQsTrue(excludeRows)
|
|
113
|
-
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
|
|
114
|
-
ctx.attachment(backupIdentifier)
|
|
115
|
-
ctx.body = await streamBackup(appId, excludeRows)
|
|
116
|
-
|
|
117
|
-
await context.doInAppContext(appId, async () => {
|
|
118
|
-
const appDb = context.getAppDB()
|
|
119
|
-
const app = await appDb.get(DocumentType.APP_METADATA)
|
|
120
|
-
await events.app.exported(app)
|
|
121
|
-
})
|
|
122
|
-
}
|
|
123
|
-
</pre></td></tr></table></pre>
|
|
124
|
-
|
|
125
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
126
|
-
</div><!-- /wrapper -->
|
|
127
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
128
|
-
Code coverage generated by
|
|
129
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
130
|
-
at Mon Oct 24 2022 16:18:22 GMT+0000 (Coordinated Universal Time)
|
|
131
|
-
</div>
|
|
132
|
-
<script src="../../prettify.js"></script>
|
|
133
|
-
<script>
|
|
134
|
-
window.onload = function () {
|
|
135
|
-
prettyPrint();
|
|
136
|
-
};
|
|
137
|
-
</script>
|
|
138
|
-
<script src="../../sorter.js"></script>
|
|
139
|
-
<script src="../../block-navigation.js"></script>
|
|
140
|
-
</body>
|
|
141
|
-
</html>
|
|
142
|
-
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
|
|
5
|
-
<head>
|
|
6
|
-
<title>Code coverage report for api/routes/backup.js</title>
|
|
7
|
-
<meta charset="utf-8" />
|
|
8
|
-
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
|
-
<link rel="stylesheet" href="../../base.css" />
|
|
10
|
-
<link rel="shortcut icon" type="image/x-icon" href="../../favicon.png" />
|
|
11
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
12
|
-
<style type='text/css'>
|
|
13
|
-
.coverage-summary .sorter {
|
|
14
|
-
background-image: url(../../sort-arrow-sprite.png);
|
|
15
|
-
}
|
|
16
|
-
</style>
|
|
17
|
-
</head>
|
|
18
|
-
|
|
19
|
-
<body>
|
|
20
|
-
<div class='wrapper'>
|
|
21
|
-
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">api/routes</a> backup.js</h1>
|
|
23
|
-
<div class='clearfix'>
|
|
24
|
-
|
|
25
|
-
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">100% </span>
|
|
27
|
-
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>7/7</span>
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">100% </span>
|
|
34
|
-
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>0/0</span>
|
|
36
|
-
</div>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<div class='fl pad1y space-right2'>
|
|
40
|
-
<span class="strong">100% </span>
|
|
41
|
-
<span class="quiet">Functions</span>
|
|
42
|
-
<span class='fraction'>0/0</span>
|
|
43
|
-
</div>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">100% </span>
|
|
48
|
-
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>7/7</span>
|
|
50
|
-
</div>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</div>
|
|
54
|
-
<p class="quiet">
|
|
55
|
-
Press <em>n</em> or <em>j</em> to go to the next uncovered block, <em>b</em>, <em>p</em> or <em>k</em> for the previous block.
|
|
56
|
-
</p>
|
|
57
|
-
<template id="filterTemplate">
|
|
58
|
-
<div class="quiet">
|
|
59
|
-
Filter:
|
|
60
|
-
<input oninput="onInput()" type="search" id="fileSearch">
|
|
61
|
-
</div>
|
|
62
|
-
</template>
|
|
63
|
-
</div>
|
|
64
|
-
<div class='status-line high'></div>
|
|
65
|
-
<pre><table class="coverage">
|
|
66
|
-
<tr><td class="line-count quiet"><a name='L1'></a><a href='#L1'>1</a>
|
|
67
|
-
<a name='L2'></a><a href='#L2'>2</a>
|
|
68
|
-
<a name='L3'></a><a href='#L3'>3</a>
|
|
69
|
-
<a name='L4'></a><a href='#L4'>4</a>
|
|
70
|
-
<a name='L5'></a><a href='#L5'>5</a>
|
|
71
|
-
<a name='L6'></a><a href='#L6'>6</a>
|
|
72
|
-
<a name='L7'></a><a href='#L7'>7</a>
|
|
73
|
-
<a name='L8'></a><a href='#L8'>8</a>
|
|
74
|
-
<a name='L9'></a><a href='#L9'>9</a>
|
|
75
|
-
<a name='L10'></a><a href='#L10'>10</a>
|
|
76
|
-
<a name='L11'></a><a href='#L11'>11</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">28x</span>
|
|
77
|
-
<span class="cline-any cline-yes">28x</span>
|
|
78
|
-
<span class="cline-any cline-yes">28x</span>
|
|
79
|
-
<span class="cline-any cline-yes">28x</span>
|
|
80
|
-
<span class="cline-any cline-neutral"> </span>
|
|
81
|
-
<span class="cline-any cline-yes">28x</span>
|
|
82
|
-
<span class="cline-any cline-neutral"> </span>
|
|
83
|
-
<span class="cline-any cline-yes">28x</span>
|
|
84
|
-
<span class="cline-any cline-neutral"> </span>
|
|
85
|
-
<span class="cline-any cline-yes">28x</span>
|
|
86
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">const Router = require("@koa/router")
|
|
87
|
-
const controller = require("../controllers/backup")
|
|
88
|
-
const authorized = require("../../middleware/authorized")
|
|
89
|
-
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
90
|
-
|
|
91
|
-
const router = new Router()
|
|
92
|
-
|
|
93
|
-
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
|
|
94
|
-
|
|
95
|
-
module.exports = router
|
|
96
|
-
</pre></td></tr></table></pre>
|
|
97
|
-
|
|
98
|
-
<div class='push'></div><!-- for sticky footer -->
|
|
99
|
-
</div><!-- /wrapper -->
|
|
100
|
-
<div class='footer quiet pad2 space-top1 center small'>
|
|
101
|
-
Code coverage generated by
|
|
102
|
-
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
103
|
-
at Mon Oct 24 2022 16:18:22 GMT+0000 (Coordinated Universal Time)
|
|
104
|
-
</div>
|
|
105
|
-
<script src="../../prettify.js"></script>
|
|
106
|
-
<script>
|
|
107
|
-
window.onload = function () {
|
|
108
|
-
prettyPrint();
|
|
109
|
-
};
|
|
110
|
-
</script>
|
|
111
|
-
<script src="../../sorter.js"></script>
|
|
112
|
-
<script src="../../block-navigation.js"></script>
|
|
113
|
-
</body>
|
|
114
|
-
</html>
|
|
115
|
-
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.addListeners = void 0;
|
|
36
|
-
const automation = __importStar(require("../threads/automation"));
|
|
37
|
-
const addListeners = (queue) => {
|
|
38
|
-
logging(queue);
|
|
39
|
-
handleStalled(queue);
|
|
40
|
-
};
|
|
41
|
-
exports.addListeners = addListeners;
|
|
42
|
-
const handleStalled = (queue) => {
|
|
43
|
-
queue.on("stalled", (job) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
-
yield automation.removeStalled(job);
|
|
45
|
-
}));
|
|
46
|
-
};
|
|
47
|
-
const logging = (queue) => {
|
|
48
|
-
var _a;
|
|
49
|
-
if ((_a = process.env.NODE_DEBUG) === null || _a === void 0 ? void 0 : _a.includes("bull")) {
|
|
50
|
-
queue
|
|
51
|
-
.on("error", (error) => {
|
|
52
|
-
// An error occurred.
|
|
53
|
-
console.error(`automation-event=error error=${JSON.stringify(error)}`);
|
|
54
|
-
})
|
|
55
|
-
.on("waiting", (jobId) => {
|
|
56
|
-
// A Job is waiting to be processed as soon as a worker is idling.
|
|
57
|
-
console.log(`automation-event=waiting jobId=${jobId}`);
|
|
58
|
-
})
|
|
59
|
-
.on("active", (job, jobPromise) => {
|
|
60
|
-
// A job has started. You can use `jobPromise.cancel()`` to abort it.
|
|
61
|
-
console.log(`automation-event=active jobId=${job.id}`);
|
|
62
|
-
})
|
|
63
|
-
.on("stalled", (job) => {
|
|
64
|
-
// A job has been marked as stalled. This is useful for debugging job
|
|
65
|
-
// workers that crash or pause the event loop.
|
|
66
|
-
console.error(`automation-event=stalled jobId=${job.id} job=${JSON.stringify(job)}`);
|
|
67
|
-
})
|
|
68
|
-
.on("progress", (job, progress) => {
|
|
69
|
-
// A job's progress was updated!
|
|
70
|
-
console.log(`automation-event=progress jobId=${job.id} progress=${progress}`);
|
|
71
|
-
})
|
|
72
|
-
.on("completed", (job, result) => {
|
|
73
|
-
// A job successfully completed with a `result`.
|
|
74
|
-
console.log(`automation-event=completed jobId=${job.id} result=${result}`);
|
|
75
|
-
})
|
|
76
|
-
.on("failed", (job, err) => {
|
|
77
|
-
// A job failed with reason `err`!
|
|
78
|
-
console.log(`automation-event=failed jobId=${job.id} error=${err}`);
|
|
79
|
-
})
|
|
80
|
-
.on("paused", () => {
|
|
81
|
-
// The queue has been paused.
|
|
82
|
-
console.log(`automation-event=paused`);
|
|
83
|
-
})
|
|
84
|
-
.on("resumed", (job) => {
|
|
85
|
-
// The queue has been resumed.
|
|
86
|
-
console.log(`automation-event=paused jobId=${job.id}`);
|
|
87
|
-
})
|
|
88
|
-
.on("cleaned", (jobs, type) => {
|
|
89
|
-
// Old jobs have been cleaned from the queue. `jobs` is an array of cleaned
|
|
90
|
-
// jobs, and `type` is the type of jobs cleaned.
|
|
91
|
-
console.log(`automation-event=cleaned length=${jobs.length} type=${type}`);
|
|
92
|
-
})
|
|
93
|
-
.on("drained", () => {
|
|
94
|
-
// Emitted every time the queue has processed all the waiting jobs (even if there can be some delayed jobs not yet processed)
|
|
95
|
-
console.log(`automation-event=drained`);
|
|
96
|
-
})
|
|
97
|
-
.on("removed", (job) => {
|
|
98
|
-
// A job successfully removed.
|
|
99
|
-
console.log(`automation-event=removed jobId=${job.id}`);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
};
|
package/src/api/routes/backup.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const Router = require("@koa/router")
|
|
2
|
-
const controller = require("../controllers/backup")
|
|
3
|
-
const authorized = require("../../middleware/authorized")
|
|
4
|
-
const { BUILDER } = require("@budibase/backend-core/permissions")
|
|
5
|
-
|
|
6
|
-
const router = new Router()
|
|
7
|
-
|
|
8
|
-
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump)
|
|
9
|
-
|
|
10
|
-
module.exports = router
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { Queue, Job, JobId } from "bull"
|
|
2
|
-
import { AutomationEvent } from "../definitions/automations"
|
|
3
|
-
import * as automation from "../threads/automation"
|
|
4
|
-
|
|
5
|
-
export const addListeners = (queue: Queue) => {
|
|
6
|
-
logging(queue)
|
|
7
|
-
handleStalled(queue)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const handleStalled = (queue: Queue) => {
|
|
11
|
-
queue.on("stalled", async (job: Job) => {
|
|
12
|
-
await automation.removeStalled(job as AutomationEvent)
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const logging = (queue: Queue) => {
|
|
17
|
-
if (process.env.NODE_DEBUG?.includes("bull")) {
|
|
18
|
-
queue
|
|
19
|
-
.on("error", (error: any) => {
|
|
20
|
-
// An error occurred.
|
|
21
|
-
console.error(`automation-event=error error=${JSON.stringify(error)}`)
|
|
22
|
-
})
|
|
23
|
-
.on("waiting", (jobId: JobId) => {
|
|
24
|
-
// A Job is waiting to be processed as soon as a worker is idling.
|
|
25
|
-
console.log(`automation-event=waiting jobId=${jobId}`)
|
|
26
|
-
})
|
|
27
|
-
.on("active", (job: Job, jobPromise: any) => {
|
|
28
|
-
// A job has started. You can use `jobPromise.cancel()`` to abort it.
|
|
29
|
-
console.log(`automation-event=active jobId=${job.id}`)
|
|
30
|
-
})
|
|
31
|
-
.on("stalled", (job: Job) => {
|
|
32
|
-
// A job has been marked as stalled. This is useful for debugging job
|
|
33
|
-
// workers that crash or pause the event loop.
|
|
34
|
-
console.error(
|
|
35
|
-
`automation-event=stalled jobId=${job.id} job=${JSON.stringify(job)}`
|
|
36
|
-
)
|
|
37
|
-
})
|
|
38
|
-
.on("progress", (job: Job, progress: any) => {
|
|
39
|
-
// A job's progress was updated!
|
|
40
|
-
console.log(
|
|
41
|
-
`automation-event=progress jobId=${job.id} progress=${progress}`
|
|
42
|
-
)
|
|
43
|
-
})
|
|
44
|
-
.on("completed", (job: Job, result) => {
|
|
45
|
-
// A job successfully completed with a `result`.
|
|
46
|
-
console.log(
|
|
47
|
-
`automation-event=completed jobId=${job.id} result=${result}`
|
|
48
|
-
)
|
|
49
|
-
})
|
|
50
|
-
.on("failed", (job, err: any) => {
|
|
51
|
-
// A job failed with reason `err`!
|
|
52
|
-
console.log(`automation-event=failed jobId=${job.id} error=${err}`)
|
|
53
|
-
})
|
|
54
|
-
.on("paused", () => {
|
|
55
|
-
// The queue has been paused.
|
|
56
|
-
console.log(`automation-event=paused`)
|
|
57
|
-
})
|
|
58
|
-
.on("resumed", (job: Job) => {
|
|
59
|
-
// The queue has been resumed.
|
|
60
|
-
console.log(`automation-event=paused jobId=${job.id}`)
|
|
61
|
-
})
|
|
62
|
-
.on("cleaned", (jobs: Job[], type: string) => {
|
|
63
|
-
// Old jobs have been cleaned from the queue. `jobs` is an array of cleaned
|
|
64
|
-
// jobs, and `type` is the type of jobs cleaned.
|
|
65
|
-
console.log(
|
|
66
|
-
`automation-event=cleaned length=${jobs.length} type=${type}`
|
|
67
|
-
)
|
|
68
|
-
})
|
|
69
|
-
.on("drained", () => {
|
|
70
|
-
// Emitted every time the queue has processed all the waiting jobs (even if there can be some delayed jobs not yet processed)
|
|
71
|
-
console.log(`automation-event=drained`)
|
|
72
|
-
})
|
|
73
|
-
.on("removed", (job: Job) => {
|
|
74
|
-
// A job successfully removed.
|
|
75
|
-
console.log(`automation-event=removed jobId=${job.id}`)
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|