@ironcode/vas-lib 2.2.0 → 3.0.0-alpha.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.
Files changed (114) hide show
  1. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts +2 -0
  2. package/cjs/lib/control-value/vas-camera-control-value.model.d.ts.map +1 -1
  3. package/cjs/lib/control-value/vas-camera-control-value.model.js +10 -0
  4. package/cjs/lib/control-value/vas-camera-control-value.model.js.map +1 -1
  5. package/cjs/lib/entity/index.d.ts +5 -0
  6. package/cjs/lib/entity/index.d.ts.map +1 -1
  7. package/cjs/lib/entity/index.js +5 -0
  8. package/cjs/lib/entity/index.js.map +1 -1
  9. package/cjs/lib/entity/vas-access-group.model.d.ts +27 -0
  10. package/cjs/lib/entity/vas-access-group.model.d.ts.map +1 -0
  11. package/cjs/lib/entity/vas-access-group.model.js +68 -0
  12. package/cjs/lib/entity/vas-access-group.model.js.map +1 -0
  13. package/cjs/lib/entity/vas-contact-type.model.d.ts +27 -0
  14. package/cjs/lib/entity/vas-contact-type.model.d.ts.map +1 -0
  15. package/cjs/lib/entity/vas-contact-type.model.js +68 -0
  16. package/cjs/lib/entity/vas-contact-type.model.js.map +1 -0
  17. package/cjs/lib/entity/vas-control.model.d.ts +4 -4
  18. package/cjs/lib/entity/vas-control.model.d.ts.map +1 -1
  19. package/cjs/lib/entity/vas-control.model.js +1 -1
  20. package/cjs/lib/entity/vas-control.model.js.map +1 -1
  21. package/cjs/lib/entity/vas-field.dto.d.ts +3 -5
  22. package/cjs/lib/entity/vas-field.dto.d.ts.map +1 -1
  23. package/cjs/lib/entity/vas-field.dto.js.map +1 -1
  24. package/cjs/lib/entity/vas-field.model.d.ts +4 -4
  25. package/cjs/lib/entity/vas-field.model.d.ts.map +1 -1
  26. package/cjs/lib/entity/vas-field.model.js.map +1 -1
  27. package/cjs/lib/entity/vas-form.model.d.ts +3 -3
  28. package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
  29. package/cjs/lib/entity/vas-form.model.js +1 -1
  30. package/cjs/lib/entity/vas-form.model.js.map +1 -1
  31. package/cjs/lib/entity/vas-group.model.d.ts +2 -2
  32. package/cjs/lib/entity/vas-group.model.d.ts.map +1 -1
  33. package/cjs/lib/entity/vas-group.model.js.map +1 -1
  34. package/cjs/lib/entity/vas-job-status.d.ts +2 -0
  35. package/cjs/lib/entity/vas-job-status.d.ts.map +1 -1
  36. package/cjs/lib/entity/vas-job-status.js +18 -0
  37. package/cjs/lib/entity/vas-job-status.js.map +1 -1
  38. package/cjs/lib/entity/vas-job-type.model.d.ts +23 -0
  39. package/cjs/lib/entity/vas-job-type.model.d.ts.map +1 -0
  40. package/cjs/lib/entity/vas-job-type.model.js +62 -0
  41. package/cjs/lib/entity/vas-job-type.model.js.map +1 -0
  42. package/cjs/lib/entity/vas-job.dto.d.ts +3 -6
  43. package/cjs/lib/entity/vas-job.dto.d.ts.map +1 -1
  44. package/cjs/lib/entity/vas-job.dto.js.map +1 -1
  45. package/cjs/lib/entity/vas-job.model.d.ts +10 -133
  46. package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
  47. package/cjs/lib/entity/vas-job.model.js +97 -324
  48. package/cjs/lib/entity/vas-job.model.js.map +1 -1
  49. package/cjs/lib/entity/vas-lookup-type.model.d.ts +23 -0
  50. package/cjs/lib/entity/vas-lookup-type.model.d.ts.map +1 -0
  51. package/cjs/lib/entity/vas-lookup-type.model.js +62 -0
  52. package/cjs/lib/entity/vas-lookup-type.model.js.map +1 -0
  53. package/cjs/lib/entity/vas-membership.model.d.ts +2 -0
  54. package/cjs/lib/entity/vas-membership.model.d.ts.map +1 -1
  55. package/cjs/lib/entity/vas-membership.model.js +29 -0
  56. package/cjs/lib/entity/vas-membership.model.js.map +1 -1
  57. package/cjs/lib/entity/vas-task-type.model.d.ts +23 -0
  58. package/cjs/lib/entity/vas-task-type.model.d.ts.map +1 -0
  59. package/cjs/lib/entity/vas-task-type.model.js +62 -0
  60. package/cjs/lib/entity/vas-task-type.model.js.map +1 -0
  61. package/cjs/lib/entity/vas-user.model.d.ts +1 -0
  62. package/cjs/lib/entity/vas-user.model.d.ts.map +1 -1
  63. package/cjs/lib/entity/vas-user.model.js +8 -0
  64. package/cjs/lib/entity/vas-user.model.js.map +1 -1
  65. package/cjs/lib/model/firebase-document-meta.interface.d.ts +6 -0
  66. package/cjs/lib/model/firebase-document-meta.interface.d.ts.map +1 -0
  67. package/cjs/lib/model/firebase-document-meta.interface.js +3 -0
  68. package/cjs/lib/model/firebase-document-meta.interface.js.map +1 -0
  69. package/cjs/lib/model/index.d.ts +1 -0
  70. package/cjs/lib/model/index.d.ts.map +1 -1
  71. package/cjs/lib/model/index.js +1 -0
  72. package/cjs/lib/model/index.js.map +1 -1
  73. package/cjs/lib/utils/get-value-by-path.d.ts +2 -3
  74. package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -1
  75. package/cjs/lib/utils/get-value-by-path.js +1 -1
  76. package/cjs/lib/utils/get-value-by-path.js.map +1 -1
  77. package/cjs/lib/utils/is-plain-object.d.ts +2 -0
  78. package/cjs/lib/utils/is-plain-object.d.ts.map +1 -0
  79. package/cjs/lib/utils/is-plain-object.js +7 -0
  80. package/cjs/lib/utils/is-plain-object.js.map +1 -0
  81. package/cjs/lib/utils/try-json.d.ts +6 -0
  82. package/cjs/lib/utils/try-json.d.ts.map +1 -0
  83. package/cjs/lib/utils/try-json.js +20 -0
  84. package/cjs/lib/utils/try-json.js.map +1 -0
  85. package/fesm2022/ironcode-vas-lib.mjs +556 -349
  86. package/fesm2022/ironcode-vas-lib.mjs.map +1 -1
  87. package/lib/control-value/vas-camera-control-value.model.d.ts +2 -0
  88. package/lib/entity/index.d.ts +5 -0
  89. package/lib/entity/vas-access-group.model.d.ts +26 -0
  90. package/lib/entity/vas-contact-type.model.d.ts +26 -0
  91. package/lib/entity/vas-control.model.d.ts +4 -4
  92. package/lib/entity/vas-field.dto.d.ts +3 -5
  93. package/lib/entity/vas-field.model.d.ts +4 -4
  94. package/lib/entity/vas-form.model.d.ts +3 -3
  95. package/lib/entity/vas-group.model.d.ts +2 -2
  96. package/lib/entity/vas-job-status.d.ts +2 -0
  97. package/lib/entity/vas-job-type.model.d.ts +22 -0
  98. package/lib/entity/vas-job.dto.d.ts +3 -6
  99. package/lib/entity/vas-job.model.d.ts +10 -133
  100. package/lib/entity/vas-lookup-type.model.d.ts +22 -0
  101. package/lib/entity/vas-membership.model.d.ts +2 -0
  102. package/lib/entity/vas-task-type.model.d.ts +22 -0
  103. package/lib/entity/vas-user.model.d.ts +1 -0
  104. package/lib/model/firebase-document-meta.interface.d.ts +5 -0
  105. package/lib/model/index.d.ts +1 -0
  106. package/lib/utils/get-value-by-path.d.ts +2 -3
  107. package/lib/utils/is-plain-object.d.ts +1 -0
  108. package/lib/utils/try-json.d.ts +5 -0
  109. package/package.json +1 -1
  110. package/cjs/lib/entity/vas-job.model.spec-data.d.ts +0 -2
  111. package/cjs/lib/entity/vas-job.model.spec-data.d.ts.map +0 -1
  112. package/cjs/lib/entity/vas-job.model.spec-data.js +0 -29
  113. package/cjs/lib/entity/vas-job.model.spec-data.js.map +0 -1
  114. package/lib/utils/is-array-string.d.ts +0 -1
@@ -8,6 +8,15 @@ function isCameraControlValueV1(object) {
8
8
  && 'url' in object
9
9
  && 'id' in object;
10
10
  }
11
+ function isCameraControlValueV2(object) {
12
+ return object instanceof Object
13
+ && 'id' in object
14
+ && 'name' in object
15
+ && 'fileSize' in object
16
+ && 'mimeType' in object
17
+ && 'sequence' in object
18
+ && 'config' in object;
19
+ }
11
20
 
12
21
  var VasControlConfigDirection;
13
22
  (function (VasControlConfigDirection) {
@@ -720,6 +729,99 @@ class VasAccountObjectModel extends VasBaseModel {
720
729
  }
721
730
  }
722
731
 
732
+ /**
733
+ * Return an object with only the properties specified by key(s)
734
+ *
735
+ * @param obj object to be processed
736
+ * @param omitKey key or array of keys to be kept
737
+ * @param transform optional function used to transform each value
738
+ */
739
+ const only = (obj, omitKey, transform) => {
740
+ const t = transform || ((obj, key) => obj[key]);
741
+ const omitKeys = Array.isArray(omitKey) ? omitKey : [omitKey];
742
+ return Object.keys(obj).reduce((result, key) => {
743
+ if (omitKeys.includes(key)) {
744
+ result[key] = t(obj, key);
745
+ }
746
+ return result;
747
+ }, {});
748
+ };
749
+
750
+ /**
751
+ * VasAccessGroupModel
752
+ */
753
+ class VasAccessGroupModel extends VasAccountObjectModel {
754
+ id;
755
+ created;
756
+ serverCreated;
757
+ createdBy;
758
+ modified;
759
+ serverModified;
760
+ modifiedBy;
761
+ createdByName;
762
+ modifiedByName;
763
+ account;
764
+ title;
765
+ sequence;
766
+ categoryGroups;
767
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, title, sequence, categoryGroups) {
768
+ super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
769
+ this.id = id;
770
+ this.created = created;
771
+ this.serverCreated = serverCreated;
772
+ this.createdBy = createdBy;
773
+ this.modified = modified;
774
+ this.serverModified = serverModified;
775
+ this.modifiedBy = modifiedBy;
776
+ this.createdByName = createdByName;
777
+ this.modifiedByName = modifiedByName;
778
+ this.account = account;
779
+ this.title = title;
780
+ this.sequence = sequence;
781
+ this.categoryGroups = categoryGroups;
782
+ }
783
+ static empty() {
784
+ return new VasAccessGroupModel('', '', '', '', '', '', '', '', '', '', '', 0, []);
785
+ }
786
+ toDto() {
787
+ return {
788
+ id: this.id,
789
+ created: this.created,
790
+ serverCreated: this.serverCreated,
791
+ createdBy: this.createdBy,
792
+ modified: this.modified,
793
+ serverModified: this.serverModified,
794
+ modifiedBy: this.modifiedBy,
795
+ createdByName: this.createdByName,
796
+ modifiedByName: this.modifiedByName,
797
+ account: this.account,
798
+ title: this.title,
799
+ sequence: this.sequence,
800
+ categoryGroups: this.categoryGroups,
801
+ };
802
+ }
803
+ static fromDto(dto) {
804
+ return new VasAccessGroupModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.title || '', dto.sequence || 0, dto.categoryGroups || []);
805
+ }
806
+ static toApiCreateDto(dto) {
807
+ return only(dto, [
808
+ 'id',
809
+ 'created',
810
+ 'modified',
811
+ 'title',
812
+ 'sequence',
813
+ ]);
814
+ }
815
+ static toApiUpdateDto(dto) {
816
+ return only(dto, [
817
+ 'created',
818
+ 'modified',
819
+ 'title',
820
+ 'sequence',
821
+ ]);
822
+ }
823
+ }
824
+
723
825
  var VasAccountIndexingMode;
724
826
  (function (VasAccountIndexingMode) {
725
827
  VasAccountIndexingMode[VasAccountIndexingMode["DISABLED"] = 0] = "DISABLED";
@@ -856,22 +958,79 @@ class VasBranchModel extends VasRestrictedAccountObjectModel {
856
958
  }
857
959
 
858
960
  /**
859
- * Return an object with only the properties specified by key(s)
860
- *
861
- * @param obj object to be processed
862
- * @param omitKey key or array of keys to be kept
863
- * @param transform optional function used to transform each value
961
+ * VasContactTypeModel
864
962
  */
865
- const only = (obj, omitKey, transform) => {
866
- const t = transform || ((obj, key) => obj[key]);
867
- const omitKeys = Array.isArray(omitKey) ? omitKey : [omitKey];
868
- return Object.keys(obj).reduce((result, key) => {
869
- if (omitKeys.includes(key)) {
870
- result[key] = t(obj, key);
871
- }
872
- return result;
873
- }, {});
874
- };
963
+ class VasContactTypeModel extends VasAccountObjectModel {
964
+ id;
965
+ created;
966
+ serverCreated;
967
+ createdBy;
968
+ modified;
969
+ serverModified;
970
+ modifiedBy;
971
+ createdByName;
972
+ modifiedByName;
973
+ account;
974
+ title;
975
+ sequence;
976
+ categoryGroups;
977
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, title, sequence, categoryGroups) {
978
+ super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
979
+ this.id = id;
980
+ this.created = created;
981
+ this.serverCreated = serverCreated;
982
+ this.createdBy = createdBy;
983
+ this.modified = modified;
984
+ this.serverModified = serverModified;
985
+ this.modifiedBy = modifiedBy;
986
+ this.createdByName = createdByName;
987
+ this.modifiedByName = modifiedByName;
988
+ this.account = account;
989
+ this.title = title;
990
+ this.sequence = sequence;
991
+ this.categoryGroups = categoryGroups;
992
+ }
993
+ static empty() {
994
+ return new VasContactTypeModel('', '', '', '', '', '', '', '', '', '', '', 0, []);
995
+ }
996
+ toDto() {
997
+ return {
998
+ id: this.id,
999
+ created: this.created,
1000
+ serverCreated: this.serverCreated,
1001
+ createdBy: this.createdBy,
1002
+ modified: this.modified,
1003
+ serverModified: this.serverModified,
1004
+ modifiedBy: this.modifiedBy,
1005
+ createdByName: this.createdByName,
1006
+ modifiedByName: this.modifiedByName,
1007
+ account: this.account,
1008
+ title: this.title,
1009
+ sequence: this.sequence,
1010
+ categoryGroups: this.categoryGroups,
1011
+ };
1012
+ }
1013
+ static fromDto(dto) {
1014
+ return new VasContactTypeModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.title || '', dto.sequence || 0, dto.categoryGroups || []);
1015
+ }
1016
+ static toApiCreateDto(dto) {
1017
+ return only(dto, [
1018
+ 'id',
1019
+ 'created',
1020
+ 'modified',
1021
+ 'title',
1022
+ 'sequence',
1023
+ ]);
1024
+ }
1025
+ static toApiUpdateDto(dto) {
1026
+ return only(dto, [
1027
+ 'created',
1028
+ 'modified',
1029
+ 'title',
1030
+ 'sequence',
1031
+ ]);
1032
+ }
1033
+ }
875
1034
 
876
1035
  class VasContactModel extends VasRestrictedAccountObjectModel {
877
1036
  id;
@@ -1191,7 +1350,7 @@ class VasControlModel extends VasRestrictedAccountObjectModel {
1191
1350
  }
1192
1351
  /**
1193
1352
  * @param {any} value the value to be parsed
1194
- * @return {VasFieldDtoValue} the parsed value
1353
+ * @return {FieldValueType} the parsed value
1195
1354
  */
1196
1355
  parseMaybeJson(value) {
1197
1356
  if (typeof value !== 'string') {
@@ -1647,6 +1806,13 @@ class VasUserModel extends VasBaseModel {
1647
1806
  instructionProviders: this.instructionProviders
1648
1807
  };
1649
1808
  }
1809
+ static toApiPatchDto(dto) {
1810
+ return only(dto, [
1811
+ 'created',
1812
+ 'modified',
1813
+ 'name',
1814
+ ]);
1815
+ }
1650
1816
  }
1651
1817
 
1652
1818
  class VasFireUserModel extends VasUserModel {
@@ -2093,7 +2259,7 @@ class VasFormModel extends VasRestrictedAccountObjectModel {
2093
2259
  }
2094
2260
  /**
2095
2261
  * @param {VasJobModel} jobModel
2096
- * @return {Array<{id: string, value: VasFieldDtoValue}>}
2262
+ * @return {Array<{id: string, value: FieldValueType}>}
2097
2263
  */
2098
2264
  getValuesByControlId(jobModel) {
2099
2265
  const items = [];
@@ -3004,6 +3170,92 @@ class VasJobStatusModel extends VasAccountObjectModel {
3004
3170
  closed: this.closed,
3005
3171
  };
3006
3172
  }
3173
+ static toApiCreateDto(dto) {
3174
+ return only(dto, [
3175
+ 'id',
3176
+ 'created',
3177
+ 'modified',
3178
+ 'title',
3179
+ 'sequence',
3180
+ ]);
3181
+ }
3182
+ static toApiUpdateDto(dto) {
3183
+ return only(dto, [
3184
+ 'created',
3185
+ 'modified',
3186
+ 'title',
3187
+ 'sequence',
3188
+ ]);
3189
+ }
3190
+ }
3191
+
3192
+ class VasJobTypeModel extends VasAccountObjectModel {
3193
+ id;
3194
+ created;
3195
+ serverCreated;
3196
+ createdBy;
3197
+ modified;
3198
+ serverModified;
3199
+ modifiedBy;
3200
+ createdByName;
3201
+ modifiedByName;
3202
+ account;
3203
+ title;
3204
+ sequence;
3205
+ categoryGroups;
3206
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, title, sequence, categoryGroups) {
3207
+ super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
3208
+ this.id = id;
3209
+ this.created = created;
3210
+ this.serverCreated = serverCreated;
3211
+ this.createdBy = createdBy;
3212
+ this.modified = modified;
3213
+ this.serverModified = serverModified;
3214
+ this.modifiedBy = modifiedBy;
3215
+ this.createdByName = createdByName;
3216
+ this.modifiedByName = modifiedByName;
3217
+ this.account = account;
3218
+ this.title = title;
3219
+ this.sequence = sequence;
3220
+ this.categoryGroups = categoryGroups;
3221
+ }
3222
+ static fromDto(dto) {
3223
+ return new VasJobTypeModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.title || '', dto.sequence || 0, dto.categoryGroups || []);
3224
+ }
3225
+ toDto() {
3226
+ return {
3227
+ id: this.id,
3228
+ created: this.created,
3229
+ serverCreated: this.serverCreated,
3230
+ createdBy: this.createdBy,
3231
+ modified: this.modified,
3232
+ serverModified: this.serverModified,
3233
+ modifiedBy: this.modifiedBy,
3234
+ createdByName: this.createdByName,
3235
+ modifiedByName: this.modifiedByName,
3236
+ account: this.account,
3237
+ title: this.title,
3238
+ sequence: this.sequence,
3239
+ categoryGroups: this.categoryGroups,
3240
+ };
3241
+ }
3242
+ static toApiCreateDto(dto) {
3243
+ return only(dto, [
3244
+ 'id',
3245
+ 'created',
3246
+ 'modified',
3247
+ 'title',
3248
+ 'sequence',
3249
+ ]);
3250
+ }
3251
+ static toApiUpdateDto(dto) {
3252
+ return only(dto, [
3253
+ 'created',
3254
+ 'modified',
3255
+ 'title',
3256
+ 'sequence',
3257
+ ]);
3258
+ }
3007
3259
  }
3008
3260
 
3009
3261
  /**
@@ -3020,7 +3272,7 @@ class VasJobStatusModel extends VasAccountObjectModel {
3020
3272
  *
3021
3273
  * will return "value"
3022
3274
  * @param {string[]} path
3023
- * @param {Record<string, VasFieldDtoValue>} object
3275
+ * @param {Record<string, FieldValueType>} object
3024
3276
  * @return {T | undefined}
3025
3277
  */
3026
3278
  const getValueByPath = (path, object) => {
@@ -3082,16 +3334,39 @@ const getEmptyGeoLocation = () => ({
3082
3334
  timestamp: ''
3083
3335
  });
3084
3336
 
3085
- const isArrayString = (value) => {
3086
- return Array.isArray(value) && value.every(i => typeof i === 'string');
3087
- };
3088
-
3089
3337
  /**
3090
- * JobModel
3338
+ * Try to parse the value as JSON if it looks like a JSON encoded string
3339
+ * @param value
3091
3340
  */
3092
- class VasJobModel extends VasRestrictedAccountObjectModel {
3093
- id;
3094
- created;
3341
+ const tryJson = (value) => {
3342
+ if (typeof value === 'string' && ['{', '['].includes(value.substring(0, 1))) {
3343
+ try {
3344
+ return JSON.parse(value);
3345
+ }
3346
+ catch (e) {
3347
+ return value;
3348
+ }
3349
+ }
3350
+ return value;
3351
+ };
3352
+
3353
+ function isPlainObject(value) {
3354
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
3355
+ }
3356
+
3357
+ let jobStaticProps;
3358
+ function getJobStaticProperties() {
3359
+ if (jobStaticProps) {
3360
+ return jobStaticProps;
3361
+ }
3362
+ return jobStaticProps = new Set(Object.getOwnPropertyNames(VasJobModel.empty()));
3363
+ }
3364
+ /**
3365
+ * JobModel
3366
+ */
3367
+ class VasJobModel extends VasRestrictedAccountObjectModel {
3368
+ id;
3369
+ created;
3095
3370
  serverCreated;
3096
3371
  createdBy;
3097
3372
  modified;
@@ -3111,8 +3386,6 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3111
3386
  pendingFields;
3112
3387
  childModified;
3113
3388
  version;
3114
- createdByDisplayName;
3115
- modifiedByDisplayName;
3116
3389
  geoLocation;
3117
3390
  files;
3118
3391
  fields;
@@ -3121,7 +3394,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3121
3394
  reports;
3122
3395
  tasks;
3123
3396
  instruction;
3124
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, reference, jobDate, jobStatus, jobType, assigneeId, formId, timeZoneOffset, pendingFields, childModified, version, createdByDisplayName, modifiedByDisplayName, geoLocation, files, fields, jobEmails, notes, reports, tasks, instruction) {
3397
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, reference, jobDate, jobStatus, jobType, assigneeId, formId, timeZoneOffset, pendingFields, childModified, version, geoLocation, files, fields, jobEmails, notes, reports, tasks, instruction) {
3125
3398
  super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
3126
3399
  this.id = id;
3127
3400
  this.created = created;
@@ -3144,8 +3417,6 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3144
3417
  this.pendingFields = pendingFields;
3145
3418
  this.childModified = childModified;
3146
3419
  this.version = version;
3147
- this.createdByDisplayName = createdByDisplayName;
3148
- this.modifiedByDisplayName = modifiedByDisplayName;
3149
3420
  this.geoLocation = geoLocation;
3150
3421
  this.files = files;
3151
3422
  this.fields = fields;
@@ -3155,102 +3426,62 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3155
3426
  this.tasks = tasks;
3156
3427
  this.instruction = instruction;
3157
3428
  }
3158
- /**
3159
- * Returns this with the dynamic interface
3160
- * @return {VasJobModelDynamicInterface}
3161
- */
3162
- get $this() {
3163
- return this;
3429
+ get createdByDisplayName() {
3430
+ return this.createdByName;
3164
3431
  }
3165
- /**
3166
- * Returns a list of Job dynamic properties i.e. those that are added by the
3167
- * dynamic forms
3168
- */
3169
- get dynamicProperties() {
3170
- const nativeProps = this.staticProperties;
3171
- return Object
3172
- .getOwnPropertyNames(this)
3173
- .filter(prop => !nativeProps.includes(prop));
3432
+ get modifiedByDisplayName() {
3433
+ return this.modifiedByName;
3174
3434
  }
3175
3435
  /**
3176
- * Returns the list of properties of the Job type
3436
+ * Return the list of Job properties
3177
3437
  */
3178
3438
  get staticProperties() {
3179
- return Object.getOwnPropertyNames(VasJobModel.empty());
3439
+ if (jobStaticProps) {
3440
+ return jobStaticProps;
3441
+ }
3442
+ return jobStaticProps = new Set(Object.getOwnPropertyNames(VasJobModel.empty()));
3180
3443
  }
3181
3444
  /**
3182
3445
  * @return {VasJobModel}
3183
3446
  */
3184
3447
  static empty() {
3185
- return new VasJobModel('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment().utcOffset(), 0, '', 0, '', '', getEmptyGeoLocation(), [], [], [], [], [], [], null);
3448
+ return new VasJobModel('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment().utcOffset(), 0, '', 0, getEmptyGeoLocation(), [], {}, [], [], [], [], null);
3186
3449
  }
3187
3450
  static fromDto(dto) {
3188
- const model = new VasJobModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.reference || '', dto.jobDate || '', dto.jobStatus || '', dto.jobType || '', dto.assigneeId || '', dto.formId || dto.lastForm || '', dto.timeZoneOffset || moment().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.createdByDisplayName || '', dto.modifiedByDisplayName || '', dto.geoLocation || getEmptyGeoLocation(), dto.files || [], dto.fields || [], dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
3189
- const emptyKeys = model.staticProperties;
3190
- Object
3191
- .keys(dto)
3192
- .filter(key => emptyKeys.indexOf(key) === -1)
3193
- .forEach((key) => model.$this[key] = dto[key]);
3194
- return model;
3195
- }
3196
- /**
3197
- * This method will instantiate a new JobModel. The difference with this
3198
- * method of instantiation is that we are coming from a relation frame i.e.
3199
- * the job has a list of {@link VasFieldDto} instead of a Job document.
3200
- *
3201
- */
3202
- static fromRelational(dto, form) {
3203
- const model = new VasJobModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.reference || '', dto.jobDate || '', dto.jobStatus || '', dto.jobType || '', dto.assigneeId || '', dto.formId || '', dto.timeZoneOffset || moment().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.createdByDisplayName || '', dto.modifiedByDisplayName || '', dto.geoLocation || getEmptyGeoLocation(), dto.files || [], dto.fields || [], dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
3204
- form.groups
3205
- .forEach(group => {
3206
- group.controls
3207
- .forEach(control => {
3208
- const field = dto.fields?.find(f => f.control === control.id);
3209
- if (!field) {
3210
- return;
3211
- }
3212
- model.getGroup(group.name)[control.name] = field.value;
3213
- });
3451
+ // we have changed the job model and stopped using the dynamic properties
3452
+ // from form group names to hold fields. Instead, we store a simple object
3453
+ // where the control name (minus the "fields." prefix) is the key, and the
3454
+ // field value is the value. However, we have to cater for data that may
3455
+ // be persisted in the old structure, or an API response where fields is an
3456
+ // array of VasFieldDto.
3457
+ // 1: if dto.fields is already an object, we use the existing value
3458
+ const fields = isPlainObject(dto.fields) ?
3459
+ dto.fields :
3460
+ {};
3461
+ // 2: if dto.fields is an array, we're handling a vas-rest response, we
3462
+ // iterate over the fields and update the fields object.
3463
+ Array.isArray(dto.fields) && dto.fields.forEach((field) => {
3464
+ fields[field.controlName.replace('fields.', '')] = tryJson(field.value);
3214
3465
  });
3215
- return model;
3216
- }
3217
- /**
3218
- * @param {VasFormModel} formModel
3219
- * @return {Record<string, VasFieldDtoValue>}
3220
- */
3221
- getFields(formModel) {
3222
- const fields = {};
3223
- formModel.groups
3224
- .forEach(group => {
3225
- group.controls.forEach(control => {
3226
- (fields)[control.reportTemplateName] =
3227
- this.getValueByPath([group.name, control.name]) || null;
3228
- });
3229
- });
3230
- return fields;
3231
- }
3232
- /**
3233
- * Will return an object whose keys are the names of all fields in the job.
3234
- * This method is similar to `getFields` except that this method will only
3235
- * return values where a value was set, as opposed to `getFields` which will
3236
- * return a value for every control even if no value was set, because it uses
3237
- * the form to drive the logic. Note also this method will return values for
3238
- * any Fields in the fields array.
3239
- * @return {Record<string, VasFieldDtoValue>}
3240
- */
3241
- getFields2() {
3242
- let fields = {};
3243
- this.dynamicProperties
3244
- .forEach((groupName) => {
3466
+ // 3: if `fields` still has no keys, we're restoring a VasJobDto object that
3467
+ // was saved in the old "form-group" style, where dynamic keys are
3468
+ // derived from the form-group names. We'll iterate over those keys, and
3469
+ // update the `fields` object. Once this model is serialized back to a
3470
+ // dto, it will have the new shape.
3471
+ if (Object.keys(fields).length === 0) {
3245
3472
  Object
3246
- .keys(this.$this[groupName])
3247
- .forEach(controlName => {
3248
- fields[controlName] =
3249
- this.getValueByPath([groupName, controlName]) || null;
3473
+ .keys(dto)
3474
+ .filter(key => !getJobStaticProperties().has(key))
3475
+ .forEach(groupName => {
3476
+ Object
3477
+ .keys(dto[groupName])
3478
+ .forEach(controlName => {
3479
+ const cn = controlName.replace('fields.', '');
3480
+ fields[cn] = dto[groupName][cn];
3481
+ });
3250
3482
  });
3251
- }, {});
3252
- this.fields.forEach(field => fields[field.controlName] = field.value);
3253
- return fields;
3483
+ }
3484
+ return new VasJobModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.reference || '', dto.jobDate || '', dto.jobStatus || '', dto.jobType || '', dto.assigneeId || '', dto.formId || dto.lastForm || '', dto.timeZoneOffset || moment().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.geoLocation || getEmptyGeoLocation(), dto.files || [], fields, dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
3254
3485
  }
3255
3486
  /**
3256
3487
  * Returns an object describing how many attachments were added to this job
@@ -3260,22 +3491,12 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3260
3491
  * job was created
3261
3492
  */
3262
3493
  getFilesUploadStatus(formModel) {
3263
- const pathsWithValue = formModel
3264
- .getCameraControlPaths()
3265
- .map(path => {
3266
- const value = this.getValueByPath(path);
3267
- if (value && !!value.id) {
3268
- return path;
3269
- }
3270
- return null;
3271
- })
3272
- .filter(path => path !== null ? path : null)
3273
- .filter(isArrayString);
3274
- let total = pathsWithValue.length;
3275
- total += this.files.length;
3494
+ const cameraFieldValues = Object
3495
+ .values(this.fields)
3496
+ .filter(value => isCameraControlValueV2(value) || isCameraControlValueV1(value));
3497
+ let total = cameraFieldValues.length + this.files.length;
3276
3498
  // calculate the number of camera images still to upload
3277
- let pending = pathsWithValue
3278
- .map(path => this.getValueByPath(path))
3499
+ let pending = cameraFieldValues
3279
3500
  .map((value) => {
3280
3501
  if (isFileDto(value)) {
3281
3502
  return value.id && value.status !== 'COMPLETE';
@@ -3288,218 +3509,51 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3288
3509
  })
3289
3510
  .filter(hasUploaded => hasUploaded)
3290
3511
  .length;
3291
- // add total from files that are pending
3292
- pending += this.files
3293
- .filter(value => value.status !== 'COMPLETE')
3294
- .length;
3512
+ // add count of job.files that are complete
3513
+ pending += this.files.filter(value => value.status !== 'COMPLETE').length;
3295
3514
  return {
3296
3515
  pending,
3297
3516
  total
3298
3517
  };
3299
3518
  }
3300
- /**
3301
- * This method will return the dynamic property from the JobModel that
3302
- * represent a group (from a form).
3303
- *
3304
- * @param name the name of the group
3305
- * @param init if true (default) and group is not found, initialise an empty
3306
- * group, otherwise throw an error
3307
- */
3308
- getGroup(name, init = true) {
3309
- let prop;
3310
- if (this.staticProperties.includes(name)) {
3311
- throw Error(`invalid group name ${name}, not a dynamic property`);
3312
- }
3313
- else if (this.$this[name] === undefined) {
3314
- if (init) {
3315
- prop = this.$this[name] = {};
3316
- }
3317
- else {
3318
- throw Error(`invalid group name ${name}, not found`);
3319
- }
3320
- }
3321
- else {
3322
- prop = this.$this[name];
3323
- if (typeof prop !== 'object') {
3324
- throw Error(`invalid group name ${name}, not an object`);
3325
- }
3326
- }
3327
- return prop;
3328
- }
3329
3519
  /**
3330
3520
  * @param path path segments
3331
3521
  */
3332
3522
  getValueByPath(path = []) {
3333
- return getValueByPath(path, this.$this);
3334
- }
3335
- /**
3336
- * In order to understand why we need this method it is important to
3337
- * understand that within the system, Jobs can be represented in one of two
3338
- * ways, document and relational.
3339
- *
3340
- * The important distinction is how values submitted by a form are stored.
3341
- *
3342
- * Jobs stored as documents (JSON objects) will store user values, as dynamic
3343
- * properties of the document.
3344
- *
3345
- * Whereas, Jobs stored as relational, will store user values in an array of
3346
- * {@link VasFieldDto} objects.
3347
- *
3348
- * Depending on where we are in the system, either one of these approaches can
3349
- * be more useful than the other.
3350
- *
3351
- * This method, assumes that the JobModel has been instantiated from a
3352
- * document representation, and serves to hydrate the fields array. In order
3353
- * to achieve this, knowledge of the {@link VasFormDto} that created the job
3354
- * is required.
3355
- *
3356
- *
3357
- * Job in document representation
3358
- * {
3359
- * id: <guid>,
3360
- * reference: "something"
3361
- * <other static job properties>...
3362
- * foo: {
3363
- * bar: "value"
3364
- * }
3365
- * }
3366
- *
3367
- * Job in relational representation
3368
- * {
3369
- * id: <guid>,
3370
- * reference: "something"
3371
- * <other static job properties>...
3372
- * <will not have dynamic properties>...
3373
- * fields: [
3374
- * {
3375
- * id: <guid>,
3376
- * <other field properties>,
3377
- * value: "value"
3378
- * }
3379
- * ]
3380
- * }
3381
- *
3382
- *
3383
- * @param formModel the VasFormModel that was used to create the job
3384
- * @param controlFieldIdMap This is used to determine the id each field.
3385
- * Either one will be found in the map, or a new one is generated.
3386
- * @param controlNames if a value is provided, it will be used
3387
- * to filter the fields that are returned.
3388
- * @return {Array<VasFieldDto>}
3389
- */
3390
- hydrateFields(formModel, controlFieldIdMap = new Map(), controlNames) {
3391
- const fields = [];
3392
- formModel.groups
3393
- .forEach(group => {
3394
- group.controls.forEach(control => {
3395
- if (!control.name.startsWith('fields.')) {
3396
- return;
3397
- }
3398
- if (controlNames && !controlNames.includes(control.name)) {
3399
- return;
3400
- }
3401
- fields.push(VasFieldModel.fromDto({
3402
- // if the controlId exists in the map, use the associated fieldId,
3403
- // otherwise generate a new id for the field.
3404
- id: controlFieldIdMap.get(control.id) || UUID.UUID(),
3405
- account: this.account,
3406
- job: this.id,
3407
- createdBy: this.createdBy,
3408
- created: this.created,
3409
- modifiedBy: this.modifiedBy,
3410
- modified: this.modified,
3411
- control: control.id,
3412
- value: this.getValueByPath([group.name, control.name])
3413
- }));
3414
- });
3415
- });
3416
- this.fields = fields;
3523
+ return getValueByPath(Array.isArray(path) ? path : path.split('.'), this);
3417
3524
  }
3418
- /**
3419
- * A very non sophisticated way to set values in the job via paths
3420
- *
3421
- * For example:
3422
- *
3423
- * setValueByPath('value', ['foo', 'bar']);
3424
- *
3425
- * will make results in job
3426
- * {
3427
- * foo: {
3428
- * bar: 'value'
3429
- * }
3430
- * }
3431
- *
3432
- * @param value the value to set
3433
- * @param path path segments
3434
- */
3435
- setValueByPath(value, path = []) {
3436
- switch (path.length) {
3437
- case 0: {
3438
- return;
3439
- }
3440
- case 1: {
3441
- this[path[0]] = value;
3442
- return;
3443
- }
3444
- case 2: {
3445
- // eslint-disable-next-line max-len
3446
- this.$this[path[0]][path[1]] = value;
3447
- return;
3448
- }
3449
- case 3: {
3450
- // eslint-disable-next-line max-len
3451
- this.$this[path[0]][path[1]][path[2]] = value;
3452
- return;
3453
- }
3454
- default: {
3455
- throw Error('path has too many segments');
3456
- }
3457
- }
3458
- }
3459
- /**
3460
- * @param staticOnly if true, will only output values for the static
3461
- * properties in the dto
3462
- */
3463
- toDto(staticOnly = false) {
3464
- if (staticOnly) {
3465
- return {
3466
- id: this.id,
3467
- created: this.created,
3468
- createdBy: this.createdBy,
3469
- modified: this.modified,
3470
- modifiedBy: this.modifiedBy,
3471
- serverCreated: this.serverCreated,
3472
- serverModified: this.serverModified,
3473
- createdByName: this.createdByName,
3474
- modifiedByName: this.modifiedByName,
3475
- account: this.account,
3476
- accessGroup: this.accessGroup,
3477
- reference: this.reference,
3478
- jobDate: this.jobDate,
3479
- jobStatus: this.jobStatus,
3480
- jobType: this.jobType,
3481
- assigneeId: this.assigneeId,
3482
- formId: this.formId,
3483
- timeZoneOffset: this.timeZoneOffset,
3484
- pendingFields: this.pendingFields,
3485
- childModified: this.childModified,
3486
- version: this.version,
3487
- createdByDisplayName: this.createdByDisplayName,
3488
- modifiedByDisplayName: this.modifiedByDisplayName,
3489
- geoLocation: this.geoLocation,
3490
- files: this.files,
3491
- fields: this.fields,
3492
- jobEmails: this.jobEmails,
3493
- notes: this.notes,
3494
- reports: this.reports,
3495
- tasks: this.tasks,
3496
- instruction: this.instruction
3497
- };
3498
- }
3499
- const dto = {};
3500
- [...this.staticProperties, ...this.dynamicProperties]
3501
- .forEach(prop => dto[prop] = this.$this[prop]);
3502
- return dto;
3525
+ toDto() {
3526
+ return {
3527
+ id: this.id,
3528
+ created: this.created,
3529
+ createdBy: this.createdBy,
3530
+ modified: this.modified,
3531
+ modifiedBy: this.modifiedBy,
3532
+ serverCreated: this.serverCreated,
3533
+ serverModified: this.serverModified,
3534
+ createdByName: this.createdByName,
3535
+ modifiedByName: this.modifiedByName,
3536
+ account: this.account,
3537
+ accessGroup: this.accessGroup,
3538
+ reference: this.reference,
3539
+ jobDate: this.jobDate,
3540
+ jobStatus: this.jobStatus,
3541
+ jobType: this.jobType,
3542
+ assigneeId: this.assigneeId,
3543
+ formId: this.formId,
3544
+ timeZoneOffset: this.timeZoneOffset,
3545
+ pendingFields: this.pendingFields,
3546
+ childModified: this.childModified,
3547
+ version: this.version,
3548
+ geoLocation: this.geoLocation,
3549
+ files: this.files,
3550
+ fields: this.fields,
3551
+ jobEmails: this.jobEmails,
3552
+ notes: this.notes,
3553
+ reports: this.reports,
3554
+ tasks: this.tasks,
3555
+ instruction: this.instruction
3556
+ };
3503
3557
  }
3504
3558
  /**
3505
3559
  * This method will parse a syntax that allows us to build strings from the
@@ -3533,7 +3587,7 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3533
3587
  if (!value || typeof value !== 'string') {
3534
3588
  return '';
3535
3589
  }
3536
- const fields = this.getFields2();
3590
+ const fields = this.fields;
3537
3591
  return value.replace(/({[^}]*})/g, (match, token) => {
3538
3592
  const syntax = token.substring(1, token.length - 1);
3539
3593
  let [key, filter] = syntax.split('|');
@@ -3559,24 +3613,11 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3559
3613
  if (objectKey === 'job') {
3560
3614
  result = (this.getValueByPath(path) || '').toString();
3561
3615
  }
3562
- else if (objectKey === 'fields') {
3563
- result = (getValueByPath(['fields.' + path.shift(), ...path], fields) || '').toString();
3616
+ else if (objectKey === 'fields' || this.fields[path[0]] !== undefined) {
3617
+ result = (getValueByPath(path, fields) || '').toString();
3564
3618
  }
3565
- else if (objectKey.length) {
3566
- if (options.objects) {
3567
- if (options.objects[objectKey] === undefined) {
3568
- console.debug(`objectKey ${objectKey} is not present in options.object`);
3569
- result = '';
3570
- }
3571
- else {
3572
- result = (getValueByPath(path, options.objects[objectKey]) || '')
3573
- .toString();
3574
- }
3575
- }
3576
- else {
3577
- console.debug(`objectKey ${objectKey} was used but options.object is not set`);
3578
- return '';
3579
- }
3619
+ else if (objectKey.length && options.objects && options.objects[objectKey] !== undefined) {
3620
+ result = (getValueByPath(path, options.objects[objectKey]) || '').toString();
3580
3621
  }
3581
3622
  else {
3582
3623
  return '';
@@ -3631,7 +3672,76 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
3631
3672
  'assigneeId',
3632
3673
  'timeZoneOffset',
3633
3674
  'pendingFields',
3634
- 'lastForm'
3675
+ 'formId'
3676
+ ]);
3677
+ }
3678
+ }
3679
+
3680
+ class VasLookupTypeModel extends VasAccountObjectModel {
3681
+ id;
3682
+ created;
3683
+ serverCreated;
3684
+ createdBy;
3685
+ modified;
3686
+ serverModified;
3687
+ modifiedBy;
3688
+ createdByName;
3689
+ modifiedByName;
3690
+ account;
3691
+ title;
3692
+ sequence;
3693
+ categoryGroups;
3694
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, title, sequence, categoryGroups) {
3695
+ super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
3696
+ this.id = id;
3697
+ this.created = created;
3698
+ this.serverCreated = serverCreated;
3699
+ this.createdBy = createdBy;
3700
+ this.modified = modified;
3701
+ this.serverModified = serverModified;
3702
+ this.modifiedBy = modifiedBy;
3703
+ this.createdByName = createdByName;
3704
+ this.modifiedByName = modifiedByName;
3705
+ this.account = account;
3706
+ this.title = title;
3707
+ this.sequence = sequence;
3708
+ this.categoryGroups = categoryGroups;
3709
+ }
3710
+ static fromDto(dto) {
3711
+ return new VasLookupTypeModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.title || '', dto.sequence || 0, dto.categoryGroups || []);
3712
+ }
3713
+ toDto() {
3714
+ return {
3715
+ id: this.id,
3716
+ created: this.created,
3717
+ serverCreated: this.serverCreated,
3718
+ createdBy: this.createdBy,
3719
+ modified: this.modified,
3720
+ serverModified: this.serverModified,
3721
+ modifiedBy: this.modifiedBy,
3722
+ createdByName: this.createdByName,
3723
+ modifiedByName: this.modifiedByName,
3724
+ account: this.account,
3725
+ title: this.title,
3726
+ sequence: this.sequence,
3727
+ categoryGroups: this.categoryGroups,
3728
+ };
3729
+ }
3730
+ static toApiCreateDto(dto) {
3731
+ return only(dto, [
3732
+ 'id',
3733
+ 'created',
3734
+ 'modified',
3735
+ 'title',
3736
+ 'sequence',
3737
+ ]);
3738
+ }
3739
+ static toApiUpdateDto(dto) {
3740
+ return only(dto, [
3741
+ 'created',
3742
+ 'modified',
3743
+ 'title',
3744
+ 'sequence',
3635
3745
  ]);
3636
3746
  }
3637
3747
  }
@@ -3800,6 +3910,34 @@ class VasMembershipModel extends VasAccountObjectModel {
3800
3910
  taskTypes: this.taskTypes
3801
3911
  };
3802
3912
  }
3913
+ static toApiCreateDto(dto) {
3914
+ return only(dto, [
3915
+ 'id',
3916
+ 'created',
3917
+ 'modified',
3918
+ 'user',
3919
+ 'admin',
3920
+ 'lookupTypes',
3921
+ 'contactTypes',
3922
+ 'accessGroups',
3923
+ 'jobStatuses',
3924
+ 'jobTypes',
3925
+ 'taskTypes',
3926
+ ]);
3927
+ }
3928
+ static toApiUpdateDto(dto) {
3929
+ return only(dto, [
3930
+ 'created',
3931
+ 'modified',
3932
+ 'admin',
3933
+ 'lookupTypes',
3934
+ 'contactTypes',
3935
+ 'accessGroups',
3936
+ 'jobStatuses',
3937
+ 'jobTypes',
3938
+ 'taskTypes',
3939
+ ]);
3940
+ }
3803
3941
  }
3804
3942
 
3805
3943
  class VasReportLayoutModel extends VasRestrictedAccountObjectModel {
@@ -3896,6 +4034,75 @@ class VasReportRequestModel extends VasAccountObjectModel {
3896
4034
  }
3897
4035
  }
3898
4036
 
4037
+ class VasTaskTypeModel extends VasAccountObjectModel {
4038
+ id;
4039
+ created;
4040
+ serverCreated;
4041
+ createdBy;
4042
+ modified;
4043
+ serverModified;
4044
+ modifiedBy;
4045
+ createdByName;
4046
+ modifiedByName;
4047
+ account;
4048
+ title;
4049
+ sequence;
4050
+ categoryGroups;
4051
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, title, sequence, categoryGroups) {
4052
+ super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
4053
+ this.id = id;
4054
+ this.created = created;
4055
+ this.serverCreated = serverCreated;
4056
+ this.createdBy = createdBy;
4057
+ this.modified = modified;
4058
+ this.serverModified = serverModified;
4059
+ this.modifiedBy = modifiedBy;
4060
+ this.createdByName = createdByName;
4061
+ this.modifiedByName = modifiedByName;
4062
+ this.account = account;
4063
+ this.title = title;
4064
+ this.sequence = sequence;
4065
+ this.categoryGroups = categoryGroups;
4066
+ }
4067
+ static fromDto(dto) {
4068
+ return new VasTaskTypeModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.title || '', dto.sequence || 0, dto.categoryGroups || []);
4069
+ }
4070
+ toDto() {
4071
+ return {
4072
+ id: this.id,
4073
+ created: this.created,
4074
+ serverCreated: this.serverCreated,
4075
+ createdBy: this.createdBy,
4076
+ modified: this.modified,
4077
+ serverModified: this.serverModified,
4078
+ modifiedBy: this.modifiedBy,
4079
+ createdByName: this.createdByName,
4080
+ modifiedByName: this.modifiedByName,
4081
+ account: this.account,
4082
+ title: this.title,
4083
+ sequence: this.sequence,
4084
+ categoryGroups: this.categoryGroups,
4085
+ };
4086
+ }
4087
+ static toApiCreateDto(dto) {
4088
+ return only(dto, [
4089
+ 'id',
4090
+ 'created',
4091
+ 'modified',
4092
+ 'title',
4093
+ 'sequence',
4094
+ ]);
4095
+ }
4096
+ static toApiUpdateDto(dto) {
4097
+ return only(dto, [
4098
+ 'created',
4099
+ 'modified',
4100
+ 'title',
4101
+ 'sequence',
4102
+ ]);
4103
+ }
4104
+ }
4105
+
3899
4106
  /**
3900
4107
  * VasTaskModel
3901
4108
  */
@@ -4077,5 +4284,5 @@ class VasVehicleModel extends VasAccountObjectModel {
4077
4284
  * Generated bundle index. Do not edit.
4078
4285
  */
4079
4286
 
4080
- export { VasAccountIndexingMode, VasAccountObjectModel, VasBaseModel, VasBranchModel, VasContactModel, VasControlConfigDirection, VasControlModel, VasControlTypeModel, VasFieldModel, VasFileModel, VasFireUserModel, VasFormConfigModel, VasFormModel, VasGroupModel, VasInstructionJobFieldModel, VasInstructionJobModel, VasInstructionModel, VasInstructionProviderModel, VasInvitationModel, VasInvitationTypeEnum, VasJobActionControlsStepModel, VasJobActionEmailFormStepModel, VasJobActionInstructionStepModel, VasJobActionModel, VasJobActionNotePromptStepModel, VasJobActionSetDatetimeStepModel, VasJobActionSetJobStatusStepModel, VasJobActionSetValueStepModel, VasJobActionWebhookStepModel, VasJobCopyModel, VasJobDataModel, VasJobEmailModel, VasJobModel, VasJobStatusModel, VasLookupModel, VasMembershipModel, VasNoteModel, VasReportLayoutModel, VasReportModel, VasReportRequestModel, VasRestrictedAccountObjectModel, VasTaskModel, VasUserModel, VasVehicleModel, getEmptyGeoLocation, isCameraControlValueV1, isFileDto, isJobAutomationStep, isJobControlsStep, isJobEmailFormStep, isJobInstructionStep, isJobNotePromptStep, isJobSetDatetimeStep, isJobSetJobStatusStep, isJobSetValueStep, isJobWebhookStep, prepareFieldApiValue, stepModelFactory };
4287
+ export { VasAccessGroupModel, VasAccountIndexingMode, VasAccountObjectModel, VasBaseModel, VasBranchModel, VasContactModel, VasContactTypeModel, VasControlConfigDirection, VasControlModel, VasControlTypeModel, VasFieldModel, VasFileModel, VasFireUserModel, VasFormConfigModel, VasFormModel, VasGroupModel, VasInstructionJobFieldModel, VasInstructionJobModel, VasInstructionModel, VasInstructionProviderModel, VasInvitationModel, VasInvitationTypeEnum, VasJobActionControlsStepModel, VasJobActionEmailFormStepModel, VasJobActionInstructionStepModel, VasJobActionModel, VasJobActionNotePromptStepModel, VasJobActionSetDatetimeStepModel, VasJobActionSetJobStatusStepModel, VasJobActionSetValueStepModel, VasJobActionWebhookStepModel, VasJobCopyModel, VasJobDataModel, VasJobEmailModel, VasJobModel, VasJobStatusModel, VasJobTypeModel, VasLookupModel, VasLookupTypeModel, VasMembershipModel, VasNoteModel, VasReportLayoutModel, VasReportModel, VasReportRequestModel, VasRestrictedAccountObjectModel, VasTaskModel, VasTaskTypeModel, VasUserModel, VasVehicleModel, getEmptyGeoLocation, isCameraControlValueV1, isCameraControlValueV2, isFileDto, isJobAutomationStep, isJobControlsStep, isJobEmailFormStep, isJobInstructionStep, isJobNotePromptStep, isJobSetDatetimeStep, isJobSetJobStatusStep, isJobSetValueStep, isJobWebhookStep, prepareFieldApiValue, stepModelFactory };
4081
4288
  //# sourceMappingURL=ironcode-vas-lib.mjs.map