@ironcode/vas-lib 0.0.11 → 0.0.14
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/index.d.ts +6 -0
- package/cjs/lib/entity/index.d.ts.map +1 -1
- package/cjs/lib/entity/index.js +6 -0
- package/cjs/lib/entity/index.js.map +1 -1
- package/cjs/lib/entity/vas-account-config.dto.d.ts +8 -0
- package/cjs/lib/entity/vas-account-config.dto.d.ts.map +1 -0
- package/cjs/lib/entity/vas-account-config.dto.js +3 -0
- package/cjs/lib/entity/vas-account-config.dto.js.map +1 -0
- package/cjs/lib/entity/vas-account-object.model.d.ts +1 -0
- package/cjs/lib/entity/vas-account-object.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-account-object.model.js +7 -0
- package/cjs/lib/entity/vas-account-object.model.js.map +1 -1
- package/cjs/lib/entity/vas-field.dto.d.ts +1 -1
- package/cjs/lib/entity/vas-field.dto.js.map +1 -1
- package/cjs/lib/entity/vas-field.model.d.ts +44 -0
- package/cjs/lib/entity/vas-field.model.d.ts.map +1 -0
- package/cjs/lib/entity/vas-field.model.js +88 -0
- package/cjs/lib/entity/vas-field.model.js.map +1 -0
- package/cjs/lib/entity/vas-file.dto.d.ts +11 -7
- package/cjs/lib/entity/vas-file.dto.d.ts.map +1 -1
- package/cjs/lib/entity/vas-file.dto.js.map +1 -1
- package/cjs/lib/entity/vas-file.model.d.ts +37 -0
- package/cjs/lib/entity/vas-file.model.d.ts.map +1 -0
- package/cjs/lib/entity/vas-file.model.js +102 -0
- package/cjs/lib/entity/vas-file.model.js.map +1 -0
- package/cjs/lib/entity/vas-form-config.dto.d.ts +9 -0
- package/cjs/lib/entity/vas-form-config.dto.d.ts.map +1 -0
- package/cjs/lib/entity/vas-form-config.dto.js +3 -0
- package/cjs/lib/entity/vas-form-config.dto.js.map +1 -0
- package/cjs/lib/entity/vas-form.dto.d.ts +1 -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 +8 -6
- package/cjs/lib/entity/vas-form.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-form.model.js +10 -7
- package/cjs/lib/entity/vas-form.model.js.map +1 -1
- package/cjs/lib/entity/vas-group.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-group.model.js +1 -0
- package/cjs/lib/entity/vas-group.model.js.map +1 -1
- package/cjs/lib/entity/vas-job-data.model.d.ts +28 -0
- package/cjs/lib/entity/vas-job-data.model.d.ts.map +1 -0
- package/cjs/lib/entity/vas-job-data.model.js +34 -0
- package/cjs/lib/entity/vas-job-data.model.js.map +1 -0
- package/cjs/lib/entity/vas-job.dto.d.ts +8 -2
- package/cjs/lib/entity/vas-job.dto.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.dto.js.map +1 -1
- package/cjs/lib/entity/vas-job.model.d.ts +105 -10
- package/cjs/lib/entity/vas-job.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-job.model.js +139 -9
- 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 +1 -0
- package/cjs/lib/entity/vas-job.model.spec-data.js.map +1 -1
- package/cjs/lib/entity/vas-report-layout.model.d.ts +18 -0
- package/cjs/lib/entity/vas-report-layout.model.d.ts.map +1 -0
- package/cjs/lib/entity/vas-report-layout.model.js +24 -0
- package/cjs/lib/entity/vas-report-layout.model.js.map +1 -0
- package/cjs/lib/entity/vas-report-request.dto.d.ts +1 -0
- package/cjs/lib/entity/vas-report-request.dto.d.ts.map +1 -1
- package/cjs/lib/entity/vas-report-request.dto.js.map +1 -1
- package/cjs/lib/entity/vas-report-request.model.d.ts +2 -1
- package/cjs/lib/entity/vas-report-request.model.d.ts.map +1 -1
- package/cjs/lib/entity/vas-report-request.model.js +5 -3
- package/cjs/lib/entity/vas-report-request.model.js.map +1 -1
- package/cjs/package.json +1 -0
- package/esm2020/lib/entity/index.mjs +7 -1
- package/esm2020/lib/entity/vas-account-config.dto.mjs +2 -0
- package/esm2020/lib/entity/vas-account-object.model.mjs +8 -1
- package/esm2020/lib/entity/vas-field.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-field.model.mjs +88 -0
- package/esm2020/lib/entity/vas-file.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-file.model.mjs +104 -0
- package/esm2020/lib/entity/vas-form-config.dto.mjs +2 -0
- package/esm2020/lib/entity/vas-form.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-form.model.mjs +11 -8
- package/esm2020/lib/entity/vas-group.model.mjs +2 -1
- package/esm2020/lib/entity/vas-job-data.model.mjs +30 -0
- package/esm2020/lib/entity/vas-job.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-job.model.mjs +150 -10
- package/esm2020/lib/entity/vas-report-layout.model.mjs +20 -0
- package/esm2020/lib/entity/vas-report-request.dto.mjs +1 -1
- package/esm2020/lib/entity/vas-report-request.model.mjs +6 -4
- package/fesm2015/ironcode-vas-lib.mjs +385 -17
- package/fesm2015/ironcode-vas-lib.mjs.map +1 -1
- package/fesm2020/ironcode-vas-lib.mjs +405 -17
- package/fesm2020/ironcode-vas-lib.mjs.map +1 -1
- package/lib/entity/index.d.ts +6 -0
- package/lib/entity/vas-account-config.dto.d.ts +7 -0
- package/lib/entity/vas-account-object.model.d.ts +1 -0
- package/lib/entity/vas-field.dto.d.ts +1 -1
- package/lib/entity/vas-field.model.d.ts +43 -0
- package/lib/entity/vas-file.dto.d.ts +11 -7
- package/lib/entity/vas-file.model.d.ts +36 -0
- package/lib/entity/vas-form-config.dto.d.ts +8 -0
- package/lib/entity/vas-form.dto.d.ts +1 -0
- package/lib/entity/vas-form.model.d.ts +8 -6
- package/lib/entity/vas-job-data.model.d.ts +27 -0
- package/lib/entity/vas-job.dto.d.ts +8 -2
- package/lib/entity/vas-job.model.d.ts +105 -10
- package/lib/entity/vas-report-layout.model.d.ts +17 -0
- package/lib/entity/vas-report-request.dto.d.ts +1 -0
- package/lib/entity/vas-report-request.model.d.ts +2 -1
- package/package.json +3 -3
|
@@ -45,6 +45,13 @@ class VasAccountObjectModel extends VasBaseModel {
|
|
|
45
45
|
this.modifiedBy = modifiedBy;
|
|
46
46
|
this.account = account;
|
|
47
47
|
}
|
|
48
|
+
toApiDto() {
|
|
49
|
+
return {
|
|
50
|
+
id: this.id,
|
|
51
|
+
created: this.created,
|
|
52
|
+
modified: this.modified
|
|
53
|
+
};
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
class VasRestrictedAccountObjectModel extends VasAccountObjectModel {
|
|
@@ -367,6 +374,213 @@ class VasControlTypeModel extends VasBaseModel {
|
|
|
367
374
|
}
|
|
368
375
|
}
|
|
369
376
|
|
|
377
|
+
/**
|
|
378
|
+
* VasJobDataModel
|
|
379
|
+
*/
|
|
380
|
+
class VasJobDataModel extends VasAccountObjectModel {
|
|
381
|
+
/**
|
|
382
|
+
* @param {string} id
|
|
383
|
+
* @param {string} created
|
|
384
|
+
* @param {string} serverCreated
|
|
385
|
+
* @param {string} createdBy
|
|
386
|
+
* @param {string} modified
|
|
387
|
+
* @param {string} serverModified
|
|
388
|
+
* @param {string} modifiedBy
|
|
389
|
+
* @param {string} account
|
|
390
|
+
* @param {string} job
|
|
391
|
+
*/
|
|
392
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, job) {
|
|
393
|
+
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account);
|
|
394
|
+
this.id = id;
|
|
395
|
+
this.created = created;
|
|
396
|
+
this.serverCreated = serverCreated;
|
|
397
|
+
this.createdBy = createdBy;
|
|
398
|
+
this.modified = modified;
|
|
399
|
+
this.serverModified = serverModified;
|
|
400
|
+
this.modifiedBy = modifiedBy;
|
|
401
|
+
this.account = account;
|
|
402
|
+
this.job = job;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* VasFieldModel
|
|
408
|
+
*/
|
|
409
|
+
class VasFieldModel extends VasJobDataModel {
|
|
410
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, job, control, fieldJobPointers, value, version) {
|
|
411
|
+
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, job);
|
|
412
|
+
this.id = id;
|
|
413
|
+
this.created = created;
|
|
414
|
+
this.serverCreated = serverCreated;
|
|
415
|
+
this.createdBy = createdBy;
|
|
416
|
+
this.modified = modified;
|
|
417
|
+
this.serverModified = serverModified;
|
|
418
|
+
this.modifiedBy = modifiedBy;
|
|
419
|
+
this.account = account;
|
|
420
|
+
this.job = job;
|
|
421
|
+
this.control = control;
|
|
422
|
+
this.fieldJobPointers = fieldJobPointers;
|
|
423
|
+
this.value = value;
|
|
424
|
+
this.version = version;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @param {VasFieldDto} fieldDto
|
|
428
|
+
* @return {VasFieldModel}
|
|
429
|
+
*/
|
|
430
|
+
static fromDto(fieldDto) {
|
|
431
|
+
return new VasFieldModel(fieldDto.id || UUID.UUID(), fieldDto.created || '', fieldDto.serverCreated || '', fieldDto.createdBy || '', fieldDto.modified || '', fieldDto.serverModified || '', fieldDto.modifiedBy || '', fieldDto.account || '', fieldDto.job || '', fieldDto.control || '', fieldDto.fieldJobPointers || [], fieldDto.value || '', fieldDto.version || 0);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* @return {VasFieldDto}
|
|
435
|
+
*/
|
|
436
|
+
toDto() {
|
|
437
|
+
return {
|
|
438
|
+
id: this.id,
|
|
439
|
+
created: this.created,
|
|
440
|
+
serverCreated: this.serverCreated,
|
|
441
|
+
createdBy: this.createdBy,
|
|
442
|
+
modified: this.modified,
|
|
443
|
+
serverModified: this.serverModified,
|
|
444
|
+
modifiedBy: this.modifiedBy,
|
|
445
|
+
account: this.account,
|
|
446
|
+
job: this.job,
|
|
447
|
+
control: this.control,
|
|
448
|
+
fieldJobPointers: this.fieldJobPointers,
|
|
449
|
+
value: this.value,
|
|
450
|
+
version: this.version,
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* @return {object}
|
|
455
|
+
*/
|
|
456
|
+
toApiDto() {
|
|
457
|
+
return Object.assign(Object.assign({}, super.toApiDto()), { control: this.control, value: this.prepareApiValue(this.value) });
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Prepares the value to be sent to the API. The api will only accept strings,
|
|
461
|
+
* numbers and booleans, thus if we have an array or object, we need to JSON
|
|
462
|
+
* encode it
|
|
463
|
+
* @param {VasFieldDto} value
|
|
464
|
+
* @return {string | number | boolean}
|
|
465
|
+
* @protected
|
|
466
|
+
*/
|
|
467
|
+
prepareApiValue(value) {
|
|
468
|
+
switch (typeof value) {
|
|
469
|
+
case 'object': {
|
|
470
|
+
return JSON.stringify(value);
|
|
471
|
+
}
|
|
472
|
+
case 'boolean': {
|
|
473
|
+
return value;
|
|
474
|
+
}
|
|
475
|
+
case 'string': {
|
|
476
|
+
return value;
|
|
477
|
+
}
|
|
478
|
+
case 'number': {
|
|
479
|
+
return value;
|
|
480
|
+
}
|
|
481
|
+
default: {
|
|
482
|
+
return '';
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* VasFileDto
|
|
490
|
+
*/
|
|
491
|
+
class VasFileModel extends VasJobDataModel {
|
|
492
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, job, name, fileSize, mimeType, sequence, config, url) {
|
|
493
|
+
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, job);
|
|
494
|
+
this.id = id;
|
|
495
|
+
this.created = created;
|
|
496
|
+
this.serverCreated = serverCreated;
|
|
497
|
+
this.createdBy = createdBy;
|
|
498
|
+
this.modified = modified;
|
|
499
|
+
this.serverModified = serverModified;
|
|
500
|
+
this.modifiedBy = modifiedBy;
|
|
501
|
+
this.account = account;
|
|
502
|
+
this.job = job;
|
|
503
|
+
this.name = name;
|
|
504
|
+
this.fileSize = fileSize;
|
|
505
|
+
this.mimeType = mimeType;
|
|
506
|
+
this.sequence = sequence;
|
|
507
|
+
this.config = config;
|
|
508
|
+
this.url = url;
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* @param {VasFieldDto} fileDto
|
|
512
|
+
* @return {VasFieldModel}
|
|
513
|
+
*/
|
|
514
|
+
static fromDto(fileDto) {
|
|
515
|
+
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 || '');
|
|
516
|
+
}
|
|
517
|
+
static parseConfig(config = '') {
|
|
518
|
+
try {
|
|
519
|
+
return JSON.parse(config);
|
|
520
|
+
}
|
|
521
|
+
catch (e) {
|
|
522
|
+
return {
|
|
523
|
+
displayAs: '',
|
|
524
|
+
embedLink: false,
|
|
525
|
+
group: 'photo',
|
|
526
|
+
description: '',
|
|
527
|
+
displayedName: '',
|
|
528
|
+
rotation: 0
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* @return {VasFileDto}
|
|
534
|
+
*/
|
|
535
|
+
toDto() {
|
|
536
|
+
return {
|
|
537
|
+
id: this.id,
|
|
538
|
+
created: this.created,
|
|
539
|
+
serverCreated: this.serverCreated,
|
|
540
|
+
createdBy: this.createdBy,
|
|
541
|
+
modified: this.modified,
|
|
542
|
+
serverModified: this.serverModified,
|
|
543
|
+
modifiedBy: this.modifiedBy,
|
|
544
|
+
account: this.account,
|
|
545
|
+
job: this.job,
|
|
546
|
+
name: this.name,
|
|
547
|
+
fileSize: this.fileSize,
|
|
548
|
+
mimeType: this.mimeType,
|
|
549
|
+
sequence: this.sequence,
|
|
550
|
+
config: this.stringifyConfig(this.config),
|
|
551
|
+
url: this.url,
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
stringifyConfig(config) {
|
|
555
|
+
if (!config) {
|
|
556
|
+
return JSON.stringify({
|
|
557
|
+
displayAs: '',
|
|
558
|
+
embedLink: false,
|
|
559
|
+
group: 'photo',
|
|
560
|
+
description: '',
|
|
561
|
+
displayedName: '',
|
|
562
|
+
rotation: 0
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
try {
|
|
566
|
+
return JSON.stringify(config);
|
|
567
|
+
}
|
|
568
|
+
catch (e) {
|
|
569
|
+
console.warn(e);
|
|
570
|
+
return '';
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
toApiDto() {
|
|
574
|
+
return Object.assign(Object.assign({}, super.toApiDto()), { name: this.name || '~', mimeType: this.mimeType || '~', sequence: this.safeNumber(this.sequence), config: JSON.stringify(this.config) });
|
|
575
|
+
}
|
|
576
|
+
safeNumber(value) {
|
|
577
|
+
if (!Number.isFinite(value)) {
|
|
578
|
+
return 0;
|
|
579
|
+
}
|
|
580
|
+
return value;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
370
584
|
/**
|
|
371
585
|
* GroupModel
|
|
372
586
|
*/
|
|
@@ -422,6 +636,7 @@ class VasGroupModel extends VasBaseModel {
|
|
|
422
636
|
return new VasGroupModel(
|
|
423
637
|
// eslint-disable-next-line new-cap
|
|
424
638
|
dto.id || UUID.UUID(), dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.account || '', dto.accessGroup || '', dto.name || '', dto.title || '', dto.description || '', dto.sequence || 0, dto.includeInSummary || false, dto.forms || [], dto.visibilityControl || '', dto.visibleIfEquals || '', (dto.controls || [])
|
|
639
|
+
.filter(control => control.name.startsWith('fields.'))
|
|
425
640
|
.sort((a, b) => a.sequence - b.sequence)
|
|
426
641
|
.map(c => VasControlModel.fromDto(c)), dto.scoreWeight || 1);
|
|
427
642
|
}
|
|
@@ -472,7 +687,7 @@ class VasGroupModel extends VasBaseModel {
|
|
|
472
687
|
/**
|
|
473
688
|
* VasFormModel
|
|
474
689
|
*/
|
|
475
|
-
class VasFormModel extends
|
|
690
|
+
class VasFormModel extends VasRestrictedAccountObjectModel {
|
|
476
691
|
/**
|
|
477
692
|
* @param {string} id
|
|
478
693
|
* @param {string} created
|
|
@@ -490,9 +705,10 @@ class VasFormModel extends VasBaseModel {
|
|
|
490
705
|
* @param {string} dynamicDescriptor
|
|
491
706
|
* @param {string} indexName
|
|
492
707
|
* @param {string} pipelineName
|
|
708
|
+
* @param {string} config
|
|
493
709
|
*/
|
|
494
|
-
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, groups, dynamicDescriptor, indexName, pipelineName) {
|
|
495
|
-
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy);
|
|
710
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, groups, dynamicDescriptor, indexName, pipelineName, config) {
|
|
711
|
+
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup);
|
|
496
712
|
this.id = id;
|
|
497
713
|
this.created = created;
|
|
498
714
|
this.serverCreated = serverCreated;
|
|
@@ -509,6 +725,7 @@ class VasFormModel extends VasBaseModel {
|
|
|
509
725
|
this.dynamicDescriptor = dynamicDescriptor;
|
|
510
726
|
this.indexName = indexName;
|
|
511
727
|
this.pipelineName = pipelineName;
|
|
728
|
+
this.config = config;
|
|
512
729
|
}
|
|
513
730
|
/**
|
|
514
731
|
* Returns the name of this form in a "safe" way, i.e. no spaces, special
|
|
@@ -551,7 +768,7 @@ class VasFormModel extends VasBaseModel {
|
|
|
551
768
|
static fromDto(dto) {
|
|
552
769
|
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 || [])
|
|
553
770
|
.sort((a, b) => a.sequence - b.sequence)
|
|
554
|
-
.map(g => VasGroupModel.fromDto(g)), dto.dynamicDescriptor || '', dto.indexName || '', dto.pipelineName || '');
|
|
771
|
+
.map(g => VasGroupModel.fromDto(g)), dto.dynamicDescriptor || '', dto.indexName || '', dto.pipelineName || '', dto.config || '');
|
|
555
772
|
}
|
|
556
773
|
addControlTypesToControl(controlTypes) {
|
|
557
774
|
const controlTypeModels = controlTypes
|
|
@@ -655,7 +872,8 @@ class VasFormModel extends VasBaseModel {
|
|
|
655
872
|
groups: this.groups.map(group => group.toDto()),
|
|
656
873
|
dynamicDescriptor: this.dynamicDescriptor,
|
|
657
874
|
indexName: this.indexName,
|
|
658
|
-
pipelineName: this.pipelineName
|
|
875
|
+
pipelineName: this.pipelineName,
|
|
876
|
+
config: this.config
|
|
659
877
|
};
|
|
660
878
|
}
|
|
661
879
|
}
|
|
@@ -727,7 +945,7 @@ const getValueByPath = (path, object) => {
|
|
|
727
945
|
/**
|
|
728
946
|
* JobModel
|
|
729
947
|
*/
|
|
730
|
-
class VasJobModel extends
|
|
948
|
+
class VasJobModel extends VasRestrictedAccountObjectModel {
|
|
731
949
|
/**
|
|
732
950
|
* @param {string} id
|
|
733
951
|
* @param {string} created
|
|
@@ -742,12 +960,17 @@ class VasJobModel extends VasBaseModel {
|
|
|
742
960
|
* @param {string} jobDate
|
|
743
961
|
* @param {string} jobStatus
|
|
744
962
|
* @param {string} jobType
|
|
745
|
-
* @param {string}
|
|
963
|
+
* @param {string} assigneeId
|
|
746
964
|
* @param {string} formId
|
|
747
965
|
* @param {number} timeZoneOffset
|
|
966
|
+
* @param {number} pendingFields
|
|
967
|
+
* @param {string} childModified
|
|
968
|
+
* @param {number} version
|
|
969
|
+
* @param {Array<VasFieldDto>} fields
|
|
970
|
+
* @param {Array<VasFileDto>} files
|
|
748
971
|
*/
|
|
749
|
-
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, reference, jobDate, jobStatus, jobType,
|
|
750
|
-
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy);
|
|
972
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, reference, jobDate, jobStatus, jobType, assigneeId, formId, timeZoneOffset, pendingFields, childModified, version, fields, files) {
|
|
973
|
+
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup);
|
|
751
974
|
this.id = id;
|
|
752
975
|
this.created = created;
|
|
753
976
|
this.serverCreated = serverCreated;
|
|
@@ -761,9 +984,14 @@ class VasJobModel extends VasBaseModel {
|
|
|
761
984
|
this.jobDate = jobDate;
|
|
762
985
|
this.jobStatus = jobStatus;
|
|
763
986
|
this.jobType = jobType;
|
|
764
|
-
this.
|
|
987
|
+
this.assigneeId = assigneeId;
|
|
765
988
|
this.formId = formId;
|
|
766
989
|
this.timeZoneOffset = timeZoneOffset;
|
|
990
|
+
this.pendingFields = pendingFields;
|
|
991
|
+
this.childModified = childModified;
|
|
992
|
+
this.version = version;
|
|
993
|
+
this.fields = fields;
|
|
994
|
+
this.files = files;
|
|
767
995
|
}
|
|
768
996
|
/**
|
|
769
997
|
* Returns this with the dynamic interface
|
|
@@ -795,7 +1023,7 @@ class VasJobModel extends VasBaseModel {
|
|
|
795
1023
|
static empty() {
|
|
796
1024
|
return new VasJobModel(
|
|
797
1025
|
// eslint-disable-next-line new-cap
|
|
798
|
-
UUID.UUID(), '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment().utcOffset());
|
|
1026
|
+
UUID.UUID(), '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment().utcOffset(), 0, '', 0, [], []);
|
|
799
1027
|
}
|
|
800
1028
|
/**
|
|
801
1029
|
* @param {VasJobDto} jobDto
|
|
@@ -804,7 +1032,7 @@ class VasJobModel extends VasBaseModel {
|
|
|
804
1032
|
static fromDto(jobDto) {
|
|
805
1033
|
const model = new VasJobModel(
|
|
806
1034
|
// eslint-disable-next-line new-cap
|
|
807
|
-
jobDto.id || UUID.UUID(), jobDto.created || '', jobDto.serverCreated || '', jobDto.createdBy || '', jobDto.modified || '', jobDto.serverModified || '', jobDto.modifiedBy || '', jobDto.account || '', jobDto.accessGroup || '', jobDto.reference || '', jobDto.jobDate || '', jobDto.jobStatus || '', jobDto.jobType || '', jobDto.
|
|
1035
|
+
jobDto.id || UUID.UUID(), jobDto.created || '', jobDto.serverCreated || '', jobDto.createdBy || '', jobDto.modified || '', jobDto.serverModified || '', jobDto.modifiedBy || '', jobDto.account || '', jobDto.accessGroup || '', jobDto.reference || '', jobDto.jobDate || '', jobDto.jobStatus || '', jobDto.jobType || '', jobDto.assigneeId || '', jobDto.formId || '', jobDto.timeZoneOffset || moment().utcOffset(), jobDto.pendingFields || 0, jobDto.childModified || '', jobDto.version || 0, jobDto.fields || [], jobDto.files || []);
|
|
808
1036
|
const emptyKeys = model.staticProperties;
|
|
809
1037
|
Object
|
|
810
1038
|
.keys(jobDto)
|
|
@@ -848,6 +1076,114 @@ class VasJobModel extends VasBaseModel {
|
|
|
848
1076
|
}, {});
|
|
849
1077
|
return fields;
|
|
850
1078
|
}
|
|
1079
|
+
/**
|
|
1080
|
+
* This method will hydrate the `fields` property of the model. The reason for
|
|
1081
|
+
* this is that we have different ways to store the field data. One way, is
|
|
1082
|
+
* we store them as dynamic properties of the job. For example job.foo.bar,
|
|
1083
|
+
* where `foo` is the name of a Group, and `bar` is the name of a control.
|
|
1084
|
+
* Thus, when we create a job using a form in the client, the job object will
|
|
1085
|
+
* have its static properties (id, account, reference etc), and also a number
|
|
1086
|
+
* of dynamic properties determined by the Groups and Controls. This kind of
|
|
1087
|
+
* object is nice to work with in certain circumstances. However, the api
|
|
1088
|
+
* works differently. In the API a Job is a record, and references a number of
|
|
1089
|
+
* Field records. Each Field stores the value. Comparing these two models we
|
|
1090
|
+
* have:
|
|
1091
|
+
* A) job with dynamic properties, e.g.
|
|
1092
|
+
* {
|
|
1093
|
+
* id: <guid>,
|
|
1094
|
+
* reference: "something"
|
|
1095
|
+
* <other static job properties>...
|
|
1096
|
+
* foo: {
|
|
1097
|
+
* bar: "value"
|
|
1098
|
+
* }
|
|
1099
|
+
* }
|
|
1100
|
+
*
|
|
1101
|
+
* B) job with fields
|
|
1102
|
+
* {
|
|
1103
|
+
* id: <guid>,
|
|
1104
|
+
* reference: "something"
|
|
1105
|
+
* <other static job properties>...
|
|
1106
|
+
* <will not have dynamic properties>...
|
|
1107
|
+
* fields: [
|
|
1108
|
+
* {
|
|
1109
|
+
* id: <guid>,
|
|
1110
|
+
* <other field properties>,
|
|
1111
|
+
* value: "value"
|
|
1112
|
+
* }
|
|
1113
|
+
* ]
|
|
1114
|
+
* }
|
|
1115
|
+
*
|
|
1116
|
+
* So, what this method does is given a JobModel in the form of A, read all
|
|
1117
|
+
* of those dynamic properties and set them into `fields`. Doing this requires
|
|
1118
|
+
* knowledge of the Form that was used to create the job. Moreover, since the
|
|
1119
|
+
* dynamic properties do not contain the ids of the fields, we also allow to
|
|
1120
|
+
* pass in a `controlFieldIdMap`. This map stores the mapping between Control
|
|
1121
|
+
* and the Field that was created in the Job to store the value for that
|
|
1122
|
+
* Control. This is useful, if for example you want to compare a Job in form A
|
|
1123
|
+
* with a Job in form B, for example if you want to update the Job on the API
|
|
1124
|
+
* with a Job that was saved by a client in form A.
|
|
1125
|
+
*
|
|
1126
|
+
* E.g.
|
|
1127
|
+
* Client -> API: client requests form
|
|
1128
|
+
* User -> Client: user fills in the form and submits
|
|
1129
|
+
* Client -> Firestore: client saves the Job in form A i.e. dynamic props
|
|
1130
|
+
* Firestore -> Function: A function is triggered to sync the job to the API
|
|
1131
|
+
* Function -> API: Function checks if job already exists, it receives 404
|
|
1132
|
+
* Function -> Function: The function calls `hydrateFields(...)`
|
|
1133
|
+
* Function -> API: The function POST the Job to /jobs
|
|
1134
|
+
* Function -> API: The function POST each field to /fields
|
|
1135
|
+
*
|
|
1136
|
+
* Similarly, if the user updates the job
|
|
1137
|
+
* Client -> API: client requests form
|
|
1138
|
+
* User -> Client: user fills in the form and submits an update
|
|
1139
|
+
* Client -> Firestore: client saves the Job in form A i.e. dynamic props
|
|
1140
|
+
* Firestore -> Function: A function is triggered to sync the job to the API
|
|
1141
|
+
* Function -> API: Function checks if job already exists, it receives 200
|
|
1142
|
+
* Function -> Function: The function calls `hydrateFields(...)` passing in
|
|
1143
|
+
* the map is made by iterating over the fields it
|
|
1144
|
+
* received from the API and storing the mappings
|
|
1145
|
+
* between controlId and fieldId for each field
|
|
1146
|
+
* Function -> API: The function PATCH the Job to /jobs
|
|
1147
|
+
* Function -> API: The function POST/PATCH each field to /fields
|
|
1148
|
+
* treated as new
|
|
1149
|
+
*
|
|
1150
|
+
* @param {VasFormModel} formModel the VasFormModel that was used to create
|
|
1151
|
+
* the job
|
|
1152
|
+
* @param {Map<string, string>} controlFieldIdMap a mapping of control to
|
|
1153
|
+
* field ids. This is used to determine whether a new id for the field should
|
|
1154
|
+
* be generated, or to reuse an existing one from the map.
|
|
1155
|
+
* @param {Array<string>} controlNames if a value is provided, it will be used
|
|
1156
|
+
* to filter the fields that are returned.
|
|
1157
|
+
* @return {Array<VasFieldDto>}
|
|
1158
|
+
*/
|
|
1159
|
+
hydrateFields(formModel, controlFieldIdMap = new Map(), controlNames) {
|
|
1160
|
+
const fields = [];
|
|
1161
|
+
formModel.groups
|
|
1162
|
+
.forEach(group => {
|
|
1163
|
+
group.controls.forEach(control => {
|
|
1164
|
+
if (!control.name.startsWith('fields.')) {
|
|
1165
|
+
return;
|
|
1166
|
+
}
|
|
1167
|
+
if (controlNames && !controlNames.includes(control.name)) {
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
fields.push(VasFieldModel.fromDto({
|
|
1171
|
+
// if the controlId exists in the map, use the associated fieldId,
|
|
1172
|
+
// otherwise generate a new id for the field.
|
|
1173
|
+
id: controlFieldIdMap.get(control.id) || UUID.UUID(),
|
|
1174
|
+
account: this.account,
|
|
1175
|
+
job: this.id,
|
|
1176
|
+
createdBy: this.createdBy,
|
|
1177
|
+
created: this.created,
|
|
1178
|
+
modifiedBy: this.modifiedBy,
|
|
1179
|
+
modified: this.modified,
|
|
1180
|
+
control: control.id,
|
|
1181
|
+
value: this.getValueByPath([group.name, control.name])
|
|
1182
|
+
}));
|
|
1183
|
+
});
|
|
1184
|
+
});
|
|
1185
|
+
this.fields = fields;
|
|
1186
|
+
}
|
|
851
1187
|
/**
|
|
852
1188
|
|
|
853
1189
|
* @param {string[]} path path segments
|
|
@@ -918,9 +1254,14 @@ class VasJobModel extends VasBaseModel {
|
|
|
918
1254
|
jobDate: this.jobDate,
|
|
919
1255
|
jobStatus: this.jobStatus,
|
|
920
1256
|
jobType: this.jobType,
|
|
921
|
-
|
|
1257
|
+
assigneeId: this.assigneeId,
|
|
922
1258
|
formId: this.formId,
|
|
923
1259
|
timeZoneOffset: this.timeZoneOffset,
|
|
1260
|
+
pendingFields: this.pendingFields,
|
|
1261
|
+
childModified: this.childModified,
|
|
1262
|
+
version: this.version,
|
|
1263
|
+
fields: this.fields,
|
|
1264
|
+
files: this.files
|
|
924
1265
|
};
|
|
925
1266
|
}
|
|
926
1267
|
const dto = {};
|
|
@@ -1023,10 +1364,35 @@ class VasJobModel extends VasBaseModel {
|
|
|
1023
1364
|
}).trim();
|
|
1024
1365
|
}
|
|
1025
1366
|
;
|
|
1367
|
+
/**
|
|
1368
|
+
* @return {object}
|
|
1369
|
+
*/
|
|
1370
|
+
toApiDto() {
|
|
1371
|
+
return Object.assign(Object.assign({}, super.toApiDto()), { reference: this.reference || '~', jobDate: this.jobDate || '~', jobType: this.jobType || '~', accessGroup: this.accessGroup || '~', jobStatus: this.jobStatus || '~', assigneeId: this.assigneeId || '~', timeZoneOffset: this.timeZoneOffset || 0, pendingFields: this.pendingFields || 0 });
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
class VasReportLayoutModel extends VasRestrictedAccountObjectModel {
|
|
1376
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup, jobType, title, description, entryPoint) {
|
|
1377
|
+
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, account, accessGroup);
|
|
1378
|
+
this.id = id;
|
|
1379
|
+
this.created = created;
|
|
1380
|
+
this.serverCreated = serverCreated;
|
|
1381
|
+
this.createdBy = createdBy;
|
|
1382
|
+
this.modified = modified;
|
|
1383
|
+
this.serverModified = serverModified;
|
|
1384
|
+
this.modifiedBy = modifiedBy;
|
|
1385
|
+
this.account = account;
|
|
1386
|
+
this.accessGroup = accessGroup;
|
|
1387
|
+
this.jobType = jobType;
|
|
1388
|
+
this.title = title;
|
|
1389
|
+
this.description = description;
|
|
1390
|
+
this.entryPoint = entryPoint;
|
|
1391
|
+
}
|
|
1026
1392
|
}
|
|
1027
1393
|
|
|
1028
1394
|
class VasReportRequestModel extends VasBaseModel {
|
|
1029
|
-
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, error, jobId, title, url) {
|
|
1395
|
+
constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, error, jobId, title, url, reportId) {
|
|
1030
1396
|
super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy);
|
|
1031
1397
|
this.id = id;
|
|
1032
1398
|
this.created = created;
|
|
@@ -1039,9 +1405,10 @@ class VasReportRequestModel extends VasBaseModel {
|
|
|
1039
1405
|
this.jobId = jobId;
|
|
1040
1406
|
this.title = title;
|
|
1041
1407
|
this.url = url;
|
|
1408
|
+
this.reportId = reportId;
|
|
1042
1409
|
}
|
|
1043
1410
|
static fromDto(dto) {
|
|
1044
|
-
return new VasReportRequestModel(dto.id || UUID.UUID(), dto.created || moment().toISOString(), dto.serverCreated || '', dto.createdBy || '', dto.modified || moment().toISOString(), dto.serverModified || '', dto.modifiedBy || '', dto.error || '', dto.jobId || '', dto.title || '', dto.url || '');
|
|
1411
|
+
return new VasReportRequestModel(dto.id || UUID.UUID(), dto.created || moment().toISOString(), dto.serverCreated || '', dto.createdBy || '', dto.modified || moment().toISOString(), dto.serverModified || '', dto.modifiedBy || '', dto.error || '', dto.jobId || '', dto.title || '', dto.url || '', dto.reportId || '');
|
|
1045
1412
|
}
|
|
1046
1413
|
toDto() {
|
|
1047
1414
|
return {
|
|
@@ -1055,7 +1422,8 @@ class VasReportRequestModel extends VasBaseModel {
|
|
|
1055
1422
|
error: this.error,
|
|
1056
1423
|
jobId: this.jobId,
|
|
1057
1424
|
title: this.title,
|
|
1058
|
-
url: this.url
|
|
1425
|
+
url: this.url,
|
|
1426
|
+
reportId: this.reportId
|
|
1059
1427
|
};
|
|
1060
1428
|
}
|
|
1061
1429
|
}
|
|
@@ -1108,5 +1476,5 @@ class VasUserModel extends VasBaseModel {
|
|
|
1108
1476
|
* Generated bundle index. Do not edit.
|
|
1109
1477
|
*/
|
|
1110
1478
|
|
|
1111
|
-
export { VasAccountObjectModel, VasBaseModel, VasBranchModel, VasContactModel, VasControlConfigDirection, VasControlModel, VasControlTypeModel, VasFormModel, VasGroupModel, VasJobModel, VasReportRequestModel, VasRestrictedAccountObjectModel, VasUserModel };
|
|
1479
|
+
export { VasAccountObjectModel, VasBaseModel, VasBranchModel, VasContactModel, VasControlConfigDirection, VasControlModel, VasControlTypeModel, VasFieldModel, VasFileModel, VasFormModel, VasGroupModel, VasJobDataModel, VasJobModel, VasReportLayoutModel, VasReportRequestModel, VasRestrictedAccountObjectModel, VasUserModel };
|
|
1112
1480
|
//# sourceMappingURL=ironcode-vas-lib.mjs.map
|