@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.
Files changed (79) hide show
  1. package/LICENSE +166 -166
  2. package/README.md +298 -284
  3. package/index.js +29 -27
  4. package/lib/main/blobStorage/blobStorage.js +52 -47
  5. package/lib/main/blobStorage/inMemoryProvider.js +27 -27
  6. package/lib/main/blobStorage/mainActions.js +24 -24
  7. package/lib/main/createDefaultLoggerFormat.js +17 -17
  8. package/lib/main/defaults.js +14 -14
  9. package/lib/main/extensions/discover.js +20 -20
  10. package/lib/main/extensions/extensionsManager.js +264 -265
  11. package/lib/main/extensions/fileUtils.js +56 -55
  12. package/lib/main/extensions/findVersion.js +49 -53
  13. package/lib/main/extensions/locationCache.js +103 -97
  14. package/lib/main/extensions/sorter.js +10 -10
  15. package/lib/main/extensions/validateMinimalVersion.js +50 -50
  16. package/lib/main/folders/cascadeFolderRemove.js +25 -25
  17. package/lib/main/folders/getEntitiesInFolder.js +53 -53
  18. package/lib/main/folders/index.js +42 -42
  19. package/lib/main/folders/moveBetweenFolders.js +354 -354
  20. package/lib/main/folders/validateDuplicatedName.js +107 -107
  21. package/lib/main/folders/validateReservedName.js +53 -53
  22. package/lib/main/logger.js +244 -244
  23. package/lib/main/migration/resourcesToAssets.js +230 -210
  24. package/lib/main/migration/xlsxTemplatesToAssets.js +128 -118
  25. package/lib/main/monitoring.js +91 -91
  26. package/lib/main/optionsLoad.js +237 -237
  27. package/lib/main/optionsSchema.js +237 -237
  28. package/lib/main/reporter.js +579 -578
  29. package/lib/main/schemaValidator.js +252 -252
  30. package/lib/main/settings.js +154 -154
  31. package/lib/main/store/checkDuplicatedId.js +27 -27
  32. package/lib/main/store/collection.js +329 -329
  33. package/lib/main/store/documentStore.js +469 -469
  34. package/lib/main/store/mainActions.js +28 -28
  35. package/lib/main/store/memoryStoreProvider.js +99 -99
  36. package/lib/main/store/queue.js +48 -48
  37. package/lib/main/store/referenceUtils.js +251 -251
  38. package/lib/main/store/setupValidateId.js +43 -43
  39. package/lib/main/store/setupValidateShortid.js +71 -71
  40. package/lib/main/store/transaction.js +69 -69
  41. package/lib/main/store/typeUtils.js +180 -180
  42. package/lib/main/templates.js +34 -34
  43. package/lib/main/validateEntityName.js +62 -62
  44. package/lib/shared/createError.js +36 -36
  45. package/lib/shared/encryption.js +114 -114
  46. package/lib/shared/folders/index.js +11 -11
  47. package/lib/shared/folders/normalizeEntityPath.js +15 -15
  48. package/lib/shared/folders/resolveEntityFromPath.js +88 -88
  49. package/lib/shared/folders/resolveEntityPath.js +46 -46
  50. package/lib/shared/folders/resolveFolderFromPath.js +38 -38
  51. package/lib/shared/generateRequestId.js +4 -4
  52. package/lib/shared/listenerCollection.js +169 -0
  53. package/lib/shared/normalizeMetaFromLogs.js +30 -30
  54. package/lib/shared/reporter.js +123 -123
  55. package/lib/shared/request.js +64 -64
  56. package/lib/shared/tempFilesHandler.js +81 -81
  57. package/lib/shared/templates.js +82 -82
  58. package/lib/static/helpers.js +33 -33
  59. package/lib/worker/blobStorage.js +34 -34
  60. package/lib/worker/defaultProxyExtend.js +46 -46
  61. package/lib/worker/documentStore.js +49 -49
  62. package/lib/worker/extensionsManager.js +17 -17
  63. package/lib/worker/logger.js +48 -48
  64. package/lib/worker/render/diff.js +138 -138
  65. package/lib/worker/render/executeEngine.js +207 -200
  66. package/lib/worker/render/htmlRecipe.js +10 -10
  67. package/lib/worker/render/moduleHelper.js +43 -43
  68. package/lib/worker/render/noneEngine.js +12 -12
  69. package/lib/worker/render/profiler.js +158 -158
  70. package/lib/worker/render/render.js +205 -209
  71. package/lib/worker/render/resolveReferences.js +60 -60
  72. package/lib/worker/reporter.js +191 -187
  73. package/lib/worker/sandbox/runInSandbox.js +13 -4
  74. package/lib/worker/sandbox/safeSandbox.js +828 -822
  75. package/lib/worker/templates.js +78 -78
  76. package/lib/worker/workerHandler.js +54 -54
  77. package/package.json +92 -92
  78. package/test/blobStorage/common.js +21 -21
  79. package/test/store/common.js +1449 -1449
@@ -1,138 +1,138 @@
1
- const jsdiff = require('diff')
2
- const gdiff = new (require('diff-match-patch'))()
3
-
4
- function formatPatch (diff) {
5
- const ret = []
6
- if (diff.oldFileName === diff.newFileName) {
7
- ret.push('Index: ' + diff.oldFileName)
8
- }
9
- ret.push('===================================================================')
10
- ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader))
11
- ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader))
12
-
13
- for (let i = 0; i < diff.hunks.length; i++) {
14
- const hunk = diff.hunks[i]
15
- ret.push(
16
- '@@ -' + hunk.oldStart + ',' + hunk.oldLines +
17
- ' +' + hunk.newStart + ',' + hunk.newLines +
18
- ' @@'
19
- )
20
- ret.push.apply(ret, hunk.lines)
21
- }
22
-
23
- const res = ret.join('\n') + '\n'
24
- return res
25
- }
26
-
27
- function createPatch (name, older, newer, context) {
28
- const { chars1, chars2, lineArray } = gdiff.diff_linesToChars_(older, newer)
29
- const cdiff = gdiff.diff_main(chars1, chars2, false)
30
- gdiff.diff_charsToLines_(cdiff, lineArray)
31
-
32
- const diff = cdiff.map(([op, data]) => {
33
- const r = { value: data }
34
- if (op === 1) {
35
- r.added = true
36
- }
37
- if (op === -1) {
38
- r.removed = true
39
- }
40
- return r
41
- })
42
-
43
- diff.push({ value: '', lines: [] }) // Append an empty value to make cleanup easier
44
-
45
- function contextLines (lines) {
46
- return lines.map(function (entry) { return ' ' + entry })
47
- }
48
-
49
- const hunks = []
50
- let oldRangeStart = 0
51
- let newRangeStart = 0
52
- let curRange = []
53
-
54
- let oldLine = 1; let newLine = 1
55
- for (let i = 0; i < diff.length; i++) {
56
- const current = diff[i]
57
-
58
- const lines = current.lines || current.value.replace(/\n$/, '').split('\n')
59
- current.lines = lines
60
-
61
- if (current.added || current.removed) {
62
- // If we have previous context, start with that
63
- if (!oldRangeStart) {
64
- const prev = diff[i - 1]
65
- oldRangeStart = oldLine
66
- newRangeStart = newLine
67
-
68
- if (prev) {
69
- curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : []
70
- oldRangeStart -= curRange.length
71
- newRangeStart -= curRange.length
72
- }
73
- }
74
-
75
- // Output our changes
76
- curRange.push(...lines.map(function (entry) {
77
- return (current.added ? '+' : '-') + entry
78
- }))
79
-
80
- // Track the updated file position
81
- if (current.added) {
82
- newLine += lines.length
83
- } else {
84
- oldLine += lines.length
85
- }
86
- } else {
87
- // Identical context lines. Track line changes
88
- if (oldRangeStart) {
89
- // Close out any changes that have been output (or join overlapping)
90
- if (lines.length <= context * 2 && i < diff.length - 2) {
91
- // Overlapping
92
- curRange.push(...contextLines(lines))
93
- } else {
94
- // end the range and output
95
- const contextSize = Math.min(lines.length, context)
96
- curRange.push(...contextLines(lines.slice(0, contextSize)))
97
-
98
- const hunk = {
99
- oldStart: oldRangeStart,
100
- oldLines: (oldLine - oldRangeStart + contextSize),
101
- newStart: newRangeStart,
102
- newLines: (newLine - newRangeStart + contextSize),
103
- lines: curRange
104
- }
105
- if (i >= diff.length - 2 && lines.length <= context) {
106
- // EOF is inside this hunk
107
- const oldEOFNewline = (/\n$/.test(older))
108
- const newEOFNewline = (/\n$/.test(newer))
109
- const noNlBeforeAdds = lines.length === 0 && curRange.length > hunk.oldLines
110
- if (!oldEOFNewline && noNlBeforeAdds) {
111
- // special case: old has no eol and no trailing context; no-nl can end up before adds
112
- curRange.splice(hunk.oldLines, 0, '\')
113
- }
114
- if ((!oldEOFNewline && !noNlBeforeAdds) || !newEOFNewline) {
115
- curRange.push('\')
116
- }
117
- }
118
- hunks.push(hunk)
119
-
120
- oldRangeStart = 0
121
- newRangeStart = 0
122
- curRange = []
123
- }
124
- }
125
- oldLine += lines.length
126
- newLine += lines.length
127
- }
128
- }
129
-
130
- return formatPatch({
131
- oldFileName: name,
132
- newFileName: name,
133
- hunks: hunks
134
- })
135
- }
136
-
137
- module.exports.applyPatch = (prev, patch) => jsdiff.applyPatch(prev, patch)
138
- module.exports.createPatch = createPatch
1
+ const jsdiff = require('diff')
2
+ const gdiff = new (require('diff-match-patch'))()
3
+
4
+ function formatPatch (diff) {
5
+ const ret = []
6
+ if (diff.oldFileName === diff.newFileName) {
7
+ ret.push('Index: ' + diff.oldFileName)
8
+ }
9
+ ret.push('===================================================================')
10
+ ret.push('--- ' + diff.oldFileName + (typeof diff.oldHeader === 'undefined' ? '' : '\t' + diff.oldHeader))
11
+ ret.push('+++ ' + diff.newFileName + (typeof diff.newHeader === 'undefined' ? '' : '\t' + diff.newHeader))
12
+
13
+ for (let i = 0; i < diff.hunks.length; i++) {
14
+ const hunk = diff.hunks[i]
15
+ ret.push(
16
+ '@@ -' + hunk.oldStart + ',' + hunk.oldLines +
17
+ ' +' + hunk.newStart + ',' + hunk.newLines +
18
+ ' @@'
19
+ )
20
+ ret.push.apply(ret, hunk.lines)
21
+ }
22
+
23
+ const res = ret.join('\n') + '\n'
24
+ return res
25
+ }
26
+
27
+ function createPatch (name, older, newer, context) {
28
+ const { chars1, chars2, lineArray } = gdiff.diff_linesToChars_(older, newer)
29
+ const cdiff = gdiff.diff_main(chars1, chars2, false)
30
+ gdiff.diff_charsToLines_(cdiff, lineArray)
31
+
32
+ const diff = cdiff.map(([op, data]) => {
33
+ const r = { value: data }
34
+ if (op === 1) {
35
+ r.added = true
36
+ }
37
+ if (op === -1) {
38
+ r.removed = true
39
+ }
40
+ return r
41
+ })
42
+
43
+ diff.push({ value: '', lines: [] }) // Append an empty value to make cleanup easier
44
+
45
+ function contextLines (lines) {
46
+ return lines.map(function (entry) { return ' ' + entry })
47
+ }
48
+
49
+ const hunks = []
50
+ let oldRangeStart = 0
51
+ let newRangeStart = 0
52
+ let curRange = []
53
+
54
+ let oldLine = 1; let newLine = 1
55
+ for (let i = 0; i < diff.length; i++) {
56
+ const current = diff[i]
57
+
58
+ const lines = current.lines || current.value.replace(/\n$/, '').split('\n')
59
+ current.lines = lines
60
+
61
+ if (current.added || current.removed) {
62
+ // If we have previous context, start with that
63
+ if (!oldRangeStart) {
64
+ const prev = diff[i - 1]
65
+ oldRangeStart = oldLine
66
+ newRangeStart = newLine
67
+
68
+ if (prev) {
69
+ curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : []
70
+ oldRangeStart -= curRange.length
71
+ newRangeStart -= curRange.length
72
+ }
73
+ }
74
+
75
+ // Output our changes
76
+ curRange.push(...lines.map(function (entry) {
77
+ return (current.added ? '+' : '-') + entry
78
+ }))
79
+
80
+ // Track the updated file position
81
+ if (current.added) {
82
+ newLine += lines.length
83
+ } else {
84
+ oldLine += lines.length
85
+ }
86
+ } else {
87
+ // Identical context lines. Track line changes
88
+ if (oldRangeStart) {
89
+ // Close out any changes that have been output (or join overlapping)
90
+ if (lines.length <= context * 2 && i < diff.length - 2) {
91
+ // Overlapping
92
+ curRange.push(...contextLines(lines))
93
+ } else {
94
+ // end the range and output
95
+ const contextSize = Math.min(lines.length, context)
96
+ curRange.push(...contextLines(lines.slice(0, contextSize)))
97
+
98
+ const hunk = {
99
+ oldStart: oldRangeStart,
100
+ oldLines: (oldLine - oldRangeStart + contextSize),
101
+ newStart: newRangeStart,
102
+ newLines: (newLine - newRangeStart + contextSize),
103
+ lines: curRange
104
+ }
105
+ if (i >= diff.length - 2 && lines.length <= context) {
106
+ // EOF is inside this hunk
107
+ const oldEOFNewline = (/\n$/.test(older))
108
+ const newEOFNewline = (/\n$/.test(newer))
109
+ const noNlBeforeAdds = lines.length === 0 && curRange.length > hunk.oldLines
110
+ if (!oldEOFNewline && noNlBeforeAdds) {
111
+ // special case: old has no eol and no trailing context; no-nl can end up before adds
112
+ curRange.splice(hunk.oldLines, 0, '\')
113
+ }
114
+ if ((!oldEOFNewline && !noNlBeforeAdds) || !newEOFNewline) {
115
+ curRange.push('\')
116
+ }
117
+ }
118
+ hunks.push(hunk)
119
+
120
+ oldRangeStart = 0
121
+ newRangeStart = 0
122
+ curRange = []
123
+ }
124
+ }
125
+ oldLine += lines.length
126
+ newLine += lines.length
127
+ }
128
+ }
129
+
130
+ return formatPatch({
131
+ oldFileName: name,
132
+ newFileName: name,
133
+ hunks: hunks
134
+ })
135
+ }
136
+
137
+ module.exports.applyPatch = (prev, patch) => jsdiff.applyPatch(prev, patch)
138
+ module.exports.createPatch = createPatch