@ind-rcg/plugins-printengine 246.1010.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.md +37 -0
- package/README.md +7 -0
- package/dist/dev/fonts/LICENSE.txt +202 -0
- package/dist/dev/fonts/Roboto-Italic.ttf +0 -0
- package/dist/dev/fonts/Roboto-Medium.ttf +0 -0
- package/dist/dev/fonts/Roboto-MediumItalic.ttf +0 -0
- package/dist/dev/fonts/Roboto-Regular.ttf +0 -0
- package/dist/dev/printEngine.js +589 -0
- package/dist/dev/src/contractToIntermediateJSONClass.js +1659 -0
- package/dist/dev/src/formatClass.js +156 -0
- package/dist/dev/src/index.js +110 -0
- package/dist/dev/src/localizationClass.js +89 -0
- package/dist/dev/src/logClass.js +38 -0
- package/dist/dev/src/macroHandlerClass.js +132 -0
- package/dist/dev/src/pdfConverterClass.js +1123 -0
- package/dist/dev/src/printEngineParams.js +124 -0
- package/dist/dev/src/tableCellIdentifier.js +116 -0
- package/dist/dev/src/togglesClass.js +61 -0
- package/dist/prod/printEngine.js +2 -0
- package/dist/prod/printEngine.js.LICENSE.txt +50 -0
- package/package.json +79 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* FILE_HEADER
|
|
3
|
+
*/
|
|
4
|
+
"use strict";
|
|
5
|
+
const _ = require('lodash');
|
|
6
|
+
const ClassLocalization = require('./localizationClass');
|
|
7
|
+
const ClassToggles = require('./togglesClass');
|
|
8
|
+
const STORAGE_KEYS = {
|
|
9
|
+
"BOS": "BOS",
|
|
10
|
+
"LOCALIZATION": "LOCALIZATION",
|
|
11
|
+
"IMAGES": "IMAGES",
|
|
12
|
+
"TOGGLES":"TOGGLES",
|
|
13
|
+
"METADATA": "METADATA"
|
|
14
|
+
};
|
|
15
|
+
Object.freeze(STORAGE_KEYS);
|
|
16
|
+
|
|
17
|
+
const METADATA_KEYS = {
|
|
18
|
+
"LOCALE": "locale",
|
|
19
|
+
"WATERMARK": "watermark",
|
|
20
|
+
"AUTOMATIC_PAGEBREAK": "automaticPageBreak"
|
|
21
|
+
};
|
|
22
|
+
Object.freeze(METADATA_KEYS);
|
|
23
|
+
const DATATYPE_ERROR_MSG = "Wrong datatype.";
|
|
24
|
+
|
|
25
|
+
class PrintEngineParams {
|
|
26
|
+
|
|
27
|
+
constructor(bos = {}, images = {}, localization = {}, toggles = new ClassToggles({}), metadata = {}) {
|
|
28
|
+
//Optional parameters for constructor via destructuring assignments including call without parameters.
|
|
29
|
+
this.__checkInputSetBOs(bos);
|
|
30
|
+
this.__checkInputSetImages(images);
|
|
31
|
+
this.__checkInputSetLocalization(localization);
|
|
32
|
+
this.__checkInputSetToggles(toggles);
|
|
33
|
+
this.__checkInputSetMetadata(metadata);
|
|
34
|
+
this.__internalStorage = {};
|
|
35
|
+
this.__internalStorage[STORAGE_KEYS.BOS] = bos;
|
|
36
|
+
this.__internalStorage[STORAGE_KEYS.IMAGES] = images;
|
|
37
|
+
this.__internalStorage[STORAGE_KEYS.LOCALIZATION] = localization;
|
|
38
|
+
this.__internalStorage[STORAGE_KEYS.TOGGLES] = toggles;
|
|
39
|
+
this.__internalStorage[STORAGE_KEYS.METADATA] = metadata;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
__checkInputSetBOs(boDictionary){
|
|
43
|
+
if(!_.isObject(boDictionary) || _.isArray(boDictionary)) {
|
|
44
|
+
throw new Error(DATATYPE_ERROR_MSG);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
setBOs(boDictionary) {
|
|
48
|
+
this.__checkInputSetBOs(boDictionary);
|
|
49
|
+
this.__internalStorage[STORAGE_KEYS.BOS] = boDictionary;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getMetadataKeys(){
|
|
53
|
+
return METADATA_KEYS;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getBOs(){
|
|
57
|
+
return this.__internalStorage[STORAGE_KEYS.BOS];
|
|
58
|
+
}
|
|
59
|
+
__checkInputSetMetadata(metadataDictionary){
|
|
60
|
+
if(!_.isObject(metadataDictionary) || _.isArray(metadataDictionary)) {
|
|
61
|
+
throw new Error(DATATYPE_ERROR_MSG);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
getMetadata(){
|
|
65
|
+
return this.__internalStorage[STORAGE_KEYS.METADATA];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setMetadata(metadataDictionary) {
|
|
69
|
+
this.__checkInputSetMetadata(metadataDictionary);
|
|
70
|
+
this.__internalStorage[STORAGE_KEYS.METADATA] = metadataDictionary;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
__checkInputSetImages(imageDictionary){
|
|
74
|
+
if(!_.isObject(imageDictionary) || _.isArray(imageDictionary)) {
|
|
75
|
+
throw new Error(DATATYPE_ERROR_MSG);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
setImages(imageDictionary){
|
|
79
|
+
this.__checkInputSetImages(imageDictionary);
|
|
80
|
+
this.__internalStorage[STORAGE_KEYS.IMAGES] = imageDictionary;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getImages(){
|
|
84
|
+
return this.__internalStorage[STORAGE_KEYS.IMAGES];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
__checkInputSetLocalization(localizationDictionary){
|
|
88
|
+
if(!_.isObject(localizationDictionary) || _.isArray(localizationDictionary) ||
|
|
89
|
+
localizationDictionary instanceof ClassLocalization) {
|
|
90
|
+
throw new Error(DATATYPE_ERROR_MSG);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
setLocalization(localizationDictionary){
|
|
94
|
+
this.__checkInputSetLocalization(localizationDictionary);
|
|
95
|
+
this.__internalStorage[STORAGE_KEYS.LOCALIZATION] = localizationDictionary;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getLocalization(){
|
|
99
|
+
return this.__internalStorage[STORAGE_KEYS.LOCALIZATION];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
__checkInputSetToggles(togglesDictionary){
|
|
103
|
+
if(! (togglesDictionary instanceof ClassToggles)) {
|
|
104
|
+
throw new Error(DATATYPE_ERROR_MSG);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
setToggles(togglesDictionary){
|
|
108
|
+
this.__checkInputSetToggles(togglesDictionary);
|
|
109
|
+
this.__internalStorage[STORAGE_KEYS.TOGGLES] = togglesDictionary;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
getToggles(){
|
|
113
|
+
return this.__internalStorage[STORAGE_KEYS.TOGGLES];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
serialize(){
|
|
117
|
+
let storageClone = _.cloneDeep(this.__internalStorage);
|
|
118
|
+
delete storageClone[STORAGE_KEYS.LOCALIZATION];
|
|
119
|
+
storageClone[STORAGE_KEYS.TOGGLES] = storageClone[STORAGE_KEYS.TOGGLES].getToggleBuffer();
|
|
120
|
+
return JSON.stringify(storageClone);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
module.exports = PrintEngineParams;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* FILE_HEADER
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
'use strict';
|
|
6
|
+
const _ = require('lodash');
|
|
7
|
+
|
|
8
|
+
const CELL_TYPE = {
|
|
9
|
+
"STANDARD": "tcid",
|
|
10
|
+
"UNKNOWN" : ""
|
|
11
|
+
};
|
|
12
|
+
Object.freeze(CELL_TYPE);
|
|
13
|
+
|
|
14
|
+
class TableCellIdentifier {
|
|
15
|
+
constructor(type, eachName, listItemIndex, correlatedListItemIndex, columnIndex) {
|
|
16
|
+
|
|
17
|
+
if (!_.isNil(type) && _.isString(type) && !_.isNil(eachName) && _.isString(eachName) &&
|
|
18
|
+
!_.isNil(listItemIndex) && (_.isString(listItemIndex) || _.isInteger(listItemIndex)) &&
|
|
19
|
+
!_.isNil(correlatedListItemIndex) && (_.isString(correlatedListItemIndex) || _.isInteger(correlatedListItemIndex)) &&
|
|
20
|
+
!_.isNil(columnIndex) && (_.isString(columnIndex) || _.isInteger(columnIndex))) {
|
|
21
|
+
|
|
22
|
+
if (type === CELL_TYPE.STANDARD &&_.toInteger(listItemIndex) === -1) {
|
|
23
|
+
this.__type = CELL_TYPE.UNKNOWN;
|
|
24
|
+
} else {
|
|
25
|
+
this.__type = type;
|
|
26
|
+
}
|
|
27
|
+
this.__eachName = _.toString(eachName);
|
|
28
|
+
this.__listItemIndex = _.toInteger(listItemIndex);
|
|
29
|
+
this.__correlatedListItemIndex = _.toInteger(correlatedListItemIndex);
|
|
30
|
+
this.__columnIndex = _.toInteger(columnIndex);
|
|
31
|
+
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error('Error creating TableCellIdentifier.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static create(eachName, listItemIndex, correlatedListItemIndex, columnIndex) {
|
|
39
|
+
return new TableCellIdentifier(CELL_TYPE.STANDARD, eachName, listItemIndex, correlatedListItemIndex, columnIndex);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static getUnknownIdentifier() {
|
|
43
|
+
return new TableCellIdentifier(CELL_TYPE.UNKNOWN ,'', -1, -1, -1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromString(idString) {
|
|
47
|
+
|
|
48
|
+
// sample Id: 'tcid.each1.0.0.0'
|
|
49
|
+
// '{PREFIX}.{eachName}.{listItemIndex}.{correlatedListItemIndex}.{columnIndex}'
|
|
50
|
+
if (!_.isNil(idString) && _.isString(idString) && _.startsWith(idString, CELL_TYPE.STANDARD)) { // || _.startsWith(Id, CELL_TYPE.SUBTOTAL))) {
|
|
51
|
+
|
|
52
|
+
let idSegments = _.split(idString, '.');
|
|
53
|
+
if (!_.isNil(idSegments) && _.isArray(idSegments) && idSegments.length === 5) {
|
|
54
|
+
return new TableCellIdentifier(...idSegments);
|
|
55
|
+
} else {
|
|
56
|
+
throw new Error('Invalid TableCellIdentifier detected.');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
} else {
|
|
60
|
+
// return static tcid...
|
|
61
|
+
return TableCellIdentifier.getUnknownIdentifier();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
isKnown() {
|
|
66
|
+
return !(this.__type === CELL_TYPE.UNKNOWN);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toString() {
|
|
70
|
+
if (!this.isKnown()) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return _.join([this.__type, this.__eachName, this.__listItemIndex, this.__correlatedListItemIndex, this.__columnIndex], '.');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
isFirstMainRowCell() {
|
|
79
|
+
return (this.isKnown() && this.__type === CELL_TYPE.STANDARD && this.__listItemIndex >= 0 && this.__correlatedListItemIndex === -1 && this.__columnIndex === 0);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
isSubsequentMainRowCell() {
|
|
83
|
+
return (this.isKnown() && this.__type === CELL_TYPE.STANDARD && this.__listItemIndex >= 0 && this.__correlatedListItemIndex === -1 && this.__columnIndex > 0);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
isFirstCorrelatedRowCell() {
|
|
87
|
+
return (this.isKnown() && this.__type === CELL_TYPE.STANDARD && this.__listItemIndex >= 0 && this.__correlatedListItemIndex >= 0 && this.__columnIndex === 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
isSubsequentCorrelatedRowCell() {
|
|
91
|
+
return (this.isKnown() && this.__type === CELL_TYPE.STANDARD && this.__listItemIndex >= 0 && this.__correlatedListItemIndex >= 0 && this.__columnIndex > 0);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
sharesMainRow(compareTcid) {
|
|
95
|
+
return (this.__checkTableCellIdentifier(compareTcid) && this.isKnown() && this.__type === compareTcid.__type && this.__listItemIndex === compareTcid.__listItemIndex);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
sharesCorrelatedRow(compareTcid) {
|
|
99
|
+
return (this.__checkTableCellIdentifier(compareTcid) && this.isKnown() && this.sharesMainRow(compareTcid) && this.__correlatedListItemIndex === compareTcid.__correlatedListItemIndex);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
isPreviousCell(compareTcid) {
|
|
103
|
+
return (this.__checkTableCellIdentifier(compareTcid) && this.sharesCorrelatedRow(compareTcid) && this.__columnIndex === compareTcid.__columnIndex + 1);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
belongsToMainRow() {
|
|
107
|
+
return (this.isFirstMainRowCell() || this.isSubsequentMainRowCell());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
__checkTableCellIdentifier(tcid) {
|
|
111
|
+
return (!_.isNil(tcid) && _.isObject(tcid) && _.isFunction(tcid.isKnown) && tcid.isKnown());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
module.exports = TableCellIdentifier;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* FILE_HEADER
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const _ = require('lodash');
|
|
7
|
+
|
|
8
|
+
class Toggles {
|
|
9
|
+
constructor(toggles) {
|
|
10
|
+
if (typeof toggles !== 'object') {
|
|
11
|
+
throw new TypeError("Not a valid toggles object");
|
|
12
|
+
}
|
|
13
|
+
this.__toggles = toggles;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
checkToggleParams(toggleId, toggleValue, toggleField) {
|
|
17
|
+
if (_.isNil(toggleId) || !_.isString(toggleId)) {
|
|
18
|
+
throw new TypeError("Invalid toggle Id parameter");
|
|
19
|
+
}
|
|
20
|
+
if (_.isNil(toggleValue) || !_.isString(toggleValue)) {
|
|
21
|
+
throw new TypeError("Invalid toggle value parameter");
|
|
22
|
+
}
|
|
23
|
+
if (_.isNil(toggleField) || !_.isString(toggleField)) {
|
|
24
|
+
throw new TypeError("Invalid toggle field parameter");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getToggleText(toggleId, toggleValue, toggleField = "shortText") {
|
|
29
|
+
this.checkToggleParams(toggleId, toggleValue, toggleField);
|
|
30
|
+
|
|
31
|
+
if (toggleId.substr(0,3) !== "Dom") {
|
|
32
|
+
toggleId = "Dom" + toggleId;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let toggle = this.__toggles[toggleId];
|
|
36
|
+
|
|
37
|
+
if (_.isNil(toggle)) {
|
|
38
|
+
throw new TypeError("Invalid toggle " + toggleId);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let value = toggle.values[toggleValue];
|
|
42
|
+
|
|
43
|
+
if (_.isNil(value)) {
|
|
44
|
+
throw new TypeError("Invalid toggle value " + toggleValue);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let text = value[toggleField];
|
|
48
|
+
|
|
49
|
+
if (_.isNil(text)) {
|
|
50
|
+
throw new TypeError("Invalid toggle field property " + toggleField);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return text;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
getToggleBuffer(){
|
|
57
|
+
return _.cloneDeep(this.__toggles);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = Toggles;
|