@jsreport/jsreport-core 3.1.1 → 3.3.0
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 -298
- package/index.js +29 -29
- package/lib/main/blobStorage/blobStorage.js +52 -52
- 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 -264
- package/lib/main/extensions/fileUtils.js +56 -56
- package/lib/main/extensions/findVersion.js +49 -49
- package/lib/main/extensions/locationCache.js +103 -103
- 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 +254 -244
- package/lib/main/migration/resourcesToAssets.js +230 -230
- package/lib/main/migration/xlsxTemplatesToAssets.js +128 -128
- package/lib/main/monitoring.js +92 -91
- package/lib/main/optionsLoad.js +237 -237
- package/lib/main/optionsSchema.js +237 -237
- package/lib/main/profiler.js +13 -1
- package/lib/main/reporter.js +593 -579
- 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 -169
- package/lib/shared/normalizeMetaFromLogs.js +30 -30
- package/lib/shared/reporter.js +128 -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 +232 -207
- package/lib/worker/render/htmlRecipe.js +10 -10
- package/lib/worker/render/moduleHelper.js +45 -43
- package/lib/worker/render/noneEngine.js +12 -12
- package/lib/worker/render/profiler.js +162 -158
- package/lib/worker/render/render.js +202 -201
- package/lib/worker/render/resolveReferences.js +60 -60
- package/lib/worker/reporter.js +197 -191
- package/lib/worker/sandbox/runInSandbox.js +65 -13
- package/lib/worker/sandbox/safeSandbox.js +829 -828
- package/lib/worker/templates.js +80 -78
- package/lib/worker/workerHandler.js +54 -54
- package/package.json +91 -92
- package/test/blobStorage/common.js +21 -21
- package/test/store/common.js +1449 -1449
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
module.exports = (reporter) => {
|
|
2
|
-
reporter.registerMainAction('documentStore.collection.find', async (spec, originalReq) => {
|
|
3
|
-
const localReq = reporter.Request(originalReq)
|
|
4
|
-
localReq.context.userFindCall = true
|
|
5
|
-
const res = await reporter.documentStore.collection(spec.collection).find(spec.query, localReq)
|
|
6
|
-
return res
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
reporter.registerMainAction('documentStore.collection.findOne', async (spec, originalReq) => {
|
|
10
|
-
const localReq = reporter.Request(originalReq)
|
|
11
|
-
localReq.context.userFindCall = true
|
|
12
|
-
const res = await reporter.documentStore.collection(spec.collection).findOne(spec.query, localReq)
|
|
13
|
-
return res
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
reporter.registerMainAction('documentStore.collection.insert', async (spec, originalReq) => {
|
|
17
|
-
const localReq = reporter.Request(originalReq)
|
|
18
|
-
const res = await reporter.documentStore.collection(spec.collection).insert(spec.doc, localReq)
|
|
19
|
-
return res
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
reporter.registerMainAction('documentStore.collection.update', async (spec, originalReq) => {
|
|
23
|
-
const localReq = reporter.Request(originalReq)
|
|
24
|
-
const res = await reporter.documentStore.collection(spec.collection).update(spec.query, spec.update, spec.options, localReq)
|
|
25
|
-
|
|
26
|
-
return res
|
|
27
|
-
})
|
|
28
|
-
}
|
|
1
|
+
module.exports = (reporter) => {
|
|
2
|
+
reporter.registerMainAction('documentStore.collection.find', async (spec, originalReq) => {
|
|
3
|
+
const localReq = reporter.Request(originalReq)
|
|
4
|
+
localReq.context.userFindCall = true
|
|
5
|
+
const res = await reporter.documentStore.collection(spec.collection).find(spec.query, localReq)
|
|
6
|
+
return res
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
reporter.registerMainAction('documentStore.collection.findOne', async (spec, originalReq) => {
|
|
10
|
+
const localReq = reporter.Request(originalReq)
|
|
11
|
+
localReq.context.userFindCall = true
|
|
12
|
+
const res = await reporter.documentStore.collection(spec.collection).findOne(spec.query, localReq)
|
|
13
|
+
return res
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
reporter.registerMainAction('documentStore.collection.insert', async (spec, originalReq) => {
|
|
17
|
+
const localReq = reporter.Request(originalReq)
|
|
18
|
+
const res = await reporter.documentStore.collection(spec.collection).insert(spec.doc, localReq)
|
|
19
|
+
return res
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
reporter.registerMainAction('documentStore.collection.update', async (spec, originalReq) => {
|
|
23
|
+
const localReq = reporter.Request(originalReq)
|
|
24
|
+
const res = await reporter.documentStore.collection(spec.collection).update(spec.query, spec.update, spec.options, localReq)
|
|
25
|
+
|
|
26
|
+
return res
|
|
27
|
+
})
|
|
28
|
+
}
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Copyright(c) 2018 Jan Blaha
|
|
3
|
-
*
|
|
4
|
-
* DocumentStore data layer provider using just memory.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const extend = require('node.extend.without.arrays')
|
|
8
|
-
const { nanoid } = require('nanoid')
|
|
9
|
-
const omit = require('lodash.omit')
|
|
10
|
-
const mingo = require('@jsreport/mingo')
|
|
11
|
-
const Transaction = require('./transaction')
|
|
12
|
-
const Queue = require('./queue')
|
|
13
|
-
|
|
14
|
-
module.exports = () => {
|
|
15
|
-
return {
|
|
16
|
-
load (model) {
|
|
17
|
-
this.model = model
|
|
18
|
-
this.transaction = Transaction({ queue: Queue() })
|
|
19
|
-
|
|
20
|
-
return this.transaction.operation(async (documents) => {
|
|
21
|
-
Object.keys(model.entitySets).forEach((e) => (documents[e] = []))
|
|
22
|
-
})
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
beginTransaction () {
|
|
26
|
-
return this.transaction.begin()
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
async commitTransaction (tran) {
|
|
30
|
-
await this.transaction.commit(tran)
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
async rollbackTransaction (tran) {
|
|
34
|
-
return this.transaction.rollback(tran)
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
find (entitySet, query, fields, opts = {}) {
|
|
38
|
-
const documents = this.transaction.getCurrentDocuments(opts)
|
|
39
|
-
const cursor = mingo.find(documents[entitySet], query, fields)
|
|
40
|
-
|
|
41
|
-
// the queue is not used here because reads are supposed to not block
|
|
42
|
-
cursor.toArray = () => cursor.all().map((e) => extend(true, {}, omit(e, '$$etag')))
|
|
43
|
-
|
|
44
|
-
return cursor
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
insert (entitySet, doc, opts = {}) {
|
|
48
|
-
return this.transaction.operation(opts, async (documents) => {
|
|
49
|
-
doc._id = doc._id || nanoid(16)
|
|
50
|
-
const newDoc = extend(true, {}, doc)
|
|
51
|
-
newDoc.$$etag = Date.now()
|
|
52
|
-
documents[entitySet].push(newDoc)
|
|
53
|
-
return doc
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
async update (entitySet, q, u, opts = {}) {
|
|
58
|
-
let count
|
|
59
|
-
|
|
60
|
-
const res = await this.transaction.operation(opts, async (documents) => {
|
|
61
|
-
const toUpdate = mingo.find(documents[entitySet], q).all()
|
|
62
|
-
|
|
63
|
-
count = toUpdate.length
|
|
64
|
-
|
|
65
|
-
// need to get of queue first before calling insert, otherwise we get a deathlock
|
|
66
|
-
if (toUpdate.length === 0 && opts.upsert) {
|
|
67
|
-
return 'insert'
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
for (const doc of toUpdate) {
|
|
71
|
-
Object.assign(doc, u.$set || {})
|
|
72
|
-
doc.$$etag = Date.now()
|
|
73
|
-
}
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
if (res === 'insert') {
|
|
77
|
-
await this.insert(entitySet, u.$set, opts)
|
|
78
|
-
return 1
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return count
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
remove (entitySet, q, opts = {}) {
|
|
85
|
-
return this.transaction.operation(opts, async (documents) => {
|
|
86
|
-
const toRemove = mingo.find(documents[entitySet], q).all()
|
|
87
|
-
documents[entitySet] = documents[entitySet].filter(d => !toRemove.includes(d))
|
|
88
|
-
})
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
drop (opts = {}) {
|
|
92
|
-
return this.transaction.operation(opts, async (documents) => {
|
|
93
|
-
for (const [entitySetName] of Object.entries(documents)) {
|
|
94
|
-
documents[entitySetName] = []
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright(c) 2018 Jan Blaha
|
|
3
|
+
*
|
|
4
|
+
* DocumentStore data layer provider using just memory.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const extend = require('node.extend.without.arrays')
|
|
8
|
+
const { nanoid } = require('nanoid')
|
|
9
|
+
const omit = require('lodash.omit')
|
|
10
|
+
const mingo = require('@jsreport/mingo')
|
|
11
|
+
const Transaction = require('./transaction')
|
|
12
|
+
const Queue = require('./queue')
|
|
13
|
+
|
|
14
|
+
module.exports = () => {
|
|
15
|
+
return {
|
|
16
|
+
load (model) {
|
|
17
|
+
this.model = model
|
|
18
|
+
this.transaction = Transaction({ queue: Queue() })
|
|
19
|
+
|
|
20
|
+
return this.transaction.operation(async (documents) => {
|
|
21
|
+
Object.keys(model.entitySets).forEach((e) => (documents[e] = []))
|
|
22
|
+
})
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
beginTransaction () {
|
|
26
|
+
return this.transaction.begin()
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
async commitTransaction (tran) {
|
|
30
|
+
await this.transaction.commit(tran)
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
async rollbackTransaction (tran) {
|
|
34
|
+
return this.transaction.rollback(tran)
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
find (entitySet, query, fields, opts = {}) {
|
|
38
|
+
const documents = this.transaction.getCurrentDocuments(opts)
|
|
39
|
+
const cursor = mingo.find(documents[entitySet], query, fields)
|
|
40
|
+
|
|
41
|
+
// the queue is not used here because reads are supposed to not block
|
|
42
|
+
cursor.toArray = () => cursor.all().map((e) => extend(true, {}, omit(e, '$$etag')))
|
|
43
|
+
|
|
44
|
+
return cursor
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
insert (entitySet, doc, opts = {}) {
|
|
48
|
+
return this.transaction.operation(opts, async (documents) => {
|
|
49
|
+
doc._id = doc._id || nanoid(16)
|
|
50
|
+
const newDoc = extend(true, {}, doc)
|
|
51
|
+
newDoc.$$etag = Date.now()
|
|
52
|
+
documents[entitySet].push(newDoc)
|
|
53
|
+
return doc
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
async update (entitySet, q, u, opts = {}) {
|
|
58
|
+
let count
|
|
59
|
+
|
|
60
|
+
const res = await this.transaction.operation(opts, async (documents) => {
|
|
61
|
+
const toUpdate = mingo.find(documents[entitySet], q).all()
|
|
62
|
+
|
|
63
|
+
count = toUpdate.length
|
|
64
|
+
|
|
65
|
+
// need to get of queue first before calling insert, otherwise we get a deathlock
|
|
66
|
+
if (toUpdate.length === 0 && opts.upsert) {
|
|
67
|
+
return 'insert'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
for (const doc of toUpdate) {
|
|
71
|
+
Object.assign(doc, u.$set || {})
|
|
72
|
+
doc.$$etag = Date.now()
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
if (res === 'insert') {
|
|
77
|
+
await this.insert(entitySet, u.$set, opts)
|
|
78
|
+
return 1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return count
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
remove (entitySet, q, opts = {}) {
|
|
85
|
+
return this.transaction.operation(opts, async (documents) => {
|
|
86
|
+
const toRemove = mingo.find(documents[entitySet], q).all()
|
|
87
|
+
documents[entitySet] = documents[entitySet].filter(d => !toRemove.includes(d))
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
drop (opts = {}) {
|
|
92
|
+
return this.transaction.operation(opts, async (documents) => {
|
|
93
|
+
for (const [entitySetName] of Object.entries(documents)) {
|
|
94
|
+
documents[entitySetName] = []
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
package/lib/main/store/queue.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
module.exports = () => {
|
|
3
|
-
const items = []
|
|
4
|
-
let busy = false
|
|
5
|
-
|
|
6
|
-
function execute () {
|
|
7
|
-
if (items.length < 1 || busy) {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
busy = true
|
|
12
|
-
const item = items.shift()
|
|
13
|
-
item.busy = true
|
|
14
|
-
|
|
15
|
-
Promise.resolve(item.fn()).then((res) => {
|
|
16
|
-
item.resolve(res)
|
|
17
|
-
busy = false
|
|
18
|
-
execute()
|
|
19
|
-
return null
|
|
20
|
-
}).catch((err) => {
|
|
21
|
-
item.reject(err)
|
|
22
|
-
busy = false
|
|
23
|
-
execute()
|
|
24
|
-
return null
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
push (fn) {
|
|
30
|
-
let _resolve, _reject
|
|
31
|
-
|
|
32
|
-
const result = new Promise((resolve, reject) => {
|
|
33
|
-
_resolve = resolve
|
|
34
|
-
_reject = reject
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
items.push({
|
|
38
|
-
fn,
|
|
39
|
-
resolve: _resolve,
|
|
40
|
-
reject: _reject,
|
|
41
|
-
submittedOn: new Date().getTime()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
execute()
|
|
45
|
-
return result
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
1
|
+
|
|
2
|
+
module.exports = () => {
|
|
3
|
+
const items = []
|
|
4
|
+
let busy = false
|
|
5
|
+
|
|
6
|
+
function execute () {
|
|
7
|
+
if (items.length < 1 || busy) {
|
|
8
|
+
return
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
busy = true
|
|
12
|
+
const item = items.shift()
|
|
13
|
+
item.busy = true
|
|
14
|
+
|
|
15
|
+
Promise.resolve(item.fn()).then((res) => {
|
|
16
|
+
item.resolve(res)
|
|
17
|
+
busy = false
|
|
18
|
+
execute()
|
|
19
|
+
return null
|
|
20
|
+
}).catch((err) => {
|
|
21
|
+
item.reject(err)
|
|
22
|
+
busy = false
|
|
23
|
+
execute()
|
|
24
|
+
return null
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
push (fn) {
|
|
30
|
+
let _resolve, _reject
|
|
31
|
+
|
|
32
|
+
const result = new Promise((resolve, reject) => {
|
|
33
|
+
_resolve = resolve
|
|
34
|
+
_reject = reject
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
items.push({
|
|
38
|
+
fn,
|
|
39
|
+
resolve: _resolve,
|
|
40
|
+
reject: _reject,
|
|
41
|
+
submittedOn: new Date().getTime()
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
execute()
|
|
45
|
+
return result
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|