@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,53 +1,49 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const fsAsync = require('fs/promises')
|
|
3
|
-
|
|
4
|
-
module.exports = async (extension) => {
|
|
5
|
-
const result = {
|
|
6
|
-
source: 'anonymous'
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (extension.version != null || extension.source != null) {
|
|
10
|
-
result.source = extension.source
|
|
11
|
-
result.version = extension.version
|
|
12
|
-
result.pkgVersion = extension.pkgVersion
|
|
13
|
-
|
|
14
|
-
return result
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (extension.name == null) {
|
|
18
|
-
return result
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (extension.directory == null) {
|
|
22
|
-
result.source = 'local'
|
|
23
|
-
result.version = 'local:inline'
|
|
24
|
-
return result
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
const packageJsonContent = await fsAsync.readFile(path.join(extension.directory, 'package.json'))
|
|
29
|
-
const packageJson = JSON.parse(packageJsonContent.toString())
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
result.source = '
|
|
33
|
-
result.version = packageJson.
|
|
34
|
-
result.pkgVersion = packageJson.version
|
|
35
|
-
} else if (packageJson.
|
|
36
|
-
result.source = '
|
|
37
|
-
result.version = packageJson.version
|
|
38
|
-
result.pkgVersion = packageJson.version
|
|
39
|
-
} else
|
|
40
|
-
result.source = 'local'
|
|
41
|
-
result.version = `local:${extension.directory}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return result
|
|
53
|
-
}
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fsAsync = require('fs/promises')
|
|
3
|
+
|
|
4
|
+
module.exports = async (extension) => {
|
|
5
|
+
const result = {
|
|
6
|
+
source: 'anonymous'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (extension.version != null || extension.source != null) {
|
|
10
|
+
result.source = extension.source
|
|
11
|
+
result.version = extension.version
|
|
12
|
+
result.pkgVersion = extension.pkgVersion
|
|
13
|
+
|
|
14
|
+
return result
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (extension.name == null) {
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (extension.directory == null) {
|
|
22
|
+
result.source = 'local'
|
|
23
|
+
result.version = 'local:inline'
|
|
24
|
+
return result
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const packageJsonContent = await fsAsync.readFile(path.join(extension.directory, 'package.json'))
|
|
29
|
+
const packageJson = JSON.parse(packageJsonContent.toString())
|
|
30
|
+
|
|
31
|
+
if (extension.directory.includes('node_modules') && packageJson.version != null) {
|
|
32
|
+
result.source = 'npm'
|
|
33
|
+
result.version = packageJson.version
|
|
34
|
+
result.pkgVersion = packageJson.version
|
|
35
|
+
} else if (packageJson.version != null) {
|
|
36
|
+
result.source = 'local'
|
|
37
|
+
result.version = `local:${extension.directory}:${packageJson.version}`
|
|
38
|
+
result.pkgVersion = packageJson.version
|
|
39
|
+
} else {
|
|
40
|
+
result.source = 'local'
|
|
41
|
+
result.version = `local:${extension.directory}`
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
result.source = 'local'
|
|
45
|
+
result.version = `local:${extension.directory}`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return result
|
|
49
|
+
}
|
|
@@ -1,97 +1,103 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const fs = require('fs/promises')
|
|
3
|
-
const fileUtils = require('./fileUtils')
|
|
4
|
-
|
|
5
|
-
module.exports = (config) => {
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const fs = require('fs/promises')
|
|
3
|
+
const fileUtils = require('./fileUtils')
|
|
4
|
+
|
|
5
|
+
module.exports = (config) => {
|
|
6
|
+
// we want to have as cache entry the node_modules folder
|
|
7
|
+
const cacheEntryRootPath = path.join(__dirname, '../../../../../')
|
|
8
|
+
const pathToLocationCache = path.join(config.tempCoreDirectory, 'locations.json')
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
async get () {
|
|
12
|
+
if (process.env.NODE_ENV === 'jsreport-development' || config.useExtensionsLocationCache === false) {
|
|
13
|
+
config.logger.info('Skipping extensions location cache when NODE_ENV=jsreport-development or when option useExtensionsLocationCache === false, crawling now')
|
|
14
|
+
|
|
15
|
+
return fileUtils.walkSync(config.rootDirectory, 'jsreport.config.js')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
await fs.stat(pathToLocationCache)
|
|
20
|
+
} catch (e) {
|
|
21
|
+
config.logger.info('Extensions location cache not found, crawling directories')
|
|
22
|
+
return fileUtils.walkSync(config.rootDirectory, 'jsreport.config.js')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const content = await fs.readFile(pathToLocationCache, 'utf8')
|
|
26
|
+
|
|
27
|
+
let cache
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
cache = JSON.parse(content)[cacheEntryRootPath]
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// file is corrupted, never mind and crawl the extensions
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!cache) {
|
|
36
|
+
config.logger.info('Extensions location cache doesn\'t contain entry yet, crawling')
|
|
37
|
+
return fileUtils.walkSync(config.rootDirectory, 'jsreport.config.js')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (cache.rootDirectory !== config.rootDirectory) {
|
|
41
|
+
config.logger.info(`Extensions location cache ${pathToLocationCache} contains information with different rootDirectory, crawling`)
|
|
42
|
+
return fileUtils.walkSync(config.rootDirectory, 'jsreport.config.js')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const stat = await fs.stat(cacheEntryRootPath)
|
|
46
|
+
|
|
47
|
+
if (stat.mtime.getTime() > cache.lastSync) {
|
|
48
|
+
config.logger.info(`Extensions location cache ${pathToLocationCache} contains older information, crawling`)
|
|
49
|
+
return fileUtils.walkSync(config.rootDirectory, 'jsreport.config.js')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
await Promise.all(cache.locations.map((l) => fs.stat(l)))
|
|
53
|
+
|
|
54
|
+
config.logger.info(`Extensions location cache contains up to date information, skipping crawling in ${config.rootDirectory}`)
|
|
55
|
+
|
|
56
|
+
// since the rootDirectory is dynamic (can be changed from options) we need to still
|
|
57
|
+
// crawl to see if we find new extensions if the rootDirectory was changed
|
|
58
|
+
const directories = fileUtils.walkSync(config.rootDirectory, 'jsreport.config.js', cacheEntryRootPath)
|
|
59
|
+
const result = directories.concat(cache.locations)
|
|
60
|
+
|
|
61
|
+
return result
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
async save (extensions) {
|
|
65
|
+
// we just want to store in cache the extensions found from the cache entry root path
|
|
66
|
+
// or in other words the ones from node_modules, we skip storing the extensions found
|
|
67
|
+
// in the rootDirectory
|
|
68
|
+
const directories = (
|
|
69
|
+
extensions
|
|
70
|
+
.map((e) => path.join(e.directory, 'jsreport.config.js'))
|
|
71
|
+
.filter((d) => d.startsWith(cacheEntryRootPath))
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
await fs.mkdir(config.tempCoreDirectory, { recursive: true })
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
await fs.stat(pathToLocationCache)
|
|
78
|
+
} catch (e) {
|
|
79
|
+
await fs.writeFile(pathToLocationCache, JSON.stringify({}), 'utf8')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const content = await fs.readFile(pathToLocationCache, 'utf8')
|
|
83
|
+
|
|
84
|
+
let nodes = {}
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
nodes = JSON.parse(content)
|
|
88
|
+
} catch (e) {
|
|
89
|
+
// file is corrupted, never mind and override all
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
nodes[cacheEntryRootPath] = {
|
|
93
|
+
rootDirectory: config.rootDirectory,
|
|
94
|
+
locations: directories,
|
|
95
|
+
lastSync: new Date().getTime()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
config.logger.debug(`Writing extension locations cache to ${pathToLocationCache}`)
|
|
99
|
+
|
|
100
|
+
return fs.writeFile(pathToLocationCache, JSON.stringify(nodes), 'utf8')
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = (pa, pb) => {
|
|
2
|
-
// todo, sort better by dependencies
|
|
3
|
-
pa.dependencies = pa.dependencies || []
|
|
4
|
-
pb.dependencies = pb.dependencies || []
|
|
5
|
-
|
|
6
|
-
if (pa.dependencies.length > pb.dependencies.length) return 1
|
|
7
|
-
if (pa.dependencies.length < pb.dependencies.length) return -1
|
|
8
|
-
|
|
9
|
-
return 0
|
|
10
|
-
}
|
|
1
|
+
module.exports = (pa, pb) => {
|
|
2
|
+
// todo, sort better by dependencies
|
|
3
|
+
pa.dependencies = pa.dependencies || []
|
|
4
|
+
pb.dependencies = pb.dependencies || []
|
|
5
|
+
|
|
6
|
+
if (pa.dependencies.length > pb.dependencies.length) return 1
|
|
7
|
+
if (pa.dependencies.length < pb.dependencies.length) return -1
|
|
8
|
+
|
|
9
|
+
return 0
|
|
10
|
+
}
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
const semver = require('semver')
|
|
2
|
-
|
|
3
|
-
function validateMinimalVersion (baseExtension, extension) {
|
|
4
|
-
const generalErrorMsg = `${extension.name == null ? 'Anonymous extension' : `Extension "${extension.name}"`} is not compatible with "${baseExtension.name}" extension.`
|
|
5
|
-
const getExtensionLabel = () => extension.name == null ? 'anonymous extension' : `"${extension.name}"`
|
|
6
|
-
|
|
7
|
-
// this allows to validate pre-release versions too
|
|
8
|
-
const normalizeVersionResults = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(baseExtension.version)
|
|
9
|
-
|
|
10
|
-
if (normalizeVersionResults == null) {
|
|
11
|
-
throw new Error(`Invalid format for version of "${baseExtension.name}" extension. Version found: "${baseExtension.version}"`)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
let shouldValidateThatRequiresIsNotEmpty = true
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
(extension.source === 'anonymous') ||
|
|
18
|
-
(extension.source === 'local' && extension.pkgVersion == null)
|
|
19
|
-
) {
|
|
20
|
-
shouldValidateThatRequiresIsNotEmpty = false
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (shouldValidateThatRequiresIsNotEmpty && extension.requires == null) {
|
|
24
|
-
throw new Error(`${generalErrorMsg} Missing ".requires" information in ${getExtensionLabel(extension)} definition`)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const extensionRequires = extension.requires || {}
|
|
28
|
-
const baseExtensionRequireInExtension = extensionRequires[baseExtension.name]
|
|
29
|
-
|
|
30
|
-
if (baseExtensionRequireInExtension == null) {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const minimalVersionFormatRegExp = /^(x{1}|\d+)\.(x{1}|\d+)\.(x{1}|\d+)$/
|
|
35
|
-
|
|
36
|
-
if (!minimalVersionFormatRegExp.test(baseExtensionRequireInExtension)) {
|
|
37
|
-
throw new Error(`${generalErrorMsg} Invalid format for minimal version of "${baseExtension.name}" extension. Minimal version found in ${getExtensionLabel(extension)} definition: "${baseExtensionRequireInExtension}"`)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const baseVersion = `${normalizeVersionResults[1]}.${normalizeVersionResults[2]}.${normalizeVersionResults[3]}`
|
|
41
|
-
const targetSemVer = `>=${baseExtensionRequireInExtension}`
|
|
42
|
-
|
|
43
|
-
const isValid = semver.satisfies(baseVersion, targetSemVer)
|
|
44
|
-
|
|
45
|
-
if (!isValid) {
|
|
46
|
-
throw new Error(`${generalErrorMsg} Minimal version spec "${baseExtensionRequireInExtension}" found in ${getExtensionLabel(extension)} does not match with version "${baseExtension.version}" of "${baseExtension.name}"`)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
module.exports = validateMinimalVersion
|
|
1
|
+
const semver = require('semver')
|
|
2
|
+
|
|
3
|
+
function validateMinimalVersion (baseExtension, extension) {
|
|
4
|
+
const generalErrorMsg = `${extension.name == null ? 'Anonymous extension' : `Extension "${extension.name}"`} is not compatible with "${baseExtension.name}" extension.`
|
|
5
|
+
const getExtensionLabel = () => extension.name == null ? 'anonymous extension' : `"${extension.name}"`
|
|
6
|
+
|
|
7
|
+
// this allows to validate pre-release versions too
|
|
8
|
+
const normalizeVersionResults = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(baseExtension.version)
|
|
9
|
+
|
|
10
|
+
if (normalizeVersionResults == null) {
|
|
11
|
+
throw new Error(`Invalid format for version of "${baseExtension.name}" extension. Version found: "${baseExtension.version}"`)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let shouldValidateThatRequiresIsNotEmpty = true
|
|
15
|
+
|
|
16
|
+
if (
|
|
17
|
+
(extension.source === 'anonymous') ||
|
|
18
|
+
(extension.source === 'local' && extension.pkgVersion == null)
|
|
19
|
+
) {
|
|
20
|
+
shouldValidateThatRequiresIsNotEmpty = false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (shouldValidateThatRequiresIsNotEmpty && extension.requires == null) {
|
|
24
|
+
throw new Error(`${generalErrorMsg} Missing ".requires" information in ${getExtensionLabel(extension)} definition`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const extensionRequires = extension.requires || {}
|
|
28
|
+
const baseExtensionRequireInExtension = extensionRequires[baseExtension.name]
|
|
29
|
+
|
|
30
|
+
if (baseExtensionRequireInExtension == null) {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const minimalVersionFormatRegExp = /^(x{1}|\d+)\.(x{1}|\d+)\.(x{1}|\d+)$/
|
|
35
|
+
|
|
36
|
+
if (!minimalVersionFormatRegExp.test(baseExtensionRequireInExtension)) {
|
|
37
|
+
throw new Error(`${generalErrorMsg} Invalid format for minimal version of "${baseExtension.name}" extension. Minimal version found in ${getExtensionLabel(extension)} definition: "${baseExtensionRequireInExtension}"`)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const baseVersion = `${normalizeVersionResults[1]}.${normalizeVersionResults[2]}.${normalizeVersionResults[3]}`
|
|
41
|
+
const targetSemVer = `>=${baseExtensionRequireInExtension}`
|
|
42
|
+
|
|
43
|
+
const isValid = semver.satisfies(baseVersion, targetSemVer)
|
|
44
|
+
|
|
45
|
+
if (!isValid) {
|
|
46
|
+
throw new Error(`${generalErrorMsg} Minimal version spec "${baseExtensionRequireInExtension}" found in ${getExtensionLabel(extension)} does not match with version "${baseExtension.version}" of "${baseExtension.name}"`)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module.exports = validateMinimalVersion
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
module.exports = (reporter) => {
|
|
2
|
-
reporter.documentStore.collection('folders').beforeRemoveListeners.add('folders', async (q, req) => {
|
|
3
|
-
const foldersToRemove = await reporter.documentStore.collection('folders').find(q, req)
|
|
4
|
-
|
|
5
|
-
for (const folder of foldersToRemove) {
|
|
6
|
-
for (const c of Object.keys(reporter.documentStore.collections)) {
|
|
7
|
-
const entities = await reporter.documentStore.collection(c).find({
|
|
8
|
-
folder: {
|
|
9
|
-
shortid: folder.shortid
|
|
10
|
-
}
|
|
11
|
-
}, req)
|
|
12
|
-
|
|
13
|
-
if (entities.length === 0) {
|
|
14
|
-
continue
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
for (const e of entities) {
|
|
18
|
-
await reporter.documentStore.collection(c).remove({
|
|
19
|
-
_id: e._id
|
|
20
|
-
}, req)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
})
|
|
25
|
-
}
|
|
1
|
+
module.exports = (reporter) => {
|
|
2
|
+
reporter.documentStore.collection('folders').beforeRemoveListeners.add('folders', async (q, req) => {
|
|
3
|
+
const foldersToRemove = await reporter.documentStore.collection('folders').find(q, req)
|
|
4
|
+
|
|
5
|
+
for (const folder of foldersToRemove) {
|
|
6
|
+
for (const c of Object.keys(reporter.documentStore.collections)) {
|
|
7
|
+
const entities = await reporter.documentStore.collection(c).find({
|
|
8
|
+
folder: {
|
|
9
|
+
shortid: folder.shortid
|
|
10
|
+
}
|
|
11
|
+
}, req)
|
|
12
|
+
|
|
13
|
+
if (entities.length === 0) {
|
|
14
|
+
continue
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
for (const e of entities) {
|
|
18
|
+
await reporter.documentStore.collection(c).remove({
|
|
19
|
+
_id: e._id
|
|
20
|
+
}, req)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
}
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = (reporter) => async function getEntitiesInFolder (folderShortId, recursive, req) {
|
|
3
|
-
if (folderShortId == null) {
|
|
4
|
-
throw new Error('Missing folder shortid param')
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const entities = []
|
|
8
|
-
const lookup = []
|
|
9
|
-
|
|
10
|
-
for (const [entitySetName] of Object.entries(reporter.documentStore.model.entitySets)) {
|
|
11
|
-
lookup.push(reporter.documentStore.collection(entitySetName).find({
|
|
12
|
-
folder: {
|
|
13
|
-
shortid: folderShortId
|
|
14
|
-
}
|
|
15
|
-
}, req).then((results) => {
|
|
16
|
-
if (results.length === 0) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (entitySetName === 'folders') {
|
|
21
|
-
return Promise.all(results.map((folder) => {
|
|
22
|
-
entities.push({
|
|
23
|
-
entitySet: entitySetName,
|
|
24
|
-
entity: folder
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
if (recursive === true) {
|
|
28
|
-
return getEntitiesInFolder(folder.shortid, true, req)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return undefined
|
|
32
|
-
})).then((folderLookupResults) => {
|
|
33
|
-
folderLookupResults.forEach((childEntities) => {
|
|
34
|
-
if (childEntities) {
|
|
35
|
-
entities.push(...childEntities)
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
} else {
|
|
40
|
-
results.forEach((entity) => {
|
|
41
|
-
entities.push({
|
|
42
|
-
entitySet: entitySetName,
|
|
43
|
-
entity
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
}
|
|
47
|
-
}))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
await Promise.all(lookup)
|
|
51
|
-
|
|
52
|
-
return entities
|
|
53
|
-
}
|
|
1
|
+
|
|
2
|
+
module.exports = (reporter) => async function getEntitiesInFolder (folderShortId, recursive, req) {
|
|
3
|
+
if (folderShortId == null) {
|
|
4
|
+
throw new Error('Missing folder shortid param')
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const entities = []
|
|
8
|
+
const lookup = []
|
|
9
|
+
|
|
10
|
+
for (const [entitySetName] of Object.entries(reporter.documentStore.model.entitySets)) {
|
|
11
|
+
lookup.push(reporter.documentStore.collection(entitySetName).find({
|
|
12
|
+
folder: {
|
|
13
|
+
shortid: folderShortId
|
|
14
|
+
}
|
|
15
|
+
}, req).then((results) => {
|
|
16
|
+
if (results.length === 0) {
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (entitySetName === 'folders') {
|
|
21
|
+
return Promise.all(results.map((folder) => {
|
|
22
|
+
entities.push({
|
|
23
|
+
entitySet: entitySetName,
|
|
24
|
+
entity: folder
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
if (recursive === true) {
|
|
28
|
+
return getEntitiesInFolder(folder.shortid, true, req)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return undefined
|
|
32
|
+
})).then((folderLookupResults) => {
|
|
33
|
+
folderLookupResults.forEach((childEntities) => {
|
|
34
|
+
if (childEntities) {
|
|
35
|
+
entities.push(...childEntities)
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
})
|
|
39
|
+
} else {
|
|
40
|
+
results.forEach((entity) => {
|
|
41
|
+
entities.push({
|
|
42
|
+
entitySet: entitySetName,
|
|
43
|
+
entity
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
await Promise.all(lookup)
|
|
51
|
+
|
|
52
|
+
return entities
|
|
53
|
+
}
|