@jsreport/jsreport-core 3.4.0 → 3.4.1
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/README.md +5 -0
- package/lib/main/blobStorage/blobStorage.js +1 -0
- package/lib/main/reporter.js +14 -19
- package/lib/main/request.js +21 -0
- package/lib/worker/workerHandler.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/main/reporter.js
CHANGED
|
@@ -25,7 +25,7 @@ const setupValidateShortid = require('./store/setupValidateShortid')
|
|
|
25
25
|
const documentStoreActions = require('./store/mainActions')
|
|
26
26
|
const blobStorageActions = require('./blobStorage/mainActions')
|
|
27
27
|
const Reporter = require('../shared/reporter')
|
|
28
|
-
const Request = require('
|
|
28
|
+
const Request = require('./request')
|
|
29
29
|
const generateRequestId = require('../shared/generateRequestId')
|
|
30
30
|
const Profiler = require('./profiler')
|
|
31
31
|
const Monitoring = require('./monitoring')
|
|
@@ -315,17 +315,11 @@ class MainReporter extends Reporter {
|
|
|
315
315
|
*
|
|
316
316
|
* @public
|
|
317
317
|
*/
|
|
318
|
-
async render (req,
|
|
318
|
+
async render (req, options = {}) {
|
|
319
319
|
if (!this._initialized) {
|
|
320
320
|
throw new Error('Not initialized, you need to call jsreport.init().then before rendering')
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
let options = {}
|
|
324
|
-
if (parentReq && !parentReq.__isJsreportRequest__) {
|
|
325
|
-
options = parentReq
|
|
326
|
-
parentReq = null
|
|
327
|
-
}
|
|
328
|
-
|
|
329
323
|
req = Object.assign({}, req)
|
|
330
324
|
req.context = Object.assign({}, req.context)
|
|
331
325
|
req.context.rootId = req.context.rootId || generateRequestId()
|
|
@@ -351,10 +345,7 @@ class MainReporter extends Reporter {
|
|
|
351
345
|
throw this.createError('Request aborted by client')
|
|
352
346
|
}
|
|
353
347
|
|
|
354
|
-
let isDataStoredInWorker = false
|
|
355
|
-
|
|
356
348
|
if (req.rawContent) {
|
|
357
|
-
isDataStoredInWorker = true
|
|
358
349
|
const result = await worker.execute({
|
|
359
350
|
actionName: 'parse',
|
|
360
351
|
req,
|
|
@@ -365,13 +356,7 @@ class MainReporter extends Reporter {
|
|
|
365
356
|
req = result
|
|
366
357
|
}
|
|
367
358
|
|
|
368
|
-
req = Request(req
|
|
369
|
-
|
|
370
|
-
if (isDataStoredInWorker) {
|
|
371
|
-
// we unset this because we want the Request() call in worker to evaluate the data
|
|
372
|
-
// and determine if the original was empty or not
|
|
373
|
-
delete req.context.originalInputDataIsEmpty
|
|
374
|
-
}
|
|
359
|
+
req = Request(req)
|
|
375
360
|
|
|
376
361
|
// TODO: we will probably validate in the thread
|
|
377
362
|
if (this.entityTypeValidator.getSchema('TemplateType') != null) {
|
|
@@ -405,7 +390,17 @@ class MainReporter extends Reporter {
|
|
|
405
390
|
if (req.context.returnResponseAndKeepWorker) {
|
|
406
391
|
keepWorker = true
|
|
407
392
|
res.stream = Readable.from(res.content)
|
|
408
|
-
|
|
393
|
+
|
|
394
|
+
// just temporary workaround until we change how report render works
|
|
395
|
+
await this.documentStore.collection('profiles').update({
|
|
396
|
+
_id: req.context.profiling.entity._id
|
|
397
|
+
}, {
|
|
398
|
+
$set: {
|
|
399
|
+
state: 'success',
|
|
400
|
+
finishedOn: new Date(),
|
|
401
|
+
blobPersisted: true
|
|
402
|
+
}
|
|
403
|
+
}, req)
|
|
409
404
|
return res
|
|
410
405
|
}
|
|
411
406
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const extend = require('node.extend.without.arrays')
|
|
2
|
+
|
|
3
|
+
module.exports = (obj) => {
|
|
4
|
+
const request = Object.create({}, {
|
|
5
|
+
__isJsreportRequest__: {
|
|
6
|
+
value: true,
|
|
7
|
+
writable: false,
|
|
8
|
+
configurable: false,
|
|
9
|
+
enumerable: false
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
request.template = extend(true, {}, obj.template)
|
|
14
|
+
|
|
15
|
+
request.options = extend(true, {}, request.options, obj.options)
|
|
16
|
+
request.context = extend(true, {}, request.context, obj.context)
|
|
17
|
+
request.context.shared = extend(true, {}, request.context.shared)
|
|
18
|
+
request.data = obj.data
|
|
19
|
+
|
|
20
|
+
return request
|
|
21
|
+
}
|