@ironcode/vas-lib 0.0.39 → 0.0.41

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 (42) hide show
  1. package/cjs/lib/entity/vas-file.dto.d.ts +2 -1
  2. package/cjs/lib/entity/vas-file.dto.d.ts.map +1 -1
  3. package/cjs/lib/entity/vas-file.dto.js.map +1 -1
  4. package/cjs/lib/entity/vas-file.model.d.ts +3 -3
  5. package/cjs/lib/entity/vas-file.model.d.ts.map +1 -1
  6. package/cjs/lib/entity/vas-file.model.js +2 -2
  7. package/cjs/lib/entity/vas-file.model.js.map +1 -1
  8. package/cjs/lib/entity/vas-form.dto.d.ts +1 -0
  9. package/cjs/lib/entity/vas-form.dto.d.ts.map +1 -1
  10. package/cjs/lib/entity/vas-form.dto.js.map +1 -1
  11. package/cjs/lib/entity/vas-form.model.d.ts +2 -21
  12. package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
  13. package/cjs/lib/entity/vas-form.model.js +5 -23
  14. package/cjs/lib/entity/vas-form.model.js.map +1 -1
  15. package/cjs/lib/entity/vas-job.model.d.ts +11 -1
  16. package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
  17. package/cjs/lib/entity/vas-job.model.js +48 -1
  18. package/cjs/lib/entity/vas-job.model.js.map +1 -1
  19. package/cjs/lib/entity/vas-job.model.spec-data.d.ts.map +1 -1
  20. package/cjs/lib/entity/vas-job.model.spec-data.js +1 -0
  21. package/cjs/lib/entity/vas-job.model.spec-data.js.map +1 -1
  22. package/cjs/lib/utils/is-array-string.d.ts +2 -0
  23. package/cjs/lib/utils/is-array-string.d.ts.map +1 -0
  24. package/cjs/lib/utils/is-array-string.js +8 -0
  25. package/cjs/lib/utils/is-array-string.js.map +1 -0
  26. package/esm2020/lib/entity/vas-file.dto.mjs +1 -1
  27. package/esm2020/lib/entity/vas-file.model.mjs +3 -3
  28. package/esm2020/lib/entity/vas-form.dto.mjs +1 -1
  29. package/esm2020/lib/entity/vas-form.model.mjs +6 -24
  30. package/esm2020/lib/entity/vas-job.model.mjs +49 -2
  31. package/esm2020/lib/utils/is-array-string.mjs +4 -0
  32. package/fesm2015/ironcode-vas-lib.mjs +56 -26
  33. package/fesm2015/ironcode-vas-lib.mjs.map +1 -1
  34. package/fesm2020/ironcode-vas-lib.mjs +56 -26
  35. package/fesm2020/ironcode-vas-lib.mjs.map +1 -1
  36. package/lib/entity/vas-file.dto.d.ts +2 -1
  37. package/lib/entity/vas-file.model.d.ts +3 -3
  38. package/lib/entity/vas-form.dto.d.ts +1 -0
  39. package/lib/entity/vas-form.model.d.ts +2 -21
  40. package/lib/entity/vas-job.model.d.ts +11 -1
  41. package/lib/utils/is-array-string.d.ts +1 -0
  42. package/package.json +1 -1
@@ -684,10 +684,10 @@ class VasFileModel extends VasJobDataModel {
684
684
  description: '',
685
685
  displayedName: '',
686
686
  rotation: 0
687
- }, '', '', '', '', '');
687
+ }, '', '', '', 'NEW', '');
688
688
  }
689
689
  static fromDto(fileDto) {
690
- return new VasFileModel(fileDto.id || UUID.UUID(), fileDto.created || '', fileDto.serverCreated || '', fileDto.createdBy || '', fileDto.modified || '', fileDto.serverModified || '', fileDto.modifiedBy || '', fileDto.account || '', fileDto.job || '', fileDto.name || '', fileDto.fileSize || 0, fileDto.mimeType || '', fileDto.sequence || 0, VasFileModel.parseConfig(fileDto.config), fileDto.url || '', fileDto.controlPath || '', fileDto.message || '', fileDto.status || '', fileDto.uri || '');
690
+ return new VasFileModel(fileDto.id || UUID.UUID(), fileDto.created || '', fileDto.serverCreated || '', fileDto.createdBy || '', fileDto.modified || '', fileDto.serverModified || '', fileDto.modifiedBy || '', fileDto.account || '', fileDto.job || '', fileDto.name || '', fileDto.fileSize || 0, fileDto.mimeType || '', fileDto.sequence || 0, VasFileModel.parseConfig(fileDto.config), fileDto.url || '', fileDto.controlPath || '', fileDto.message || '', fileDto.status || 'NEW', fileDto.uri || '');
691
691
  }
692
692
  static parseConfig(config = '') {
693
693
  try {
@@ -871,27 +871,7 @@ class VasGroupModel extends VasBaseModel {
871
871
  * VasFormModel
872
872
  */
873
873
  class VasFormModel extends VasRestrictedAccountObjectModel {
874
- /**
875
- * @param {string} id
876
- * @param {string} created
877
- * @param {string} serverCreated
878
- * @param {string} createdBy
879
- * @param {string} modified
880
- * @param {string} serverModified
881
- * @param {string} modifiedBy
882
- * @param {string} account
883
- * @param {string} accessGroup
884
- * @param {string} jobType
885
- * @param {string} title
886
- * @param {string} description
887
- * @param {VasGroupModel[]} groups
888
- * @param {string} dynamicDescriptor
889
- * @param {string} indexName
890
- * @param {string} pipelineName
891
- * @param {string} config
892
- * @param {boolean} geoLocationEnabled
893
- */
894
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, groups, dynamicDescriptor, indexName, pipelineName, config, geoLocationEnabled) {
874
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, groups, dynamicDescriptor, indexName, pipelineName, config, geoLocationEnabled, filesEnabled) {
895
875
  super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup);
896
876
  this.id = id;
897
877
  this.created = created;
@@ -911,6 +891,7 @@ class VasFormModel extends VasRestrictedAccountObjectModel {
911
891
  this.pipelineName = pipelineName;
912
892
  this.config = config;
913
893
  this.geoLocationEnabled = geoLocationEnabled;
894
+ this.filesEnabled = filesEnabled;
914
895
  }
915
896
  /**
916
897
  * Returns the name of this form in a "safe" way, i.e. no spaces, special
@@ -953,7 +934,7 @@ class VasFormModel extends VasRestrictedAccountObjectModel {
953
934
  static fromDto(dto) {
954
935
  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 || [])
955
936
  .sort((a, b) => a.sequence - b.sequence)
956
- .map(g => VasGroupModel.fromDto(g)), dto.dynamicDescriptor || '', dto.indexName || '', dto.pipelineName || '', dto.config || '', dto.geoLocationEnabled || false);
937
+ .map(g => VasGroupModel.fromDto(g)), dto.dynamicDescriptor || '', dto.indexName || '', dto.pipelineName || '', dto.config || '', dto.geoLocationEnabled || false, dto.filesEnabled || false);
957
938
  }
958
939
  addControlTypesToControl(controlTypes) {
959
940
  const controlTypeModels = controlTypes
@@ -1059,7 +1040,8 @@ class VasFormModel extends VasRestrictedAccountObjectModel {
1059
1040
  indexName: this.indexName,
1060
1041
  pipelineName: this.pipelineName,
1061
1042
  config: this.config,
1062
- geoLocationEnabled: this.geoLocationEnabled
1043
+ geoLocationEnabled: this.geoLocationEnabled,
1044
+ filesEnabled: this.filesEnabled
1063
1045
  };
1064
1046
  }
1065
1047
  }
@@ -1171,6 +1153,10 @@ const getEmptyGeoLocation = () => ({
1171
1153
  timestamp: ''
1172
1154
  });
1173
1155
 
1156
+ const isArrayString = (value) => {
1157
+ return Array.isArray(value) && value.every(i => typeof i === 'string');
1158
+ };
1159
+
1174
1160
  /**
1175
1161
  * JobModel
1176
1162
  */
@@ -1311,6 +1297,51 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
1311
1297
  }, {});
1312
1298
  return fields;
1313
1299
  }
1300
+ /**
1301
+ * Returns an object describing how many attachments were added to this job
1302
+ * (camera controls and files), and how many have not been uploaded yet.
1303
+ *
1304
+ * @param formModel instance of {@link VasFormModel} that was used when the
1305
+ * job was created
1306
+ */
1307
+ getFilesUploadStatus(formModel) {
1308
+ const pathsWithValue = formModel
1309
+ .getCameraControlPaths()
1310
+ .map(path => {
1311
+ const value = this.getValueByPath(path);
1312
+ if (value && !!value.id) {
1313
+ return path;
1314
+ }
1315
+ return null;
1316
+ })
1317
+ .filter(path => path !== null ? path : null)
1318
+ .filter(isArrayString);
1319
+ let total = pathsWithValue.length;
1320
+ total += this.files.length;
1321
+ // calculate the number of camera images still to upload
1322
+ let pending = pathsWithValue
1323
+ .map(path => this.getValueByPath(path))
1324
+ .map((value) => {
1325
+ if (isFileDto(value)) {
1326
+ return value.id && value.status !== 'COMPLETE';
1327
+ }
1328
+ else if (isCameraControlValueV1(value)) {
1329
+ // if url is not set, it hasn't been uploaded
1330
+ return value.id && !value.url;
1331
+ }
1332
+ return false;
1333
+ })
1334
+ .filter(hasUploaded => hasUploaded)
1335
+ .length;
1336
+ // add total from files that are pending
1337
+ pending += this.files
1338
+ .filter(value => value.status !== 'COMPLETE')
1339
+ .length;
1340
+ return {
1341
+ pending,
1342
+ total
1343
+ };
1344
+ }
1314
1345
  /**
1315
1346
  * This method will hydrate the `fields` property of the model. The reason for
1316
1347
  * this is that we have different ways to store the field data. One way, is
@@ -1420,7 +1451,6 @@ class VasJobModel extends VasRestrictedAccountObjectModel {
1420
1451
  this.fields = fields;
1421
1452
  }
1422
1453
  /**
1423
-
1424
1454
  * @param {string[]} path path segments
1425
1455
  * @return {void}
1426
1456
  */