@ironcode/vas-lib 0.0.9 → 0.0.11
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/cjs/lib/entity/vas-control.model.d.ts +1 -1
- package/cjs/lib/entity/vas-control.model.js +1 -1
- package/cjs/lib/entity/vas-control.model.js.map +1 -1
- package/cjs/lib/entity/vas-form.dto.d.ts +3 -0
- package/cjs/lib/entity/vas-form.dto.d.ts.map +1 -1
- package/cjs/lib/entity/vas-form.dto.js.map +1 -1
- package/cjs/lib/entity/vas-form.model.d.ts +7 -1
- package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-form.model.js +11 -2
- package/cjs/lib/entity/vas-form.model.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.d.ts +14 -27
- package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.js +74 -70
- package/cjs/lib/entity/vas-job.model.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.spec-data.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.spec-data.js +3 -0
- package/cjs/lib/entity/vas-job.model.spec-data.js.map +1 -1
- package/cjs/lib/utils/get-value-by-path.d.ts +20 -0
- package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -0
- package/cjs/lib/utils/get-value-by-path.js +68 -0
- package/cjs/lib/utils/get-value-by-path.js.map +1 -0
- package/esm2020/lib/entity/vas-control.model.mjs +2 -2
- package/esm2020/lib/entity/vas-form.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-form.model.mjs +12 -3
- package/esm2020/lib/entity/vas-job.model.mjs +75 -71
- package/esm2020/lib/utils/get-value-by-path.mjs +64 -0
- package/fesm2015/ironcode-vas-lib.mjs +149 -73
- package/fesm2015/ironcode-vas-lib.mjs.map +1 -1
- package/fesm2020/ironcode-vas-lib.mjs +149 -73
- package/fesm2020/ironcode-vas-lib.mjs.map +1 -1
- package/lib/entity/vas-control.model.d.ts +1 -1
- package/lib/entity/vas-form.dto.d.ts +3 -0
- package/lib/entity/vas-form.model.d.ts +7 -1
- package/lib/entity/vas-job.model.d.ts +14 -27
- package/lib/utils/get-value-by-path.d.ts +19 -0
- package/package.json +1 -1
|
@@ -243,7 +243,7 @@ class VasControlModel extends VasBaseModel {
|
|
|
243
243
|
}
|
|
244
244
|
/**
|
|
245
245
|
* Returns the name of this control to be used in the report templates
|
|
246
|
-
* i.e.
|
|
246
|
+
* i.e. fields.foo -> foo
|
|
247
247
|
* @return {string}
|
|
248
248
|
*/
|
|
249
249
|
get reportTemplateName() {
|
|
@@ -487,8 +487,11 @@ class VasFormModel extends VasBaseModel {
|
|
|
487
487
|
* @param {string} title
|
|
488
488
|
* @param {string} description
|
|
489
489
|
* @param {VasGroupModel[]} groups
|
|
490
|
+
* @param {string} dynamicDescriptor
|
|
491
|
+
* @param {string} indexName
|
|
492
|
+
* @param {string} pipelineName
|
|
490
493
|
*/
|
|
491
|
-
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, groups) {
|
|
494
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, groups, dynamicDescriptor, indexName, pipelineName) {
|
|
492
495
|
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy);
|
|
493
496
|
this.id = id;
|
|
494
497
|
this.created = created;
|
|
@@ -503,6 +506,9 @@ class VasFormModel extends VasBaseModel {
|
|
|
503
506
|
this.title = title;
|
|
504
507
|
this.description = description;
|
|
505
508
|
this.groups = groups;
|
|
509
|
+
this.dynamicDescriptor = dynamicDescriptor;
|
|
510
|
+
this.indexName = indexName;
|
|
511
|
+
this.pipelineName = pipelineName;
|
|
506
512
|
}
|
|
507
513
|
/**
|
|
508
514
|
* Returns the name of this form in a "safe" way, i.e. no spaces, special
|
|
@@ -545,7 +551,7 @@ class VasFormModel extends VasBaseModel {
|
|
|
545
551
|
static fromDto(dto) {
|
|
546
552
|
return new VasFormModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.account || '', dto.accessGroup || '', dto.jobType || '', dto.title || '', dto.description || '', (dto.groups || [])
|
|
547
553
|
.sort((a, b) => a.sequence - b.sequence)
|
|
548
|
-
.map(g => VasGroupModel.fromDto(g)));
|
|
554
|
+
.map(g => VasGroupModel.fromDto(g)), dto.dynamicDescriptor || '', dto.indexName || '', dto.pipelineName || '');
|
|
549
555
|
}
|
|
550
556
|
addControlTypesToControl(controlTypes) {
|
|
551
557
|
const controlTypeModels = controlTypes
|
|
@@ -646,10 +652,77 @@ class VasFormModel extends VasBaseModel {
|
|
|
646
652
|
title: this.title,
|
|
647
653
|
description: this.description,
|
|
648
654
|
groups: this.groups.map(group => group.toDto()),
|
|
655
|
+
dynamicDescriptor: this.dynamicDescriptor,
|
|
656
|
+
indexName: this.indexName,
|
|
657
|
+
pipelineName: this.pipelineName
|
|
649
658
|
};
|
|
650
659
|
}
|
|
651
660
|
}
|
|
652
661
|
|
|
662
|
+
/**
|
|
663
|
+
* A non sophisticated way to get values from the job via paths. For example:
|
|
664
|
+
*
|
|
665
|
+
* getValueByPath(
|
|
666
|
+
* ['foo', 'bar'],
|
|
667
|
+
* {
|
|
668
|
+
* foo: {
|
|
669
|
+
* bar: 'value'
|
|
670
|
+
* }
|
|
671
|
+
* }
|
|
672
|
+
* );
|
|
673
|
+
*
|
|
674
|
+
* will return "value"
|
|
675
|
+
* @param {string[]} path
|
|
676
|
+
* @param {Record<string, VasFieldDtoValue>} object
|
|
677
|
+
* @return {T | undefined}
|
|
678
|
+
*/
|
|
679
|
+
const getValueByPath = (path, object) => {
|
|
680
|
+
switch (path.length) {
|
|
681
|
+
case 0: {
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
case 1: {
|
|
685
|
+
return (object)[path[0]];
|
|
686
|
+
}
|
|
687
|
+
case 2: {
|
|
688
|
+
const val0 = object[path[0]];
|
|
689
|
+
if (!val0) {
|
|
690
|
+
return undefined;
|
|
691
|
+
}
|
|
692
|
+
return val0[path[1]];
|
|
693
|
+
}
|
|
694
|
+
case 3: {
|
|
695
|
+
const val0 = object[path[0]];
|
|
696
|
+
if (!val0) {
|
|
697
|
+
return undefined;
|
|
698
|
+
}
|
|
699
|
+
const val1 = val0[path[1]];
|
|
700
|
+
if (!val1) {
|
|
701
|
+
return undefined;
|
|
702
|
+
}
|
|
703
|
+
return val1[path[2]];
|
|
704
|
+
}
|
|
705
|
+
case 4: {
|
|
706
|
+
const val0 = object[path[0]];
|
|
707
|
+
if (!val0) {
|
|
708
|
+
return undefined;
|
|
709
|
+
}
|
|
710
|
+
const val1 = val0[path[1]];
|
|
711
|
+
if (!val1) {
|
|
712
|
+
return undefined;
|
|
713
|
+
}
|
|
714
|
+
const val2 = val1[path[2]];
|
|
715
|
+
if (!val2) {
|
|
716
|
+
return undefined;
|
|
717
|
+
}
|
|
718
|
+
return val2[path[3]];
|
|
719
|
+
}
|
|
720
|
+
default: {
|
|
721
|
+
throw Error('path has too many segments');
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
|
|
653
726
|
/**
|
|
654
727
|
* JobModel
|
|
655
728
|
*/
|
|
@@ -696,8 +769,6 @@ class VasJobModel extends VasBaseModel {
|
|
|
696
769
|
* @return {VasJobModelDynamicInterface}
|
|
697
770
|
*/
|
|
698
771
|
get $this() {
|
|
699
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
700
|
-
const $this = this;
|
|
701
772
|
return this;
|
|
702
773
|
}
|
|
703
774
|
/**
|
|
@@ -756,69 +827,33 @@ class VasJobModel extends VasBaseModel {
|
|
|
756
827
|
return fields;
|
|
757
828
|
}
|
|
758
829
|
/**
|
|
759
|
-
*
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
830
|
+
* Will return an object whose keys are the names of all fields in the job but
|
|
831
|
+
* with the "fields." part removed. This method is similar to `getFields`
|
|
832
|
+
* except that this method will only return values that are set whereas
|
|
833
|
+
* `getFields` will return a property regardless (because it uses the form to
|
|
834
|
+
* drive the logic)
|
|
835
|
+
* @return {Record<string, VasFieldDtoValue>}
|
|
836
|
+
*/
|
|
837
|
+
getFields2() {
|
|
838
|
+
let fields = {};
|
|
839
|
+
this.dynamicProperties
|
|
840
|
+
.forEach((groupName) => {
|
|
841
|
+
Object
|
|
842
|
+
.keys(this.$this[groupName])
|
|
843
|
+
.forEach(controlName => {
|
|
844
|
+
const controlNameShort = controlName.replace(/fields\./, '');
|
|
845
|
+
fields[controlNameShort] = this.getValueByPath([groupName, controlName]);
|
|
846
|
+
});
|
|
847
|
+
}, {});
|
|
848
|
+
return fields;
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
|
|
774
852
|
* @param {string[]} path path segments
|
|
775
853
|
* @return {void}
|
|
776
854
|
*/
|
|
777
855
|
getValueByPath(path = []) {
|
|
778
|
-
|
|
779
|
-
case 0: {
|
|
780
|
-
return;
|
|
781
|
-
}
|
|
782
|
-
case 1: {
|
|
783
|
-
return (this.$this)[path[0]];
|
|
784
|
-
}
|
|
785
|
-
case 2: {
|
|
786
|
-
const val0 = this.$this[path[0]];
|
|
787
|
-
if (!val0) {
|
|
788
|
-
return undefined;
|
|
789
|
-
}
|
|
790
|
-
return val0[path[1]];
|
|
791
|
-
}
|
|
792
|
-
case 3: {
|
|
793
|
-
const val0 = this.$this[path[0]];
|
|
794
|
-
if (!val0) {
|
|
795
|
-
return undefined;
|
|
796
|
-
}
|
|
797
|
-
const val1 = val0[path[1]];
|
|
798
|
-
if (!val1) {
|
|
799
|
-
return undefined;
|
|
800
|
-
}
|
|
801
|
-
return val1[path[2]];
|
|
802
|
-
}
|
|
803
|
-
case 4: {
|
|
804
|
-
const val0 = this.$this[path[0]];
|
|
805
|
-
if (!val0) {
|
|
806
|
-
return undefined;
|
|
807
|
-
}
|
|
808
|
-
const val1 = val0[path[1]];
|
|
809
|
-
if (!val1) {
|
|
810
|
-
return undefined;
|
|
811
|
-
}
|
|
812
|
-
const val2 = val1[path[2]];
|
|
813
|
-
if (!val2) {
|
|
814
|
-
return undefined;
|
|
815
|
-
}
|
|
816
|
-
return val2[path[3]];
|
|
817
|
-
}
|
|
818
|
-
default: {
|
|
819
|
-
throw Error('path has too many segments');
|
|
820
|
-
}
|
|
821
|
-
}
|
|
856
|
+
return getValueByPath(path, this.$this);
|
|
822
857
|
}
|
|
823
858
|
/**
|
|
824
859
|
* A very non sophisticated way to set values in the job via paths
|
|
@@ -843,7 +878,7 @@ class VasJobModel extends VasBaseModel {
|
|
|
843
878
|
return;
|
|
844
879
|
}
|
|
845
880
|
case 1: {
|
|
846
|
-
|
|
881
|
+
this[path[0]] = value;
|
|
847
882
|
return;
|
|
848
883
|
}
|
|
849
884
|
case 2: {
|
|
@@ -867,14 +902,29 @@ class VasJobModel extends VasBaseModel {
|
|
|
867
902
|
* @return {VasJobDto}
|
|
868
903
|
*/
|
|
869
904
|
toDto(staticOnly = false) {
|
|
870
|
-
const dto = {};
|
|
871
|
-
this.staticProperties
|
|
872
|
-
.forEach(prop => (dto)[prop] = this.$this[prop]);
|
|
873
905
|
if (staticOnly) {
|
|
874
|
-
return
|
|
906
|
+
return {
|
|
907
|
+
id: this.id,
|
|
908
|
+
created: this.created,
|
|
909
|
+
createdBy: this.createdBy,
|
|
910
|
+
modified: this.modified,
|
|
911
|
+
modifiedBy: this.modifiedBy,
|
|
912
|
+
serverCreated: this.serverCreated,
|
|
913
|
+
serverModified: this.serverModified,
|
|
914
|
+
account: this.account,
|
|
915
|
+
accessGroup: this.accessGroup,
|
|
916
|
+
reference: this.reference,
|
|
917
|
+
jobDate: this.jobDate,
|
|
918
|
+
jobStatus: this.jobStatus,
|
|
919
|
+
jobType: this.jobType,
|
|
920
|
+
assignee: this.assignee,
|
|
921
|
+
formId: this.formId,
|
|
922
|
+
timeZoneOffset: this.timeZoneOffset,
|
|
923
|
+
};
|
|
875
924
|
}
|
|
876
|
-
|
|
877
|
-
|
|
925
|
+
const dto = {};
|
|
926
|
+
[...this.staticProperties, ...this.dynamicProperties]
|
|
927
|
+
.forEach(prop => (dto)[prop] = this.$this[prop]);
|
|
878
928
|
return dto;
|
|
879
929
|
}
|
|
880
930
|
/**
|
|
@@ -929,7 +979,33 @@ class VasJobModel extends VasBaseModel {
|
|
|
929
979
|
filterArg = (filterArg || '').trim();
|
|
930
980
|
}
|
|
931
981
|
const path = key.split('.');
|
|
932
|
-
|
|
982
|
+
const objectKey = path.shift() || '';
|
|
983
|
+
let result = '';
|
|
984
|
+
if (objectKey === 'job') {
|
|
985
|
+
result = (this.getValueByPath(path) || '').toString();
|
|
986
|
+
}
|
|
987
|
+
else if (objectKey === 'fields') {
|
|
988
|
+
result = (getValueByPath(path, this.getFields2()) || '').toString();
|
|
989
|
+
}
|
|
990
|
+
else if (objectKey.length) {
|
|
991
|
+
if (options.objects) {
|
|
992
|
+
if (options.objects[objectKey] === undefined) {
|
|
993
|
+
console.debug(`objectKey ${objectKey} is not present in options.object`);
|
|
994
|
+
result = '';
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
result = (getValueByPath(path, options.objects[objectKey]) || '')
|
|
998
|
+
.toString();
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
else {
|
|
1002
|
+
console.debug(`objectKey ${objectKey} was used but options.object is not set`);
|
|
1003
|
+
return '';
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
else {
|
|
1007
|
+
return '';
|
|
1008
|
+
}
|
|
933
1009
|
if (filterName && result) {
|
|
934
1010
|
switch (filterName) {
|
|
935
1011
|
case 'date': {
|
|
@@ -943,7 +1019,7 @@ class VasJobModel extends VasBaseModel {
|
|
|
943
1019
|
}
|
|
944
1020
|
}
|
|
945
1021
|
return result;
|
|
946
|
-
});
|
|
1022
|
+
}).trim();
|
|
947
1023
|
}
|
|
948
1024
|
;
|
|
949
1025
|
}
|