@ironcode/vas-lib 3.0.0-alpha.8 → 3.0.0-alpha.9

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.
@@ -3797,6 +3797,13 @@ const getEmptyGeoLocation = () => ({
3797
3797
  timestamp: ''
3798
3798
  });
3799
3799
 
3800
+ /**
3801
+ * Return true IFF the array contains only strings
3802
+ */
3803
+ const isArrayString = (value) => {
3804
+ return Array.isArray(value) && value.every(i => typeof i === 'string');
3805
+ };
3806
+
3800
3807
  /**
3801
3808
  * Return true if the argument is a plain object {}, i.e. not an array, null.
3802
3809
  */
@@ -3804,6 +3811,53 @@ function isPlainObject(value) {
3804
3811
  return typeof value === 'object' && value !== null && !Array.isArray(value);
3805
3812
  }
3806
3813
 
3814
+ /**
3815
+ * Return an object omitting properties specified by key(s)
3816
+ *
3817
+ * @param obj object to be processed
3818
+ * @param omitKey key or array of keys to be omitted
3819
+ */
3820
+ const omit = (obj, omitKey) => {
3821
+ return Object.keys(obj).reduce((result, key) => {
3822
+ if (Array.isArray(omitKey)) {
3823
+ if (!omitKey.includes(key)) {
3824
+ result[key] = obj[key];
3825
+ }
3826
+ }
3827
+ else {
3828
+ if (omitKey !== key) {
3829
+ result[key] = obj[key];
3830
+ }
3831
+ }
3832
+ return result;
3833
+ }, {});
3834
+ };
3835
+
3836
+ /**
3837
+ * Try to parse the value as JSON if it looks like a JSON encoded string, return
3838
+ * the original value if it's not a JSON string or parsing fails.
3839
+ */
3840
+ const tryJson = (value) => {
3841
+ if (typeof value === 'string' && ['{', '['].includes(value.substring(0, 1))) {
3842
+ try {
3843
+ return JSON.parse(value);
3844
+ }
3845
+ catch (e) {
3846
+ return value;
3847
+ }
3848
+ }
3849
+ return value;
3850
+ };
3851
+
3852
+ const nullables = new Set([
3853
+ 'created',
3854
+ 'modified',
3855
+ 'reference',
3856
+ 'jobDate',
3857
+ 'followUpDate',
3858
+ 'followUpStatus',
3859
+ 'followUpNote',
3860
+ ]);
3807
3861
  let jobStaticProps;
3808
3862
  /**
3809
3863
  * VasJobBaseModel
@@ -3831,6 +3885,9 @@ class VasJobBaseModel extends VasRestrictedAccountObjectModel {
3831
3885
  pendingFields;
3832
3886
  childModified;
3833
3887
  version;
3888
+ followUpDate;
3889
+ followUpStatus;
3890
+ followUpNote;
3834
3891
  geoLocation;
3835
3892
  files;
3836
3893
  fields;
@@ -3839,7 +3896,7 @@ class VasJobBaseModel extends VasRestrictedAccountObjectModel {
3839
3896
  reports;
3840
3897
  tasks;
3841
3898
  instruction;
3842
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, reference, jobDate, jobStatus, jobStatusLastUpdate, jobType, assigneeId, formId, timeZoneOffset, pendingFields, childModified, version, geoLocation, files, fields, jobEmails, notes, reports, tasks, instruction) {
3899
+ constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, reference, jobDate, jobStatus, jobStatusLastUpdate, jobType, assigneeId, formId, timeZoneOffset, pendingFields, childModified, version, followUpDate, followUpStatus, followUpNote, geoLocation, files, fields, jobEmails, notes, reports, tasks, instruction) {
3843
3900
  super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
3844
3901
  this.id = id;
3845
3902
  this.created = created;
@@ -3863,6 +3920,9 @@ class VasJobBaseModel extends VasRestrictedAccountObjectModel {
3863
3920
  this.pendingFields = pendingFields;
3864
3921
  this.childModified = childModified;
3865
3922
  this.version = version;
3923
+ this.followUpDate = followUpDate;
3924
+ this.followUpStatus = followUpStatus;
3925
+ this.followUpNote = followUpNote;
3866
3926
  this.geoLocation = geoLocation;
3867
3927
  this.files = files;
3868
3928
  this.fields = fields;
@@ -3959,7 +4019,6 @@ class VasJobBaseModel extends VasRestrictedAccountObjectModel {
3959
4019
  if (!value || typeof value !== 'string') {
3960
4020
  return '';
3961
4021
  }
3962
- const fields = this.fields;
3963
4022
  return value.replace(/({[^}]*})/g, (match, token) => {
3964
4023
  const syntax = token.substring(1, token.length - 1);
3965
4024
  let [key, filter] = syntax.split('|');
@@ -4044,8 +4103,11 @@ class VasJobBaseModel extends VasRestrictedAccountObjectModel {
4044
4103
  'assigneeId',
4045
4104
  'timeZoneOffset',
4046
4105
  'pendingFields',
4047
- 'formId'
4048
- ]);
4106
+ 'formId',
4107
+ 'followUpDate',
4108
+ 'followUpStatus',
4109
+ 'followUpNote',
4110
+ ], (value, key) => value[key] === null && nullables.has(key) ? '~' : value[key]);
4049
4111
  }
4050
4112
  }
4051
4113
  class VasJobRelationalModel extends VasJobBaseModel {
@@ -4083,10 +4145,43 @@ class VasJobRelationalModel extends VasJobBaseModel {
4083
4145
  if (dto.fields !== undefined && !Array.isArray(dto.fields)) {
4084
4146
  throw Error('fields must be an array');
4085
4147
  }
4086
- return new VasJobRelationalModel(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.jobStatusLastUpdate || '', 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 || [], (dto.fields || []).map(f => VasFieldModel.fromDto(f)), dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
4148
+ return new VasJobRelationalModel(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.jobStatusLastUpdate || '', dto.jobType || '', dto.assigneeId || '', dto.formId || dto.lastForm || '', dto.timeZoneOffset || moment().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.followUpDate || '', dto.followUpStatus || '', dto.followUpNote || '', dto.geoLocation || getEmptyGeoLocation(), dto.files || [], (dto.fields || []).map(f => VasFieldModel.fromDto(f)), dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
4087
4149
  }
4088
4150
  static empty() {
4089
- return new VasJobRelationalModel('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment().utcOffset(), 0, '', 0, getEmptyGeoLocation(), [], [], [], [], [], [], null);
4151
+ return new VasJobRelationalModel('', // id
4152
+ '', // created
4153
+ '', // serverCreated
4154
+ '', // createdBy
4155
+ '', // modified
4156
+ '', // serverModified
4157
+ '', // modifiedBy
4158
+ '', // createdByName
4159
+ '', // modifiedByName
4160
+ '', // account
4161
+ '', // accessGroup
4162
+ '', // reference
4163
+ '', // jobDate
4164
+ '', // jobStatus
4165
+ '', // jobStatusLastUpdate
4166
+ '', // jobType
4167
+ '', // assigneeId
4168
+ '', // formId
4169
+ moment().utcOffset(), // timeZoneOffset
4170
+ 0, // pendingFields: number,
4171
+ '', // childModified: string,
4172
+ 0, // version: number,
4173
+ '', // followUpDate: string,
4174
+ '', // followUpStatus: string,
4175
+ '', // followUpNote: string,
4176
+ getEmptyGeoLocation(), // geoLocation: GeoLocation,
4177
+ [], // files: Array<VasFileDto>,
4178
+ [], // fields: FType,
4179
+ [], // jobEmails: Array<VasJobEmailDto>,
4180
+ [], // notes: Array<VasNoteDto>,
4181
+ [], // reports: Array<VasReportDto>,
4182
+ [], // tasks: Array<VasTaskDto>,
4183
+ null // instruction: VasInstructionDto | null
4184
+ );
4090
4185
  }
4091
4186
  toDto() {
4092
4187
  return {
@@ -4112,6 +4207,9 @@ class VasJobRelationalModel extends VasJobBaseModel {
4112
4207
  pendingFields: this.pendingFields,
4113
4208
  childModified: this.childModified,
4114
4209
  version: this.version,
4210
+ followUpDate: this.followUpDate,
4211
+ followUpStatus: this.followUpStatus,
4212
+ followUpNote: this.followUpNote,
4115
4213
  geoLocation: this.geoLocation,
4116
4214
  files: this.files,
4117
4215
  fields: this.fields.map(f => f.toDto()),
@@ -4125,7 +4223,7 @@ class VasJobRelationalModel extends VasJobBaseModel {
4125
4223
  }
4126
4224
  class VasJobDocumentModel extends VasJobBaseModel {
4127
4225
  static fromRelationalDto(dto) {
4128
- return new VasJobDocumentModel(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.jobStatusLastUpdate || '', 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 || [], (dto.fields || []).reduce((p, c) => {
4226
+ return new VasJobDocumentModel(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.jobStatusLastUpdate || '', dto.jobType || '', dto.assigneeId || '', dto.formId || dto.lastForm || '', dto.timeZoneOffset || moment().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.followUpDate || '', dto.followUpStatus || '', dto.followUpNote || '', dto.geoLocation || getEmptyGeoLocation(), dto.files || [], (dto.fields || []).reduce((p, c) => {
4129
4227
  p[c.controlName.replace('fields.', '')] = c.value;
4130
4228
  return p;
4131
4229
  }, {}), dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
@@ -4134,10 +4232,43 @@ class VasJobDocumentModel extends VasJobBaseModel {
4134
4232
  if (dto.fields !== undefined && !isPlainObject(dto.fields)) {
4135
4233
  throw Error('fields must be an object');
4136
4234
  }
4137
- return new VasJobDocumentModel(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.jobStatusLastUpdate || '', 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 || [], dto.fields || {}, dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
4235
+ return new VasJobDocumentModel(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.jobStatusLastUpdate || '', dto.jobType || '', dto.assigneeId || '', dto.formId || dto.lastForm || '', dto.timeZoneOffset || moment().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.followUpDate || '', dto.followUpStatus || '', dto.followUpNote || '', dto.geoLocation || getEmptyGeoLocation(), dto.files || [], dto.fields || {}, dto.jobEmails || [], dto.notes || [], dto.reports || [], dto.tasks || [], dto.instruction || null);
4138
4236
  }
4139
4237
  static empty() {
4140
- return new VasJobDocumentModel('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment().utcOffset(), 0, '', 0, getEmptyGeoLocation(), [], {}, [], [], [], [], null);
4238
+ return new VasJobDocumentModel('', // id
4239
+ '', // created
4240
+ '', // serverCreated
4241
+ '', // createdBy
4242
+ '', // modified
4243
+ '', // serverModified
4244
+ '', // modifiedBy
4245
+ '', // createdByName
4246
+ '', // modifiedByName
4247
+ '', // account
4248
+ '', // accessGroup
4249
+ '', // reference
4250
+ '', // jobDate
4251
+ '', // jobStatus
4252
+ '', // jobStatusLastUpdate
4253
+ '', // jobType
4254
+ '', // assigneeId
4255
+ '', // formId
4256
+ moment().utcOffset(), // timeZoneOffset
4257
+ 0, // pendingFields: number,
4258
+ '', // childModified: string,
4259
+ 0, // version: number,
4260
+ '', // followUpDate: string,
4261
+ '', // followUpStatus: string,
4262
+ '', // followUpNote: string,
4263
+ getEmptyGeoLocation(), // geoLocation: GeoLocation,
4264
+ [], // files: Array<VasFileDto>,
4265
+ {}, // fields: FType,
4266
+ [], // jobEmails: Array<VasJobEmailDto>,
4267
+ [], // notes: Array<VasNoteDto>,
4268
+ [], // reports: Array<VasReportDto>,
4269
+ [], // tasks: Array<VasTaskDto>,
4270
+ null // instruction: VasInstructionDto | null
4271
+ );
4141
4272
  }
4142
4273
  toDto() {
4143
4274
  return {
@@ -4163,6 +4294,9 @@ class VasJobDocumentModel extends VasJobBaseModel {
4163
4294
  pendingFields: this.pendingFields,
4164
4295
  childModified: this.childModified,
4165
4296
  version: this.version,
4297
+ followUpDate: this.followUpDate,
4298
+ followUpStatus: this.followUpStatus,
4299
+ followUpNote: this.followUpNote,
4166
4300
  geoLocation: this.geoLocation,
4167
4301
  files: this.files,
4168
4302
  fields: this.fields,
@@ -4778,51 +4912,6 @@ class VasVehicleModel extends VasAccountObjectModel {
4778
4912
  }
4779
4913
  }
4780
4914
 
4781
- /**
4782
- * Return true IFF the array contains only strings
4783
- */
4784
- const isArrayString = (value) => {
4785
- return Array.isArray(value) && value.every(i => typeof i === 'string');
4786
- };
4787
-
4788
- /**
4789
- * Return an object omitting properties specified by key(s)
4790
- *
4791
- * @param obj object to be processed
4792
- * @param omitKey key or array of keys to be omitted
4793
- */
4794
- const omit = (obj, omitKey) => {
4795
- return Object.keys(obj).reduce((result, key) => {
4796
- if (Array.isArray(omitKey)) {
4797
- if (!omitKey.includes(key)) {
4798
- result[key] = obj[key];
4799
- }
4800
- }
4801
- else {
4802
- if (omitKey !== key) {
4803
- result[key] = obj[key];
4804
- }
4805
- }
4806
- return result;
4807
- }, {});
4808
- };
4809
-
4810
- /**
4811
- * Try to parse the value as JSON if it looks like a JSON encoded string, return
4812
- * the original value if it's not a JSON string or parsing fails.
4813
- */
4814
- const tryJson = (value) => {
4815
- if (typeof value === 'string' && ['{', '['].includes(value.substring(0, 1))) {
4816
- try {
4817
- return JSON.parse(value);
4818
- }
4819
- catch (e) {
4820
- return value;
4821
- }
4822
- }
4823
- return value;
4824
- };
4825
-
4826
4915
  /**
4827
4916
  * Generated bundle index. Do not edit.
4828
4917
  */