@jsreport/jsreport-core 3.0.1 → 3.1.2-test.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/LICENSE +166 -166
- package/README.md +298 -284
- package/index.js +29 -27
- package/lib/main/blobStorage/blobStorage.js +52 -47
- package/lib/main/blobStorage/inMemoryProvider.js +27 -27
- package/lib/main/blobStorage/mainActions.js +24 -24
- package/lib/main/createDefaultLoggerFormat.js +17 -17
- package/lib/main/defaults.js +14 -14
- package/lib/main/extensions/discover.js +20 -20
- package/lib/main/extensions/extensionsManager.js +264 -265
- package/lib/main/extensions/fileUtils.js +56 -55
- package/lib/main/extensions/findVersion.js +49 -53
- package/lib/main/extensions/locationCache.js +103 -97
- package/lib/main/extensions/sorter.js +10 -10
- package/lib/main/extensions/validateMinimalVersion.js +50 -50
- package/lib/main/folders/cascadeFolderRemove.js +25 -25
- package/lib/main/folders/getEntitiesInFolder.js +53 -53
- package/lib/main/folders/index.js +42 -42
- package/lib/main/folders/moveBetweenFolders.js +354 -354
- package/lib/main/folders/validateDuplicatedName.js +107 -107
- package/lib/main/folders/validateReservedName.js +53 -53
- package/lib/main/logger.js +244 -244
- package/lib/main/migration/resourcesToAssets.js +230 -210
- package/lib/main/migration/xlsxTemplatesToAssets.js +128 -118
- package/lib/main/monitoring.js +91 -91
- package/lib/main/optionsLoad.js +237 -237
- package/lib/main/optionsSchema.js +237 -237
- package/lib/main/reporter.js +579 -578
- package/lib/main/schemaValidator.js +252 -252
- package/lib/main/settings.js +154 -154
- package/lib/main/store/checkDuplicatedId.js +27 -27
- package/lib/main/store/collection.js +329 -329
- package/lib/main/store/documentStore.js +469 -469
- package/lib/main/store/mainActions.js +28 -28
- package/lib/main/store/memoryStoreProvider.js +99 -99
- package/lib/main/store/queue.js +48 -48
- package/lib/main/store/referenceUtils.js +251 -251
- package/lib/main/store/setupValidateId.js +43 -43
- package/lib/main/store/setupValidateShortid.js +71 -71
- package/lib/main/store/transaction.js +69 -69
- package/lib/main/store/typeUtils.js +180 -180
- package/lib/main/templates.js +34 -34
- package/lib/main/validateEntityName.js +62 -62
- package/lib/shared/createError.js +36 -36
- package/lib/shared/encryption.js +114 -114
- package/lib/shared/folders/index.js +11 -11
- package/lib/shared/folders/normalizeEntityPath.js +15 -15
- package/lib/shared/folders/resolveEntityFromPath.js +88 -88
- package/lib/shared/folders/resolveEntityPath.js +46 -46
- package/lib/shared/folders/resolveFolderFromPath.js +38 -38
- package/lib/shared/generateRequestId.js +4 -4
- package/lib/shared/listenerCollection.js +169 -0
- package/lib/shared/normalizeMetaFromLogs.js +30 -30
- package/lib/shared/reporter.js +123 -123
- package/lib/shared/request.js +64 -64
- package/lib/shared/tempFilesHandler.js +81 -81
- package/lib/shared/templates.js +82 -82
- package/lib/static/helpers.js +33 -33
- package/lib/worker/blobStorage.js +34 -34
- package/lib/worker/defaultProxyExtend.js +46 -46
- package/lib/worker/documentStore.js +49 -49
- package/lib/worker/extensionsManager.js +17 -17
- package/lib/worker/logger.js +48 -48
- package/lib/worker/render/diff.js +138 -138
- package/lib/worker/render/executeEngine.js +207 -200
- package/lib/worker/render/htmlRecipe.js +10 -10
- package/lib/worker/render/moduleHelper.js +43 -43
- package/lib/worker/render/noneEngine.js +12 -12
- package/lib/worker/render/profiler.js +158 -158
- package/lib/worker/render/render.js +205 -209
- package/lib/worker/render/resolveReferences.js +60 -60
- package/lib/worker/reporter.js +191 -187
- package/lib/worker/sandbox/runInSandbox.js +13 -4
- package/lib/worker/sandbox/safeSandbox.js +828 -822
- package/lib/worker/templates.js +78 -78
- package/lib/worker/workerHandler.js +54 -54
- package/package.json +92 -92
- package/test/blobStorage/common.js +21 -21
- package/test/store/common.js +1449 -1449
|
@@ -1,47 +1,52 @@
|
|
|
1
|
-
module.exports = (reporter, options) => {
|
|
2
|
-
let provider
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
async read (blobName, req) {
|
|
6
|
-
const r = await provider.read(blobName, req)
|
|
7
|
-
if (r == null) {
|
|
8
|
-
throw reporter.createError(`Blob ${blobName} wasn't found`, {
|
|
9
|
-
statusCode: 404
|
|
10
|
-
})
|
|
11
|
-
}
|
|
12
|
-
return r
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
write (blobName, buffer, req) {
|
|
16
|
-
return provider.write(blobName, buffer, req)
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
async remove (blobName, req) {
|
|
20
|
-
return provider.remove(blobName)
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
async append (blobName, buffer, req) {
|
|
24
|
-
if (!provider.append) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
module.exports = (reporter, options) => {
|
|
2
|
+
let provider
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
async read (blobName, req) {
|
|
6
|
+
const r = await provider.read(blobName, req)
|
|
7
|
+
if (r == null) {
|
|
8
|
+
throw reporter.createError(`Blob ${blobName} wasn't found`, {
|
|
9
|
+
statusCode: 404
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
return r
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
write (blobName, buffer, req) {
|
|
16
|
+
return provider.write(blobName, buffer, req)
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
async remove (blobName, req) {
|
|
20
|
+
return provider.remove(blobName)
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
async append (blobName, buffer, req) {
|
|
24
|
+
if (!provider.append) {
|
|
25
|
+
let existingBuf = Buffer.from([])
|
|
26
|
+
try {
|
|
27
|
+
existingBuf = await provider.read(blobName, req)
|
|
28
|
+
} catch (e) {
|
|
29
|
+
// so far blob storage throws when blob doesnt exit
|
|
30
|
+
}
|
|
31
|
+
return provider.write(blobName, existingBuf ? Buffer.concat([existingBuf, buffer]) : buffer, req)
|
|
32
|
+
}
|
|
33
|
+
return provider.append(blobName, buffer, req)
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
async init () {
|
|
37
|
+
if (provider.init) {
|
|
38
|
+
return provider.init()
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
drop () {
|
|
43
|
+
if (provider.drop) {
|
|
44
|
+
return provider.drop()
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
registerProvider (p) {
|
|
49
|
+
provider = p
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
module.exports = (options) => {
|
|
2
|
-
const storage = {}
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
write (blobName, buffer) {
|
|
6
|
-
storage[blobName] = buffer
|
|
7
|
-
return blobName
|
|
8
|
-
},
|
|
9
|
-
|
|
10
|
-
read (blobName) {
|
|
11
|
-
return storage[blobName]
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
remove (blobName) {
|
|
15
|
-
delete storage[blobName]
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
append (blobName, buffer) {
|
|
19
|
-
storage[blobName] = storage[blobName] || Buffer.from('')
|
|
20
|
-
storage[blobName] = Buffer.concat([storage[blobName], buffer])
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
init () {
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
module.exports = (options) => {
|
|
2
|
+
const storage = {}
|
|
3
|
+
|
|
4
|
+
return {
|
|
5
|
+
write (blobName, buffer) {
|
|
6
|
+
storage[blobName] = buffer
|
|
7
|
+
return blobName
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
read (blobName) {
|
|
11
|
+
return storage[blobName]
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
remove (blobName) {
|
|
15
|
+
delete storage[blobName]
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
append (blobName, buffer) {
|
|
19
|
+
storage[blobName] = storage[blobName] || Buffer.from('')
|
|
20
|
+
storage[blobName] = Buffer.concat([storage[blobName], buffer])
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
init () {
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
module.exports = (reporter) => {
|
|
2
|
-
reporter.registerMainAction('blobStorage.read', async (spec, originalReq) => {
|
|
3
|
-
const localReq = reporter.Request(originalReq)
|
|
4
|
-
const res = await reporter.blobStorage.read(spec.blobName, localReq)
|
|
5
|
-
|
|
6
|
-
return res.toString('base64')
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
reporter.registerMainAction('blobStorage.write', async (spec, originalReq) => {
|
|
10
|
-
const localReq = reporter.Request(originalReq)
|
|
11
|
-
|
|
12
|
-
return await reporter.blobStorage.write(spec.blobName, Buffer.from(spec.content, 'base64'), localReq)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
reporter.registerMainAction('blobStorage.remove', async (spec, originalReq) => {
|
|
16
|
-
const localReq = reporter.Request(originalReq)
|
|
17
|
-
return reporter.blobStorage.remove(spec.blobName, localReq)
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
reporter.registerMainAction('blobStorage.append', async (spec, originalReq) => {
|
|
21
|
-
const localReq = reporter.Request(originalReq)
|
|
22
|
-
return reporter.blobStorage.append(spec.blobName, Buffer.from(spec.content, 'base64'), localReq)
|
|
23
|
-
})
|
|
24
|
-
}
|
|
1
|
+
module.exports = (reporter) => {
|
|
2
|
+
reporter.registerMainAction('blobStorage.read', async (spec, originalReq) => {
|
|
3
|
+
const localReq = reporter.Request(originalReq)
|
|
4
|
+
const res = await reporter.blobStorage.read(spec.blobName, localReq)
|
|
5
|
+
|
|
6
|
+
return res.toString('base64')
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
reporter.registerMainAction('blobStorage.write', async (spec, originalReq) => {
|
|
10
|
+
const localReq = reporter.Request(originalReq)
|
|
11
|
+
|
|
12
|
+
return await reporter.blobStorage.write(spec.blobName, Buffer.from(spec.content, 'base64'), localReq)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
reporter.registerMainAction('blobStorage.remove', async (spec, originalReq) => {
|
|
16
|
+
const localReq = reporter.Request(originalReq)
|
|
17
|
+
return reporter.blobStorage.remove(spec.blobName, localReq)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
reporter.registerMainAction('blobStorage.append', async (spec, originalReq) => {
|
|
21
|
+
const localReq = reporter.Request(originalReq)
|
|
22
|
+
return reporter.blobStorage.append(spec.blobName, Buffer.from(spec.content, 'base64'), localReq)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const { MESSAGE } = require('triple-beam')
|
|
2
|
-
const winston = require('winston')
|
|
3
|
-
|
|
4
|
-
module.exports = (options = {}) => {
|
|
5
|
-
return winston.format((info) => {
|
|
6
|
-
const { level, message, ...meta } = info
|
|
7
|
-
info[MESSAGE] = `${options.timestamp === true ? `${new Date().toISOString()} - ` : ''}${level}: ${message}`
|
|
8
|
-
|
|
9
|
-
const metaKeys = Object.keys(meta)
|
|
10
|
-
|
|
11
|
-
if (metaKeys.length > 0) {
|
|
12
|
-
info[MESSAGE] += ` ${metaKeys.map((k) => `${k}=${meta[k]}`).join(', ')}`
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return info
|
|
16
|
-
})
|
|
17
|
-
}
|
|
1
|
+
const { MESSAGE } = require('triple-beam')
|
|
2
|
+
const winston = require('winston')
|
|
3
|
+
|
|
4
|
+
module.exports = (options = {}) => {
|
|
5
|
+
return winston.format((info) => {
|
|
6
|
+
const { level, message, ...meta } = info
|
|
7
|
+
info[MESSAGE] = `${options.timestamp === true ? `${new Date().toISOString()} - ` : ''}${level}: ${message}`
|
|
8
|
+
|
|
9
|
+
const metaKeys = Object.keys(meta)
|
|
10
|
+
|
|
11
|
+
if (metaKeys.length > 0) {
|
|
12
|
+
info[MESSAGE] += ` ${metaKeys.map((k) => `${k}=${meta[k]}`).join(', ')}`
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return info
|
|
16
|
+
})
|
|
17
|
+
}
|
package/lib/main/defaults.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const os = require('os')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
exports.getDefaultTempDirectory = () => {
|
|
5
|
-
return path.join(os.tmpdir(), 'jsreport')
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
exports.getDefaultRootDirectory = () => {
|
|
9
|
-
return path.join(__dirname, '../../../../')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
exports.getDefaultLoadConfig = () => {
|
|
13
|
-
return false
|
|
14
|
-
}
|
|
1
|
+
const os = require('os')
|
|
2
|
+
const path = require('path')
|
|
3
|
+
|
|
4
|
+
exports.getDefaultTempDirectory = () => {
|
|
5
|
+
return path.join(os.tmpdir(), 'jsreport')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
exports.getDefaultRootDirectory = () => {
|
|
9
|
+
return path.join(__dirname, '../../../../')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
exports.getDefaultLoadConfig = () => {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const locationCache = require('./locationCache')
|
|
3
|
-
|
|
4
|
-
module.exports = async (config) => {
|
|
5
|
-
const cache = locationCache(config)
|
|
6
|
-
|
|
7
|
-
config.logger.info(`Searching for available extensions in ${config.rootDirectory}`)
|
|
8
|
-
|
|
9
|
-
const results = await cache.get()
|
|
10
|
-
config.logger.info(`Found ${results.length} extension(s)`)
|
|
11
|
-
|
|
12
|
-
const availableExtensions = results.map((configFile) => (
|
|
13
|
-
Object.assign({
|
|
14
|
-
directory: path.dirname(configFile)
|
|
15
|
-
}, require(configFile))
|
|
16
|
-
))
|
|
17
|
-
|
|
18
|
-
await cache.save(availableExtensions)
|
|
19
|
-
return availableExtensions
|
|
20
|
-
}
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const locationCache = require('./locationCache')
|
|
3
|
+
|
|
4
|
+
module.exports = async (config) => {
|
|
5
|
+
const cache = locationCache(config)
|
|
6
|
+
|
|
7
|
+
config.logger.info(`Searching for available extensions in ${config.rootDirectory}`)
|
|
8
|
+
|
|
9
|
+
const results = await cache.get()
|
|
10
|
+
config.logger.info(`Found ${results.length} extension(s)`)
|
|
11
|
+
|
|
12
|
+
const availableExtensions = results.map((configFile) => (
|
|
13
|
+
Object.assign({
|
|
14
|
+
directory: path.dirname(configFile)
|
|
15
|
+
}, require(configFile))
|
|
16
|
+
))
|
|
17
|
+
|
|
18
|
+
await cache.save(availableExtensions)
|
|
19
|
+
return availableExtensions
|
|
20
|
+
}
|