@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 CHANGED
@@ -282,6 +282,11 @@ jsreport.documentStore.collection('templates')
282
282
 
283
283
  ## Changelog
284
284
 
285
+ ### 3.4.1
286
+
287
+ - fix passing data to async report
288
+ - fix blob appends
289
+
285
290
  ### 3.4.0
286
291
 
287
292
  - fix for reports execution
@@ -25,6 +25,7 @@ module.exports = (reporter, options) => {
25
25
  let existingBuf = Buffer.from([])
26
26
  try {
27
27
  existingBuf = await provider.read(blobName, req)
28
+ await provider.remove(blobName, req)
28
29
  } catch (e) {
29
30
  // so far blob storage throws when blob doesnt exit
30
31
  }
@@ -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('../shared/request')
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, parentReq) {
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, parentReq)
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
- await this.afterRenderListeners.fire(req, res)
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
+ }
@@ -31,6 +31,7 @@ module.exports = (userInitData, { executeMain, convertUint8ArrayToBuffer }) => {
31
31
  ...JSON.parse(req.rawContent),
32
32
  context: req.context
33
33
  }
34
+ parsedReq.context.parsedInWorker = true
34
35
 
35
36
  return omit(parsedReq, 'data')
36
37
  } catch (e) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsreport/jsreport-core",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "javascript based business reporting",
5
5
  "keywords": [
6
6
  "report",