@ironcode/vas-lib 1.8.0-alpha.4 → 1.8.0-alpha.6

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 (148) hide show
  1. package/cjs/lib/control-value/vas-camera-control-value.model.js +1 -2
  2. package/cjs/lib/control-value/vas-camera-control-value.model.js.map +1 -1
  3. package/cjs/lib/controls-config/vas-control-config-direction.enum.js +1 -1
  4. package/cjs/lib/controls-config/vas-control-config-direction.enum.js.map +1 -1
  5. package/cjs/lib/entity/index.d.ts +1 -0
  6. package/cjs/lib/entity/index.d.ts.map +1 -1
  7. package/cjs/lib/entity/index.js +1 -0
  8. package/cjs/lib/entity/index.js.map +1 -1
  9. package/cjs/lib/entity/vas-account.dto.js +1 -1
  10. package/cjs/lib/entity/vas-account.dto.js.map +1 -1
  11. package/cjs/lib/entity/vas-control.model.js.map +1 -1
  12. package/cjs/lib/entity/vas-field.model.js.map +1 -1
  13. package/cjs/lib/entity/vas-file.dto.js +1 -2
  14. package/cjs/lib/entity/vas-file.dto.js.map +1 -1
  15. package/cjs/lib/entity/vas-file.model.js.map +1 -1
  16. package/cjs/lib/entity/vas-fire-user.model.d.ts +1 -1
  17. package/cjs/lib/entity/vas-fire-user.model.d.ts.map +1 -1
  18. package/cjs/lib/entity/vas-fire-user.model.js.map +1 -1
  19. package/cjs/lib/entity/vas-form-config.model.d.ts +3 -13
  20. package/cjs/lib/entity/vas-form-config.model.d.ts.map +1 -1
  21. package/cjs/lib/entity/vas-form-config.model.js.map +1 -1
  22. package/cjs/lib/entity/vas-form.model.js.map +1 -1
  23. package/cjs/lib/entity/vas-group.model.js.map +1 -1
  24. package/cjs/lib/entity/vas-invitation.js +1 -1
  25. package/cjs/lib/entity/vas-invitation.js.map +1 -1
  26. package/cjs/lib/entity/vas-job.model.js.map +1 -1
  27. package/cjs/lib/entity/vas-lookup.model.d.ts +34 -0
  28. package/cjs/lib/entity/vas-lookup.model.d.ts.map +1 -0
  29. package/cjs/lib/entity/vas-lookup.model.js +61 -0
  30. package/cjs/lib/entity/vas-lookup.model.js.map +1 -0
  31. package/cjs/lib/entity/vas-task.dto.d.ts +1 -0
  32. package/cjs/lib/entity/vas-task.dto.d.ts.map +1 -1
  33. package/cjs/lib/entity/vas-task.dto.js.map +1 -1
  34. package/cjs/lib/entity/vas-task.model.d.ts +2 -1
  35. package/cjs/lib/entity/vas-task.model.d.ts.map +1 -1
  36. package/cjs/lib/entity/vas-task.model.js +4 -2
  37. package/cjs/lib/entity/vas-task.model.js.map +1 -1
  38. package/cjs/lib/entity/vas-user.model.d.ts +1 -1
  39. package/cjs/lib/entity/vas-user.model.d.ts.map +1 -1
  40. package/cjs/lib/utils/find-form-control.js.map +1 -1
  41. package/cjs/lib/utils/get-value-by-path.d.ts.map +1 -1
  42. package/cjs/lib/utils/get-value-by-path.js.map +1 -1
  43. package/cjs/lib/utils/is-array-string.d.ts +1 -1
  44. package/cjs/lib/utils/is-array-string.d.ts.map +1 -1
  45. package/cjs/lib/utils/omit.d.ts.map +1 -1
  46. package/cjs/lib/utils/omit.js.map +1 -1
  47. package/cjs/lib/utils/only.d.ts.map +1 -1
  48. package/cjs/lib/utils/only.js.map +1 -1
  49. package/{fesm2020 → fesm2022}/ironcode-vas-lib.mjs +560 -4
  50. package/fesm2022/ironcode-vas-lib.mjs.map +1 -0
  51. package/lib/entity/index.d.ts +1 -0
  52. package/lib/entity/vas-fire-user.model.d.ts +1 -1
  53. package/lib/entity/vas-form-config.model.d.ts +3 -13
  54. package/lib/entity/vas-lookup.model.d.ts +33 -0
  55. package/lib/entity/vas-task.dto.d.ts +1 -0
  56. package/lib/entity/vas-task.model.d.ts +2 -1
  57. package/lib/entity/vas-user.model.d.ts +1 -1
  58. package/lib/utils/is-array-string.d.ts +1 -1
  59. package/package.json +4 -11
  60. package/cjs/package.json +0 -68
  61. package/esm2020/ironcode-vas-lib.mjs +0 -5
  62. package/esm2020/lib/control-value/index.mjs +0 -3
  63. package/esm2020/lib/control-value/vas-camera-control-value.model.mjs +0 -8
  64. package/esm2020/lib/control-value/vas-function-control-value.dto.mjs +0 -2
  65. package/esm2020/lib/controls-config/index.mjs +0 -5
  66. package/esm2020/lib/controls-config/vas-control-config-direction.enum.mjs +0 -8
  67. package/esm2020/lib/controls-config/vas-control-config.model.mjs +0 -2
  68. package/esm2020/lib/controls-config/vas-function-control-config.dto.mjs +0 -2
  69. package/esm2020/lib/controls-config/vas-select-control-config.model.mjs +0 -2
  70. package/esm2020/lib/elastic/index.mjs +0 -2
  71. package/esm2020/lib/elastic/job.elastic-doc.mjs +0 -2
  72. package/esm2020/lib/entity/index.mjs +0 -67
  73. package/esm2020/lib/entity/vas-access-group.dto.mjs +0 -2
  74. package/esm2020/lib/entity/vas-account-config.dto.mjs +0 -2
  75. package/esm2020/lib/entity/vas-account-object.dto.mjs +0 -2
  76. package/esm2020/lib/entity/vas-account-object.model.mjs +0 -24
  77. package/esm2020/lib/entity/vas-account.dto.mjs +0 -7
  78. package/esm2020/lib/entity/vas-base.dto.mjs +0 -2
  79. package/esm2020/lib/entity/vas-base.model.mjs +0 -34
  80. package/esm2020/lib/entity/vas-branch.dto.mjs +0 -2
  81. package/esm2020/lib/entity/vas-branch.model.mjs +0 -68
  82. package/esm2020/lib/entity/vas-contact-type.dto.mjs +0 -2
  83. package/esm2020/lib/entity/vas-contact.dto.mjs +0 -2
  84. package/esm2020/lib/entity/vas-contact.model.mjs +0 -99
  85. package/esm2020/lib/entity/vas-control-type.dto.mjs +0 -2
  86. package/esm2020/lib/entity/vas-control-type.model.mjs +0 -52
  87. package/esm2020/lib/entity/vas-control.dto.mjs +0 -2
  88. package/esm2020/lib/entity/vas-control.model.mjs +0 -171
  89. package/esm2020/lib/entity/vas-field.dto.mjs +0 -2
  90. package/esm2020/lib/entity/vas-field.model.mjs +0 -97
  91. package/esm2020/lib/entity/vas-file.dto.mjs +0 -9
  92. package/esm2020/lib/entity/vas-file.model.mjs +0 -125
  93. package/esm2020/lib/entity/vas-fire-user.dto.mjs +0 -2
  94. package/esm2020/lib/entity/vas-fire-user.model.mjs +0 -102
  95. package/esm2020/lib/entity/vas-form-config.dto.mjs +0 -2
  96. package/esm2020/lib/entity/vas-form-config.model.mjs +0 -31
  97. package/esm2020/lib/entity/vas-form.dto.mjs +0 -2
  98. package/esm2020/lib/entity/vas-form.model.mjs +0 -203
  99. package/esm2020/lib/entity/vas-group.dto.mjs +0 -2
  100. package/esm2020/lib/entity/vas-group.model.mjs +0 -97
  101. package/esm2020/lib/entity/vas-instruction-job-field.dto.mjs +0 -2
  102. package/esm2020/lib/entity/vas-instruction-job-field.model.mjs +0 -48
  103. package/esm2020/lib/entity/vas-instruction-job.dto.mjs +0 -2
  104. package/esm2020/lib/entity/vas-instruction-job.model.mjs +0 -81
  105. package/esm2020/lib/entity/vas-instruction-provider.dto.mjs +0 -2
  106. package/esm2020/lib/entity/vas-instruction-provider.model.mjs +0 -66
  107. package/esm2020/lib/entity/vas-instruction.dto.mjs +0 -2
  108. package/esm2020/lib/entity/vas-instruction.model.mjs +0 -52
  109. package/esm2020/lib/entity/vas-invitation.mjs +0 -88
  110. package/esm2020/lib/entity/vas-job-data.dto.mjs +0 -2
  111. package/esm2020/lib/entity/vas-job-data.model.mjs +0 -21
  112. package/esm2020/lib/entity/vas-job-email.dto.mjs +0 -2
  113. package/esm2020/lib/entity/vas-job-email.model.mjs +0 -79
  114. package/esm2020/lib/entity/vas-job-status.dto.mjs +0 -2
  115. package/esm2020/lib/entity/vas-job-type.dto.mjs +0 -2
  116. package/esm2020/lib/entity/vas-job.dto.mjs +0 -2
  117. package/esm2020/lib/entity/vas-job.model.mjs +0 -497
  118. package/esm2020/lib/entity/vas-lookup-type.dto.mjs +0 -2
  119. package/esm2020/lib/entity/vas-lookup.dto.mjs +0 -2
  120. package/esm2020/lib/entity/vas-membership.dto.mjs +0 -2
  121. package/esm2020/lib/entity/vas-membership.model.mjs +0 -62
  122. package/esm2020/lib/entity/vas-note.dto.mjs +0 -2
  123. package/esm2020/lib/entity/vas-note.model.mjs +0 -59
  124. package/esm2020/lib/entity/vas-report-layout.dto.mjs +0 -2
  125. package/esm2020/lib/entity/vas-report-layout.model.mjs +0 -22
  126. package/esm2020/lib/entity/vas-report-request.dto.mjs +0 -2
  127. package/esm2020/lib/entity/vas-report-request.model.mjs +0 -44
  128. package/esm2020/lib/entity/vas-report.dto.mjs +0 -2
  129. package/esm2020/lib/entity/vas-report.model.mjs +0 -57
  130. package/esm2020/lib/entity/vas-restricted-account-object.dto.mjs +0 -2
  131. package/esm2020/lib/entity/vas-restricted-account-object.model.mjs +0 -24
  132. package/esm2020/lib/entity/vas-task-type.dto.mjs +0 -2
  133. package/esm2020/lib/entity/vas-task.dto.mjs +0 -2
  134. package/esm2020/lib/entity/vas-task.model.mjs +0 -66
  135. package/esm2020/lib/entity/vas-user.dto.mjs +0 -2
  136. package/esm2020/lib/entity/vas-user.model.mjs +0 -42
  137. package/esm2020/lib/entity/vas-vehicle.dto.mjs +0 -2
  138. package/esm2020/lib/entity/vas-vehicle.model.mjs +0 -69
  139. package/esm2020/lib/model/geo-location.mjs +0 -12
  140. package/esm2020/lib/model/index.mjs +0 -3
  141. package/esm2020/lib/model/vas-time-range.model.mjs +0 -2
  142. package/esm2020/lib/utils/get-value-by-path.mjs +0 -64
  143. package/esm2020/lib/utils/is-array-string.mjs +0 -4
  144. package/esm2020/lib/utils/only.mjs +0 -22
  145. package/esm2020/public-api.mjs +0 -6
  146. package/fesm2015/ironcode-vas-lib.mjs +0 -2478
  147. package/fesm2015/ironcode-vas-lib.mjs.map +0 -1
  148. package/fesm2020/ironcode-vas-lib.mjs.map +0 -1
@@ -1,2478 +0,0 @@
1
- import moment from 'moment/moment';
2
- import { UUID } from 'angular2-uuid';
3
- import moment$1 from 'moment';
4
-
5
- function isCameraControlValueV1(object) {
6
- return object instanceof Object
7
- && 'webPath' in object
8
- && 'path' in object
9
- && 'url' in object
10
- && 'id' in object;
11
- }
12
-
13
- var VasControlConfigDirection;
14
- (function (VasControlConfigDirection) {
15
- // eslint-disable-next-line @typescript-eslint/naming-convention
16
- VasControlConfigDirection[VasControlConfigDirection["ROW"] = 0] = "ROW";
17
- // eslint-disable-next-line @typescript-eslint/naming-convention
18
- VasControlConfigDirection[VasControlConfigDirection["COLUMN"] = 1] = "COLUMN";
19
- })(VasControlConfigDirection || (VasControlConfigDirection = {}));
20
-
21
- /**
22
- * BaseEntityModel
23
- */
24
- class VasBaseModel {
25
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName) {
26
- this.id = id;
27
- this.created = created;
28
- this.serverCreated = serverCreated;
29
- this.createdBy = createdBy;
30
- this.modified = modified;
31
- this.serverModified = serverModified;
32
- this.modifiedBy = modifiedBy;
33
- this.createdByName = createdByName;
34
- this.modifiedByName = modifiedByName;
35
- }
36
- static fromDto(dto) {
37
- return new VasBaseModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '');
38
- }
39
- static create(user, values = {}) {
40
- return this.fromDto(Object.assign(Object.assign({}, values), { id: UUID.UUID(), created: moment().toISOString(), modified: moment().toISOString(), createdBy: (user === null || user === void 0 ? void 0 : user.id) || '', createdByName: (user === null || user === void 0 ? void 0 : user.name) || '', modifiedBy: (user === null || user === void 0 ? void 0 : user.id) || '', modifiedByName: (user === null || user === void 0 ? void 0 : user.name) || '' }));
41
- }
42
- }
43
-
44
- class VasUserModel extends VasBaseModel {
45
- constructor(id, created = '', serverCreated = '', createdBy = '', modified = '', serverModified = '', modifiedBy = '', createdByName, modifiedByName, email, name, username, memberships, instructionProviders) {
46
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName);
47
- this.id = id;
48
- this.created = created;
49
- this.serverCreated = serverCreated;
50
- this.createdBy = createdBy;
51
- this.modified = modified;
52
- this.serverModified = serverModified;
53
- this.modifiedBy = modifiedBy;
54
- this.createdByName = createdByName;
55
- this.modifiedByName = modifiedByName;
56
- this.email = email;
57
- this.name = name;
58
- this.username = username;
59
- this.memberships = memberships;
60
- this.instructionProviders = instructionProviders;
61
- }
62
- static fromDto(dto) {
63
- return new VasUserModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.email || '', dto.name || '', dto.username || '', dto.memberships || [], dto.instructionProviders || []);
64
- }
65
- toDto() {
66
- return {
67
- id: this.id,
68
- created: this.created,
69
- serverCreated: this.serverCreated,
70
- createdBy: this.createdBy,
71
- modified: this.modified,
72
- serverModified: this.serverModified,
73
- modifiedBy: this.modifiedBy,
74
- createdByName: this.createdByName,
75
- modifiedByName: this.modifiedByName,
76
- email: this.email,
77
- name: this.name,
78
- username: this.username,
79
- memberships: this.memberships,
80
- instructionProviders: this.instructionProviders
81
- };
82
- }
83
- }
84
-
85
- class VasFireUserModel extends VasUserModel {
86
- constructor(id, created = '', serverCreated = '', createdBy = '', modified = '', serverModified = '', modifiedBy = '', createdByName, modifiedByName, email, name, username, memberships, instructionProviders, accounts, tokens, topics, language, displayName) {
87
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, email, name, username, memberships, instructionProviders);
88
- this.id = id;
89
- this.created = created;
90
- this.serverCreated = serverCreated;
91
- this.createdBy = createdBy;
92
- this.modified = modified;
93
- this.serverModified = serverModified;
94
- this.modifiedBy = modifiedBy;
95
- this.createdByName = createdByName;
96
- this.modifiedByName = modifiedByName;
97
- this.email = email;
98
- this.name = name;
99
- this.username = username;
100
- this.memberships = memberships;
101
- this.instructionProviders = instructionProviders;
102
- this.accounts = accounts;
103
- this.tokens = tokens;
104
- this.topics = topics;
105
- this.language = language;
106
- this.displayName = displayName;
107
- }
108
- static fromDto(dto) {
109
- return new VasFireUserModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.email || '', dto.name || '', dto.username || '', dto.memberships || [], dto.instructionProviders || [], dto.accounts || {}, dto.tokens || [], dto.topics || [], dto.language || '', dto.displayName || '');
110
- }
111
- static newUser(uid, displayName, email) {
112
- return new VasFireUserModel(uid, moment().toISOString(), moment().toISOString(), uid, moment().toISOString(), moment().toISOString(), uid, '', '', email, displayName, email, [], [], {}, [], [], '', displayName);
113
- }
114
- toDto() {
115
- return {
116
- id: this.id,
117
- created: this.created,
118
- serverCreated: this.serverCreated,
119
- createdBy: this.createdBy,
120
- modified: this.modified,
121
- serverModified: this.serverModified,
122
- modifiedBy: this.modifiedBy,
123
- createdByName: this.createdByName,
124
- modifiedByName: this.modifiedByName,
125
- email: this.email,
126
- name: this.name,
127
- username: this.username,
128
- memberships: this.memberships,
129
- instructionProviders: this.instructionProviders,
130
- accounts: this.accounts,
131
- tokens: this.tokens,
132
- topics: this.topics,
133
- language: this.language,
134
- displayName: this.displayName
135
- };
136
- }
137
- /**
138
- * Adds token to tokens list if it is not already present
139
- * @param token the new token
140
- */
141
- addToken(token) {
142
- if (this.tokens.includes(token)) {
143
- return;
144
- }
145
- this.tokens.push(token);
146
- }
147
- /**
148
- * Remove token from tokens list
149
- * @param token the token to remove
150
- */
151
- removeToken(token) {
152
- this.tokens = this.tokens.filter(t => t !== token);
153
- }
154
- /**
155
- * Resets the tokens list
156
- */
157
- resetTokens() {
158
- this.tokens = [];
159
- }
160
- /**
161
- * Adds topic to topics list if it is not already present
162
- * @param topic the new token
163
- */
164
- addTopic(topic) {
165
- if (this.topics.includes(topic)) {
166
- return;
167
- }
168
- this.topics.push(topic);
169
- }
170
- /**
171
- * Remove topic from topic list
172
- * @param topic the topic to remove
173
- */
174
- removeTopic(topic) {
175
- this.topics = this.topics.filter(t => t !== topic);
176
- }
177
- /**
178
- * Resets the topic list
179
- */
180
- resetTopics() {
181
- this.topics = [];
182
- }
183
- }
184
-
185
- var VasAccountIndexingMode;
186
- (function (VasAccountIndexingMode) {
187
- VasAccountIndexingMode[VasAccountIndexingMode["DISABLED"] = 0] = "DISABLED";
188
- VasAccountIndexingMode[VasAccountIndexingMode["ON_CHANGE"] = 1] = "ON_CHANGE";
189
- VasAccountIndexingMode[VasAccountIndexingMode["ON_REPORT"] = 2] = "ON_REPORT";
190
- })(VasAccountIndexingMode || (VasAccountIndexingMode = {}));
191
-
192
- class VasAccountObjectModel extends VasBaseModel {
193
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account) {
194
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName);
195
- this.id = id;
196
- this.created = created;
197
- this.serverCreated = serverCreated;
198
- this.createdBy = createdBy;
199
- this.modified = modified;
200
- this.serverModified = serverModified;
201
- this.modifiedBy = modifiedBy;
202
- this.createdByName = createdByName;
203
- this.modifiedByName = modifiedByName;
204
- this.account = account;
205
- }
206
- toApiDto(options) {
207
- return {
208
- id: this.id,
209
- created: this.created,
210
- modified: this.modified
211
- };
212
- }
213
- }
214
-
215
- class VasRestrictedAccountObjectModel extends VasAccountObjectModel {
216
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup) {
217
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
218
- this.id = id;
219
- this.created = created;
220
- this.serverCreated = serverCreated;
221
- this.createdBy = createdBy;
222
- this.modified = modified;
223
- this.serverModified = serverModified;
224
- this.modifiedBy = modifiedBy;
225
- this.createdByName = createdByName;
226
- this.modifiedByName = modifiedByName;
227
- this.account = account;
228
- this.accessGroup = accessGroup;
229
- }
230
- toApiDto(options) {
231
- return Object.assign(Object.assign({}, super.toApiDto(options)), { accessGroup: this.accessGroup });
232
- }
233
- }
234
-
235
- class VasBranchModel extends VasRestrictedAccountObjectModel {
236
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, branchType, storeCode, address, city, postcode, email, locationManager, areaManager, regionalDirector, salesManager, cluster, hourWeekdays, hourSaturday, hourSunday, exceptions, active) {
237
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
238
- this.id = id;
239
- this.created = created;
240
- this.serverCreated = serverCreated;
241
- this.createdBy = createdBy;
242
- this.modified = modified;
243
- this.serverModified = serverModified;
244
- this.modifiedBy = modifiedBy;
245
- this.createdByName = createdByName;
246
- this.modifiedByName = modifiedByName;
247
- this.account = account;
248
- this.accessGroup = accessGroup;
249
- this.branchType = branchType;
250
- this.storeCode = storeCode;
251
- this.address = address;
252
- this.city = city;
253
- this.postcode = postcode;
254
- this.email = email;
255
- this.locationManager = locationManager;
256
- this.areaManager = areaManager;
257
- this.regionalDirector = regionalDirector;
258
- this.salesManager = salesManager;
259
- this.cluster = cluster;
260
- this.hourWeekdays = hourWeekdays;
261
- this.hourSaturday = hourSaturday;
262
- this.hourSunday = hourSunday;
263
- this.exceptions = exceptions;
264
- this.active = active;
265
- }
266
- static fromDto(dto) {
267
- return new VasBranchModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.branchType || '', dto.storeCode || '', dto.address || '', dto.city || '', dto.postcode || '', dto.email || '', dto.locationManager || undefined, dto.areaManager || undefined, dto.regionalDirector || undefined, dto.salesManager || undefined, dto.cluster || '', dto.hourWeekdays || [], dto.hourSaturday || [], dto.hourSunday || [], dto.exceptions || '', dto.active || true);
268
- }
269
- toDto() {
270
- return {
271
- id: this.id,
272
- created: this.created,
273
- serverCreated: this.serverCreated,
274
- createdBy: this.createdBy,
275
- modified: this.modified,
276
- serverModified: this.serverModified,
277
- modifiedBy: this.modifiedBy,
278
- createdByName: this.createdByName,
279
- modifiedByName: this.modifiedByName,
280
- account: this.account,
281
- accessGroup: this.accessGroup,
282
- branchType: this.branchType,
283
- storeCode: this.storeCode,
284
- address: this.address,
285
- city: this.city,
286
- postcode: this.postcode,
287
- email: this.email,
288
- locationManager: this.locationManager,
289
- areaManager: this.areaManager,
290
- regionalDirector: this.regionalDirector,
291
- salesManager: this.salesManager,
292
- cluster: this.cluster,
293
- hourWeekdays: this.hourWeekdays,
294
- hourSaturday: this.hourSaturday,
295
- hourSunday: this.hourSunday,
296
- exceptions: this.exceptions,
297
- active: this.active
298
- };
299
- }
300
- }
301
-
302
- /**
303
- * Return an object with only the properties specified by key(s)
304
- *
305
- * @param obj object to be processed
306
- * @param omitKey key or array of keys to be kept
307
- */
308
- const only = (obj, omitKey) => {
309
- return Object.keys(obj).reduce((result, key) => {
310
- if (Array.isArray(omitKey)) {
311
- if (omitKey.includes(key)) {
312
- result[key] = obj[key];
313
- }
314
- }
315
- else {
316
- if (omitKey === key) {
317
- result[key] = obj[key];
318
- }
319
- }
320
- return result;
321
- }, {});
322
- };
323
-
324
- class VasContactModel extends VasRestrictedAccountObjectModel {
325
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, contactType, name, email, mobile, phone, address, address2, address3, billingCode, business, fax, vatNumber, website) {
326
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
327
- this.id = id;
328
- this.created = created;
329
- this.serverCreated = serverCreated;
330
- this.createdBy = createdBy;
331
- this.modified = modified;
332
- this.serverModified = serverModified;
333
- this.modifiedBy = modifiedBy;
334
- this.createdByName = createdByName;
335
- this.modifiedByName = modifiedByName;
336
- this.account = account;
337
- this.accessGroup = accessGroup;
338
- this.contactType = contactType;
339
- this.name = name;
340
- this.email = email;
341
- this.mobile = mobile;
342
- this.phone = phone;
343
- this.address = address;
344
- this.address2 = address2;
345
- this.address3 = address3;
346
- this.billingCode = billingCode;
347
- this.business = business;
348
- this.fax = fax;
349
- this.vatNumber = vatNumber;
350
- this.website = website;
351
- }
352
- static fromDto(dto) {
353
- return new VasContactModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.contactType || '', dto.name || '', dto.email || '', dto.mobile || '', dto.phone || '', dto.address || '', dto.address2 || '', dto.address3 || '', dto.billingCode || '', dto.business || '', dto.fax || '', dto.vatNumber || '', dto.website || '');
354
- }
355
- toDto() {
356
- return {
357
- id: this.id,
358
- created: this.created,
359
- serverCreated: this.serverCreated,
360
- createdBy: this.createdBy,
361
- modified: this.modified,
362
- serverModified: this.serverModified,
363
- modifiedBy: this.modifiedBy,
364
- createdByName: this.createdByName,
365
- modifiedByName: this.modifiedByName,
366
- account: this.account,
367
- accessGroup: this.accessGroup,
368
- contactType: this.contactType,
369
- name: this.name,
370
- email: this.email,
371
- mobile: this.mobile,
372
- phone: this.phone,
373
- address: this.address,
374
- address2: this.address2,
375
- address3: this.address3,
376
- billingCode: this.billingCode,
377
- business: this.business,
378
- fax: this.fax,
379
- vatNumber: this.vatNumber,
380
- website: this.website,
381
- };
382
- }
383
- toApiDto(options) {
384
- return Object.assign(Object.assign({}, super.toApiDto()), { contactType: this.contactType || '~', name: this.name || '~', email: this.email || '~', mobile: this.mobile || '~', phone: this.phone || '~', address: this.address || '~', address2: this.address2 || '~', address3: this.address3 || '~', billingCode: this.billingCode || '~', business: this.business || '~', fax: this.fax || '~', vatNumber: this.vatNumber || '~', website: this.website || '~' });
385
- }
386
- static toApiPatchDto(contact) {
387
- return only(contact, [
388
- 'accessGroup',
389
- 'contactType',
390
- 'name',
391
- 'email',
392
- 'mobile',
393
- 'phone',
394
- 'address',
395
- 'address2',
396
- 'address3',
397
- 'billingCode',
398
- 'business',
399
- 'fax',
400
- 'vatNumber',
401
- 'website'
402
- ]);
403
- }
404
- }
405
-
406
- /**
407
- * VasControlTypeModel
408
- */
409
- class VasControlTypeModel extends VasBaseModel {
410
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, name) {
411
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName);
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.createdByName = createdByName;
420
- this.modifiedByName = modifiedByName;
421
- this.name = name;
422
- }
423
- /**
424
- * @return VasControlTypeModel
425
- */
426
- static empty() {
427
- return new VasControlTypeModel('', '', '', '', '', '', '', '', '', '');
428
- }
429
- /**
430
- * @param {VasControlTypeDto} dto
431
- * @return {VasControlTypeModel}
432
- */
433
- static fromDto(dto) {
434
- return new VasControlTypeModel(
435
- // eslint-disable-next-line new-cap
436
- dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.name || '');
437
- }
438
- /**
439
- * @return {VasControlTypeDto}
440
- */
441
- toDto() {
442
- return {
443
- id: this.id,
444
- created: this.created,
445
- serverCreated: this.serverCreated,
446
- createdBy: this.createdBy,
447
- modified: this.modified,
448
- serverModified: this.serverModified,
449
- modifiedBy: this.modifiedBy,
450
- createdByName: this.createdByName,
451
- modifiedByName: this.modifiedByName,
452
- name: this.name
453
- };
454
- }
455
- }
456
-
457
- /**
458
- * ControlModel
459
- */
460
- class VasControlModel extends VasRestrictedAccountObjectModel {
461
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, controlType, group, validators, name, title, linkable, sequence, description, defaultValue, config, descriptionImage, portalEnabled) {
462
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
463
- this.id = id;
464
- this.created = created;
465
- this.serverCreated = serverCreated;
466
- this.createdBy = createdBy;
467
- this.modified = modified;
468
- this.serverModified = serverModified;
469
- this.modifiedBy = modifiedBy;
470
- this.createdByName = createdByName;
471
- this.modifiedByName = modifiedByName;
472
- this.account = account;
473
- this.accessGroup = accessGroup;
474
- this.controlType = controlType;
475
- this.group = group;
476
- this.validators = validators;
477
- this.name = name;
478
- this.title = title;
479
- this.linkable = linkable;
480
- this.sequence = sequence;
481
- this.description = description;
482
- this.defaultValue = defaultValue;
483
- this.config = config;
484
- this.descriptionImage = descriptionImage;
485
- this.portalEnabled = portalEnabled;
486
- this.controlTypeId = '';
487
- if (typeof controlType === 'string') {
488
- this.controlTypeId = controlType;
489
- }
490
- else {
491
- this.controlTypeId = controlType.id;
492
- }
493
- }
494
- get controlTypeName() {
495
- var _a;
496
- return ((_a = this.controlType) === null || _a === void 0 ? void 0 : _a.name) || '';
497
- }
498
- /**
499
- * The defaultValue property is returned from the api as a string or number,
500
- * in the case of string, it maybe a json. This getter will return an
501
- * object if the value is a json string
502
- */
503
- get defaultValueDecoded() {
504
- if (this.defaultValue === '' && this.controlType) {
505
- switch (this.controlTypeName) {
506
- case 'branch':
507
- case 'camera':
508
- case 'contact': {
509
- return {};
510
- }
511
- case 'toggle': {
512
- return {
513
- checked: false, comment: ''
514
- };
515
- }
516
- }
517
- }
518
- return this.parseMaybeJson(this.defaultValue);
519
- }
520
- /**
521
- * Returns the name of this control to be used in the report templates
522
- * i.e. fields.foo -> foo
523
- * @return {string}
524
- */
525
- get reportTemplateName() {
526
- return this.name.replace(/^fields\./, '');
527
- }
528
- /**
529
- * @return {string}
530
- */
531
- get safeName() {
532
- return this.name;
533
- }
534
- /**
535
- * @return {VasControlModel}
536
- */
537
- static empty() {
538
- return VasControlModel.fromDto({
539
- // eslint-disable-next-line new-cap
540
- id: UUID.UUID()
541
- });
542
- }
543
- /**
544
- * @param {VasControlDto} dto
545
- * @return {VasControlModel}
546
- */
547
- static fromDto(dto) {
548
- const handleControlType = (c) => {
549
- if (c === undefined) {
550
- return VasControlTypeModel.empty();
551
- }
552
- else if (typeof c === 'string') {
553
- return VasControlTypeModel.fromDto({ id: c });
554
- }
555
- else {
556
- return VasControlTypeModel.fromDto(c);
557
- }
558
- };
559
- return new VasControlModel(
560
- // eslint-disable-next-line new-cap
561
- dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', handleControlType(dto.controlType), dto.group || '', dto.validators || [], dto.name || '', dto.title || '', dto.linkable || false, dto.sequence || 0, dto.description || '', dto.defaultValue || '', JSON.parse(dto.config || '{}'), dto.descriptionImage || '', dto.portalEnabled || false);
562
- }
563
- /**
564
- * @param {any} value the value to be parsed
565
- * @return {VasFieldDtoValue} the parsed value
566
- */
567
- parseMaybeJson(value) {
568
- if (typeof value !== 'string') {
569
- return value;
570
- }
571
- try {
572
- return JSON.parse(value);
573
- }
574
- catch (e) {
575
- return value;
576
- }
577
- }
578
- /**
579
- * @return {VasControlDto}
580
- */
581
- toDto() {
582
- return {
583
- id: this.id,
584
- created: this.created,
585
- serverCreated: this.serverCreated,
586
- createdBy: this.createdBy,
587
- modified: this.modified,
588
- serverModified: this.serverModified,
589
- modifiedBy: this.modifiedBy,
590
- createdByName: this.createdByName,
591
- modifiedByName: this.modifiedByName,
592
- account: this.account,
593
- accessGroup: this.accessGroup,
594
- controlType: this.controlType.toDto(),
595
- group: this.group,
596
- validators: this.validators,
597
- name: this.name,
598
- title: this.title,
599
- linkable: this.linkable,
600
- sequence: this.sequence,
601
- description: this.description,
602
- defaultValue: this.defaultValue,
603
- config: JSON.stringify(this.config),
604
- descriptionImage: this.descriptionImage,
605
- portalEnabled: this.portalEnabled
606
- };
607
- }
608
- toApiDto(options) {
609
- return Object.assign(Object.assign({}, super.toApiDto()), { title: this.title || '~', name: this.name || '~', portalEnabled: this.portalEnabled, sequence: this.sequence, description: this.description || '~', defaultValue: this.defaultValue, config: JSON.stringify(this.config), controlType: this.controlType.id, group: this.group, validators: this.validators, linkable: this.linkable });
610
- }
611
- }
612
-
613
- /**
614
- * VasJobDataModel
615
- */
616
- class VasJobDataModel extends VasAccountObjectModel {
617
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job) {
618
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
619
- this.id = id;
620
- this.created = created;
621
- this.serverCreated = serverCreated;
622
- this.createdBy = createdBy;
623
- this.modified = modified;
624
- this.serverModified = serverModified;
625
- this.modifiedBy = modifiedBy;
626
- this.createdByName = createdByName;
627
- this.modifiedByName = modifiedByName;
628
- this.account = account;
629
- this.job = job;
630
- }
631
- }
632
-
633
- /**
634
- * VasFieldModel
635
- */
636
- class VasFieldModel extends VasJobDataModel {
637
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, control, fieldJobPointers, value, version, controlName, controlTitle, controlTypeName) {
638
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job);
639
- this.id = id;
640
- this.created = created;
641
- this.serverCreated = serverCreated;
642
- this.createdBy = createdBy;
643
- this.modified = modified;
644
- this.serverModified = serverModified;
645
- this.modifiedBy = modifiedBy;
646
- this.createdByName = createdByName;
647
- this.modifiedByName = modifiedByName;
648
- this.account = account;
649
- this.job = job;
650
- this.control = control;
651
- this.fieldJobPointers = fieldJobPointers;
652
- this.value = value;
653
- this.version = version;
654
- this.controlName = controlName;
655
- this.controlTitle = controlTitle;
656
- this.controlTypeName = controlTypeName;
657
- }
658
- /**
659
- * @param {VasFieldDto} fieldDto
660
- * @return {VasFieldModel}
661
- */
662
- static fromDto(fieldDto) {
663
- return new VasFieldModel(fieldDto.id || '', fieldDto.created || '', fieldDto.serverCreated || '', fieldDto.createdBy || '', fieldDto.modified || '', fieldDto.serverModified || '', fieldDto.modifiedBy || '', fieldDto.createdByName || '', fieldDto.modifiedByName || '', fieldDto.account || '', fieldDto.job || '', fieldDto.control || '', fieldDto.fieldJobPointers || [], fieldDto.value || '', fieldDto.version || 0, fieldDto.controlName || '', fieldDto.controlTitle || '', fieldDto.controlTypeName || '');
664
- }
665
- /**
666
- * @return {VasFieldDto}
667
- */
668
- toDto() {
669
- return {
670
- id: this.id,
671
- created: this.created,
672
- serverCreated: this.serverCreated,
673
- createdBy: this.createdBy,
674
- modified: this.modified,
675
- serverModified: this.serverModified,
676
- modifiedBy: this.modifiedBy,
677
- createdByName: this.createdByName,
678
- modifiedByName: this.modifiedByName,
679
- account: this.account,
680
- job: this.job,
681
- control: this.control,
682
- fieldJobPointers: this.fieldJobPointers,
683
- value: this.value,
684
- version: this.version,
685
- controlName: this.controlName,
686
- controlTitle: this.controlTitle,
687
- controlTypeName: this.controlTypeName,
688
- };
689
- }
690
- /**
691
- * @return {object}
692
- */
693
- toApiDto() {
694
- return Object.assign(Object.assign({}, super.toApiDto()), { control: this.control, value: this.prepareApiValue(this.value) });
695
- }
696
- /**
697
- * Prepares the value to be sent to the API. The api will only accept strings,
698
- * numbers and booleans, thus if we have an array or object, we need to JSON
699
- * encode it
700
- * @param {VasFieldDto} value
701
- * @return {string | number | boolean}
702
- * @protected
703
- */
704
- prepareApiValue(value) {
705
- switch (typeof value) {
706
- case 'object': {
707
- return JSON.stringify(value);
708
- }
709
- case 'boolean': {
710
- return value;
711
- }
712
- case 'string': {
713
- return value;
714
- }
715
- case 'number': {
716
- return value;
717
- }
718
- default: {
719
- return '';
720
- }
721
- }
722
- }
723
- }
724
-
725
- function isFileDto(object) {
726
- return object instanceof Object
727
- && 'url' in object
728
- && 'uri' in object
729
- && 'message' in object
730
- && 'status' in object
731
- && 'controlPath' in object;
732
- }
733
-
734
- /**
735
- * VasFileDto
736
- */
737
- class VasFileModel extends VasJobDataModel {
738
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, name, fileSize, mimeType, sequence, config, url, controlPath, message, status, uri) {
739
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job);
740
- this.id = id;
741
- this.created = created;
742
- this.serverCreated = serverCreated;
743
- this.createdBy = createdBy;
744
- this.modified = modified;
745
- this.serverModified = serverModified;
746
- this.modifiedBy = modifiedBy;
747
- this.createdByName = createdByName;
748
- this.modifiedByName = modifiedByName;
749
- this.account = account;
750
- this.job = job;
751
- this.name = name;
752
- this.fileSize = fileSize;
753
- this.mimeType = mimeType;
754
- this.sequence = sequence;
755
- this.config = config;
756
- this.url = url;
757
- this.controlPath = controlPath;
758
- this.message = message;
759
- this.status = status;
760
- this.uri = uri;
761
- }
762
- static empty() {
763
- return new VasFileModel('', '', '', '', '', '', '', '', '', '', '', '', 0, '', 0, {
764
- displayAs: 'grid',
765
- embedLink: false,
766
- group: 'photo',
767
- description: '',
768
- displayedName: '',
769
- rotation: 0
770
- }, '', '', '', 'NEW', '');
771
- }
772
- static fromDto(dto) {
773
- return new VasFileModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job || '', dto.name || '', dto.fileSize || 0, dto.mimeType || '', dto.sequence || 0, VasFileModel.parseConfig(dto.config), dto.url || '', dto.controlPath || '', dto.message || '', dto.status || 'NEW', dto.uri || '');
774
- }
775
- static parseConfig(config = '') {
776
- try {
777
- return JSON.parse(config);
778
- }
779
- catch (e) {
780
- return {
781
- displayAs: 'grid',
782
- embedLink: false,
783
- group: 'photo',
784
- description: '',
785
- displayedName: '',
786
- rotation: 0
787
- };
788
- }
789
- }
790
- /**
791
- * @return {VasFileDto}
792
- */
793
- toDto() {
794
- return {
795
- id: this.id,
796
- created: this.created,
797
- serverCreated: this.serverCreated,
798
- createdBy: this.createdBy,
799
- modified: this.modified,
800
- serverModified: this.serverModified,
801
- modifiedBy: this.modifiedBy,
802
- createdByName: this.createdByName,
803
- modifiedByName: this.modifiedByName,
804
- account: this.account,
805
- job: this.job,
806
- name: this.name,
807
- fileSize: this.fileSize,
808
- mimeType: this.mimeType,
809
- sequence: this.sequence,
810
- config: this.stringifyConfig(this.config),
811
- url: this.url,
812
- controlPath: this.controlPath,
813
- message: this.message,
814
- status: this.status,
815
- uri: this.uri,
816
- };
817
- }
818
- stringifyConfig(config) {
819
- if (!config) {
820
- return JSON.stringify({
821
- displayAs: 'grid',
822
- embedLink: false,
823
- group: 'photo',
824
- description: '',
825
- displayedName: '',
826
- rotation: 0
827
- });
828
- }
829
- try {
830
- return JSON.stringify(config);
831
- }
832
- catch (e) {
833
- console.warn(e);
834
- return '';
835
- }
836
- }
837
- toApiDto(options = { contentUploaded: false }) {
838
- const apiDto = Object.assign(Object.assign({}, super.toApiDto()), { name: this.name || '~', mimeType: this.mimeType || '~', sequence: this.safeNumber(this.sequence), config: JSON.stringify(this.config) });
839
- if (options.contentUploaded) {
840
- apiDto['original'] = this.id;
841
- }
842
- return apiDto;
843
- }
844
- safeNumber(value) {
845
- if (!Number.isFinite(value)) {
846
- return 0;
847
- }
848
- return value;
849
- }
850
- }
851
-
852
- /**
853
- * GroupModel
854
- */
855
- class VasGroupModel extends VasRestrictedAccountObjectModel {
856
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, name, title, description, sequence, includeInSummary, forms, visibilityControl, visibleIfEquals, controls, scoreWeight) {
857
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
858
- this.id = id;
859
- this.created = created;
860
- this.serverCreated = serverCreated;
861
- this.createdBy = createdBy;
862
- this.modified = modified;
863
- this.serverModified = serverModified;
864
- this.modifiedBy = modifiedBy;
865
- this.createdByName = createdByName;
866
- this.modifiedByName = modifiedByName;
867
- this.account = account;
868
- this.accessGroup = accessGroup;
869
- this.name = name;
870
- this.title = title;
871
- this.description = description;
872
- this.sequence = sequence;
873
- this.includeInSummary = includeInSummary;
874
- this.forms = forms;
875
- this.visibilityControl = visibilityControl;
876
- this.visibleIfEquals = visibleIfEquals;
877
- this.controls = controls;
878
- this.scoreWeight = scoreWeight;
879
- }
880
- /**
881
- * @param {VasGroupDto} dto
882
- * @return {VasGroupModel}
883
- */
884
- static fromDto(dto) {
885
- return new VasGroupModel(
886
- // eslint-disable-next-line new-cap
887
- dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.name || '', dto.title || '', dto.description || '', dto.sequence || 0, dto.includeInSummary || false, dto.forms || [], dto.visibilityControl || '', dto.visibleIfEquals || '', (dto.controls || [])
888
- .filter(control => control.name.startsWith('fields.'))
889
- .sort((a, b) => a.sequence - b.sequence)
890
- .map(c => VasControlModel.fromDto(c)), dto.scoreWeight || 1);
891
- }
892
- /**
893
- * @param {Array<VasControlModel>} valuesByControlId
894
- * @return {boolean}
895
- */
896
- isVisible(valuesByControlId) {
897
- if (!this.visibilityControl || !this.visibleIfEquals) {
898
- return true;
899
- }
900
- const control = valuesByControlId
901
- .find(c => c.id === this.visibilityControl);
902
- if (!control) {
903
- console.warn(`control with id ${this.visibilityControl} not found`);
904
- return true;
905
- }
906
- return (control.value || '').toString() === this.visibleIfEquals;
907
- }
908
- /**
909
- * @return {VasGroupDto}
910
- */
911
- toDto() {
912
- return {
913
- id: this.id,
914
- created: this.created,
915
- serverCreated: this.serverCreated,
916
- createdBy: this.createdBy,
917
- modified: this.modified,
918
- serverModified: this.serverModified,
919
- modifiedBy: this.modifiedBy,
920
- createdByName: this.createdByName,
921
- modifiedByName: this.modifiedByName,
922
- account: this.account,
923
- accessGroup: this.accessGroup,
924
- name: this.name,
925
- title: this.title,
926
- description: this.description,
927
- sequence: this.sequence,
928
- includeInSummary: this.includeInSummary,
929
- forms: this.forms,
930
- visibilityControl: this.visibilityControl,
931
- visibleIfEquals: this.visibleIfEquals,
932
- controls: this.controls.map(control => control.toDto()),
933
- scoreWeight: this.scoreWeight
934
- };
935
- }
936
- toApiDto(options) {
937
- return Object.assign(Object.assign({}, super.toApiDto(options)), { name: this.name || '~', title: this.title || '~', sequence: this.sequence || 0, includeInSummary: this.includeInSummary });
938
- }
939
- }
940
-
941
- class VasFormConfigModel {
942
- constructor(emailRecipients, actions) {
943
- this.emailRecipients = emailRecipients;
944
- this.actions = actions;
945
- }
946
- toDto() {
947
- return {
948
- emailRecipients: this.emailRecipients,
949
- actions: this.actions
950
- };
951
- }
952
- toJsonString() {
953
- return JSON.stringify(this.toDto());
954
- }
955
- static create() {
956
- return new VasFormConfigModel();
957
- }
958
- static fromDto(dto) {
959
- return new VasFormConfigModel(dto.emailRecipients, dto.actions);
960
- }
961
- static fromJsonString(value) {
962
- try {
963
- const dto = JSON.parse(value || '{}');
964
- return VasFormConfigModel.fromDto(dto);
965
- }
966
- catch (e) {
967
- return VasFormConfigModel.create();
968
- }
969
- }
970
- }
971
-
972
- /**
973
- * VasFormModel
974
- */
975
- class VasFormModel extends VasRestrictedAccountObjectModel {
976
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, jobType, title, description, groups, dynamicDescriptor, indexName, pipelineName, config, geoLocationEnabled, filesEnabled) {
977
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
978
- this.id = id;
979
- this.created = created;
980
- this.serverCreated = serverCreated;
981
- this.createdBy = createdBy;
982
- this.modified = modified;
983
- this.serverModified = serverModified;
984
- this.modifiedBy = modifiedBy;
985
- this.createdByName = createdByName;
986
- this.modifiedByName = modifiedByName;
987
- this.account = account;
988
- this.accessGroup = accessGroup;
989
- this.jobType = jobType;
990
- this.title = title;
991
- this.description = description;
992
- this.groups = groups;
993
- this.dynamicDescriptor = dynamicDescriptor;
994
- this.indexName = indexName;
995
- this.pipelineName = pipelineName;
996
- this.config = config;
997
- this.geoLocationEnabled = geoLocationEnabled;
998
- this.filesEnabled = filesEnabled;
999
- }
1000
- /**
1001
- * Returns the name of this form in a "safe" way, i.e. no spaces, special
1002
- * characters
1003
- * @return {string}
1004
- */
1005
- get safeTitle() {
1006
- return this.title
1007
- .replace(/[^a-z0-9]/gi, '-')
1008
- .replace(/-+/g, '-')
1009
- .toLowerCase();
1010
- }
1011
- /**
1012
- * The VAS API response for Form will inline Group and Control but not
1013
- * ControlType. This method is a help which will allows us to construct an
1014
- * instance of VasFormModel with the ControlType model set appropriately into
1015
- * each VasControlModel
1016
- * @param {VasFormDto} formDto
1017
- * @param {Array<VasControlTypeDto>} controlTypeDtos
1018
- * @return {VasFormModel}
1019
- * @deprecated vas-rest has been updated to inline control types into the
1020
- * control so this method is no longer required. use VasFormModel.fromDto()
1021
- */
1022
- static fromApiResponse(formDto, controlTypeDtos) {
1023
- const controlTypeModels = controlTypeDtos
1024
- .map(ctDto => VasControlTypeModel.fromDto(ctDto));
1025
- const formModel = VasFormModel.fromDto(formDto);
1026
- formModel.groups
1027
- .forEach(group => {
1028
- group.controls
1029
- .forEach(control => {
1030
- // Note that we are forcing types here. This is because we have
1031
- // updated the typings for ControlModel and ControlDto to reflect
1032
- // the fact that VASREST is updating the response from certain
1033
- // controllers to inline ControlType into the Control. Consumers of
1034
- // the library will know what version of the API they are consuming
1035
- // so can decide when to migrate away from fromApiResponse, and can
1036
- // use fromDto instead
1037
- control.controlType = controlTypeModels
1038
- .find(ct => ct.id === (control.controlTypeId));
1039
- });
1040
- });
1041
- return formModel;
1042
- }
1043
- static empty() {
1044
- return VasFormModel.fromDto({});
1045
- }
1046
- /**
1047
- * @param {VasFormDto} dto
1048
- * @return {VasFormModel}
1049
- */
1050
- static fromDto(dto) {
1051
- return new VasFormModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.accessGroup || '', dto.jobType || '', dto.title || '', dto.description || '', (dto.groups || [])
1052
- .sort((a, b) => a.sequence - b.sequence)
1053
- .map(g => VasGroupModel.fromDto(g)), dto.dynamicDescriptor || '', dto.indexName || '', dto.pipelineName || '', VasFormConfigModel.fromJsonString(dto.config), dto.geoLocationEnabled || false, dto.filesEnabled || false);
1054
- }
1055
- /**
1056
- * @param {string} id
1057
- * @return {VasControlModel | undefined}
1058
- */
1059
- findControlModelById(id) {
1060
- let result;
1061
- this.groups
1062
- .find(group => group.controls
1063
- .find(control => {
1064
- if (control.id !== id) {
1065
- return;
1066
- }
1067
- result = control;
1068
- return true;
1069
- }));
1070
- return result;
1071
- }
1072
- /**
1073
- *
1074
- * @param {string} name
1075
- * @return {VasControlModel | undefined}
1076
- */
1077
- findControlModelByName(name) {
1078
- let result;
1079
- this.groups
1080
- .find(group => group.controls
1081
- .find(control => {
1082
- if (control.name !== name) {
1083
- return;
1084
- }
1085
- result = control;
1086
- return true;
1087
- }));
1088
- return result;
1089
- }
1090
- /**
1091
- *
1092
- * @return {Array<Array<string>>}
1093
- */
1094
- getCameraControlPaths() {
1095
- const paths = [];
1096
- this.groups.forEach(group => {
1097
- group.controls.forEach(control => {
1098
- if (control.controlTypeName !== 'camera') {
1099
- return;
1100
- }
1101
- paths.push([group.name, control.safeName]);
1102
- });
1103
- });
1104
- return paths;
1105
- }
1106
- /**
1107
- * Return all Controls in the Form
1108
- */
1109
- getControls() {
1110
- return this.groups
1111
- .reduce((acc, g) => {
1112
- return acc.concat(g.controls);
1113
- }, []);
1114
- }
1115
- /**
1116
- * @param {VasJobModel} jobModel
1117
- * @return {Array<{id: string, value: VasFieldDtoValue}>}
1118
- */
1119
- getValuesByControlId(jobModel) {
1120
- const items = [];
1121
- this.groups
1122
- .forEach(group => {
1123
- group.controls
1124
- .forEach(control => {
1125
- items.push({
1126
- id: control.id,
1127
- value: jobModel.getValueByPath([group.name, control.safeName])
1128
- });
1129
- });
1130
- });
1131
- return items;
1132
- }
1133
- /**
1134
- * @return {VasFormDto}
1135
- */
1136
- toDto() {
1137
- return {
1138
- id: this.id,
1139
- created: this.created,
1140
- serverCreated: this.serverCreated,
1141
- createdBy: this.createdBy,
1142
- modified: this.modified,
1143
- serverModified: this.serverModified,
1144
- modifiedBy: this.modifiedBy,
1145
- createdByName: this.createdByName,
1146
- modifiedByName: this.modifiedByName,
1147
- account: this.account,
1148
- accessGroup: this.accessGroup,
1149
- jobType: this.jobType,
1150
- title: this.title,
1151
- description: this.description,
1152
- groups: this.groups.map(group => group.toDto()),
1153
- dynamicDescriptor: this.dynamicDescriptor,
1154
- indexName: this.indexName,
1155
- pipelineName: this.pipelineName,
1156
- config: this.config.toJsonString(),
1157
- geoLocationEnabled: this.geoLocationEnabled,
1158
- filesEnabled: this.filesEnabled
1159
- };
1160
- }
1161
- toApiDto(options) {
1162
- return Object.assign(Object.assign({}, super.toApiDto(options)), { title: this.title || '~', description: this.description || '~', jobType: this.jobType });
1163
- }
1164
- }
1165
-
1166
- var VasInvitationTypeEnum;
1167
- (function (VasInvitationTypeEnum) {
1168
- VasInvitationTypeEnum["TYPE_VAS_DESKTOP"] = "vas-desktop";
1169
- VasInvitationTypeEnum["TYPE_VAS_MOBILE"] = "vas-mobile";
1170
- VasInvitationTypeEnum["TYPE_VAS_PORTAL"] = "vas-portal";
1171
- VasInvitationTypeEnum["TYPE_P2C_DESKTOP"] = "p2c-desktop";
1172
- VasInvitationTypeEnum["TYPE_P2C_MOBILE"] = "p2c-mobile";
1173
- })(VasInvitationTypeEnum || (VasInvitationTypeEnum = {}));
1174
- class VasInvitationModel extends VasAccountObjectModel {
1175
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, secret, type, accessGroups, contactTypes, jobStatuses, jobTypes, lookupTypes, taskTypes, instructionProviders) {
1176
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
1177
- this.id = id;
1178
- this.created = created;
1179
- this.serverCreated = serverCreated;
1180
- this.createdBy = createdBy;
1181
- this.modified = modified;
1182
- this.serverModified = serverModified;
1183
- this.modifiedBy = modifiedBy;
1184
- this.createdByName = createdByName;
1185
- this.modifiedByName = modifiedByName;
1186
- this.account = account;
1187
- this.secret = secret;
1188
- this.type = type;
1189
- this.accessGroups = accessGroups;
1190
- this.contactTypes = contactTypes;
1191
- this.jobStatuses = jobStatuses;
1192
- this.jobTypes = jobTypes;
1193
- this.lookupTypes = lookupTypes;
1194
- this.taskTypes = taskTypes;
1195
- this.instructionProviders = instructionProviders;
1196
- }
1197
- toDto() {
1198
- return {
1199
- id: this.id,
1200
- created: this.created,
1201
- serverCreated: this.serverCreated,
1202
- createdBy: this.createdBy,
1203
- modified: this.modified,
1204
- serverModified: this.serverModified,
1205
- modifiedBy: this.modifiedBy,
1206
- createdByName: this.createdByName,
1207
- modifiedByName: this.modifiedByName,
1208
- account: this.account,
1209
- secret: this.secret,
1210
- type: this.type,
1211
- accessGroups: this.accessGroups,
1212
- contactTypes: this.contactTypes,
1213
- jobStatuses: this.jobStatuses,
1214
- jobTypes: this.jobTypes,
1215
- lookupTypes: this.lookupTypes,
1216
- taskTypes: this.taskTypes,
1217
- instructionProviders: this.instructionProviders,
1218
- };
1219
- }
1220
- static fromDto(dto) {
1221
- return new VasInvitationModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.secret || '', dto.type || VasInvitationTypeEnum.TYPE_VAS_PORTAL, dto.accessGroups || [], dto.contactTypes || [], dto.jobStatuses || [], dto.jobTypes || [], dto.lookupTypes || [], dto.taskTypes || [], dto.instructionProviders || []);
1222
- }
1223
- toApiDto(options) {
1224
- const dto = Object.assign(Object.assign({}, super.toApiDto()), { type: this.type });
1225
- if (this.accessGroups.length) {
1226
- dto['accessGroups'] = this.accessGroups.map(d => d.id);
1227
- }
1228
- if (this.contactTypes.length) {
1229
- dto['contactTypes'] = this.contactTypes.map(d => d.id);
1230
- }
1231
- if (this.jobStatuses.length) {
1232
- dto['jobStatuses'] = this.jobStatuses.map(d => d.id);
1233
- }
1234
- if (this.jobTypes.length) {
1235
- dto['jobTypes'] = this.jobTypes.map(d => d.id);
1236
- }
1237
- if (this.lookupTypes.length) {
1238
- dto['lookupTypes'] = this.lookupTypes.map(d => d.id);
1239
- }
1240
- if (this.taskTypes.length) {
1241
- dto['taskTypes'] = this.taskTypes.map(d => d.id);
1242
- }
1243
- if (this.instructionProviders.length) {
1244
- dto['instructionProviders'] = this.instructionProviders.map(d => d.id);
1245
- }
1246
- return dto;
1247
- }
1248
- }
1249
-
1250
- /**
1251
- * VasNoteModel
1252
- */
1253
- class VasNoteModel extends VasJobDataModel {
1254
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, content, sensitive) {
1255
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job);
1256
- this.id = id;
1257
- this.created = created;
1258
- this.serverCreated = serverCreated;
1259
- this.createdBy = createdBy;
1260
- this.modified = modified;
1261
- this.serverModified = serverModified;
1262
- this.modifiedBy = modifiedBy;
1263
- this.createdByName = createdByName;
1264
- this.modifiedByName = modifiedByName;
1265
- this.account = account;
1266
- this.job = job;
1267
- this.content = content;
1268
- this.sensitive = sensitive;
1269
- }
1270
- /**
1271
- * @param dto VasNoteDto
1272
- * @return VasNoteModel
1273
- */
1274
- static fromDto(dto) {
1275
- return new VasNoteModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job || '', dto.content || '', dto.sensitive || false);
1276
- }
1277
- /**
1278
- * @returns VasNoteDto
1279
- */
1280
- toDto() {
1281
- return {
1282
- id: this.id,
1283
- created: this.created,
1284
- serverCreated: this.serverCreated,
1285
- createdBy: this.createdBy,
1286
- modified: this.modified,
1287
- serverModified: this.serverModified,
1288
- modifiedBy: this.modifiedBy,
1289
- createdByName: this.createdByName,
1290
- modifiedByName: this.modifiedByName,
1291
- account: this.account,
1292
- job: this.job,
1293
- content: this.content,
1294
- sensitive: this.sensitive,
1295
- };
1296
- }
1297
- toApiDto(options) {
1298
- return Object.assign(Object.assign({}, super.toApiDto(options)), { content: this.content, sensitive: this.sensitive, created: this.created, modified: this.modified });
1299
- }
1300
- }
1301
-
1302
- /**
1303
- * VasInstructionJobFieldModel
1304
- */
1305
- class VasInstructionJobFieldModel extends VasBaseModel {
1306
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, value, name, title, sequence, controlType) {
1307
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName);
1308
- this.id = id;
1309
- this.created = created;
1310
- this.serverCreated = serverCreated;
1311
- this.createdBy = createdBy;
1312
- this.modified = modified;
1313
- this.serverModified = serverModified;
1314
- this.modifiedBy = modifiedBy;
1315
- this.createdByName = createdByName;
1316
- this.modifiedByName = modifiedByName;
1317
- this.value = value;
1318
- this.name = name;
1319
- this.title = title;
1320
- this.sequence = sequence;
1321
- this.controlType = controlType;
1322
- }
1323
- static empty() {
1324
- return new VasInstructionJobFieldModel('', '', '', '', '', '', '', '', '', '', '', '', 0, '');
1325
- }
1326
- static fromDto(dto) {
1327
- return new VasInstructionJobFieldModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.value || '', dto.name || '', dto.title || '', dto.sequence || 0, dto.controlType || '');
1328
- }
1329
- toDto() {
1330
- return {
1331
- id: this.id,
1332
- created: this.created,
1333
- serverCreated: this.serverCreated,
1334
- createdBy: this.createdBy,
1335
- modified: this.modified,
1336
- serverModified: this.serverModified,
1337
- modifiedBy: this.modifiedBy,
1338
- createdByName: this.createdByName,
1339
- modifiedByName: this.modifiedByName,
1340
- value: this.value,
1341
- name: this.name,
1342
- title: this.title,
1343
- sequence: this.sequence,
1344
- controlType: this.controlType
1345
- };
1346
- }
1347
- }
1348
-
1349
- class VasReportModel extends VasJobDataModel {
1350
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, reportLayoutId, title, sendEmail, message, attempted, completed, succeeded, attempts, notificationId) {
1351
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job);
1352
- this.id = id;
1353
- this.created = created;
1354
- this.serverCreated = serverCreated;
1355
- this.createdBy = createdBy;
1356
- this.modified = modified;
1357
- this.serverModified = serverModified;
1358
- this.modifiedBy = modifiedBy;
1359
- this.createdByName = createdByName;
1360
- this.modifiedByName = modifiedByName;
1361
- this.account = account;
1362
- this.job = job;
1363
- this.reportLayoutId = reportLayoutId;
1364
- this.title = title;
1365
- this.sendEmail = sendEmail;
1366
- this.message = message;
1367
- this.attempted = attempted;
1368
- this.completed = completed;
1369
- this.succeeded = succeeded;
1370
- this.attempts = attempts;
1371
- this.notificationId = notificationId;
1372
- }
1373
- static empty() {
1374
- return VasReportModel.fromDto({});
1375
- }
1376
- static fromDto(dto) {
1377
- return new VasReportModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job || '', dto.reportLayoutId || '', dto.title || '', dto.sendEmail || '', dto.message || '', dto.attempted || '', dto.completed || '', dto.succeeded || '', dto.attempts || 0, dto.notificationId || '');
1378
- }
1379
- toDto() {
1380
- return {
1381
- id: this.id,
1382
- created: this.created,
1383
- serverCreated: this.serverCreated,
1384
- createdBy: this.createdBy,
1385
- modified: this.modified,
1386
- serverModified: this.serverModified,
1387
- modifiedBy: this.modifiedBy,
1388
- createdByName: this.createdByName,
1389
- modifiedByName: this.modifiedByName,
1390
- account: this.account,
1391
- job: this.job,
1392
- reportLayoutId: this.reportLayoutId,
1393
- title: this.title,
1394
- sendEmail: this.sendEmail,
1395
- message: this.message,
1396
- attempted: this.attempted,
1397
- completed: this.completed,
1398
- succeeded: this.succeeded,
1399
- attempts: this.attempts,
1400
- notificationId: this.notificationId,
1401
- };
1402
- }
1403
- }
1404
-
1405
- /**
1406
- * VasNoteModel
1407
- */
1408
- class VasInstructionJobModel extends VasBaseModel {
1409
- /**
1410
- * @param id id
1411
- * @param created created
1412
- * @param serverCreated serverCreated
1413
- * @param createdBy createdBy
1414
- * @param modified modified
1415
- * @param serverModified serverModified
1416
- * @param modifiedBy modifiedBy
1417
- * @param reference reference
1418
- * @param jobStatus jobStatus
1419
- * @param createdByName createdByName
1420
- * @param modifiedByName modifiedByName
1421
- * @param notes notes
1422
- * @param fields fields
1423
- * @param files files
1424
- * @param reports reports
1425
- */
1426
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, reference, jobStatus, notes, fields, files, reports) {
1427
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName);
1428
- this.id = id;
1429
- this.created = created;
1430
- this.serverCreated = serverCreated;
1431
- this.createdBy = createdBy;
1432
- this.modified = modified;
1433
- this.serverModified = serverModified;
1434
- this.modifiedBy = modifiedBy;
1435
- this.createdByName = createdByName;
1436
- this.modifiedByName = modifiedByName;
1437
- this.reference = reference;
1438
- this.jobStatus = jobStatus;
1439
- this.notes = notes;
1440
- this.fields = fields;
1441
- this.files = files;
1442
- this.reports = reports;
1443
- }
1444
- /**
1445
- * @return empty VasInstructionJobModel
1446
- */
1447
- static empty() {
1448
- return new VasInstructionJobModel('', '', '', '', '', '', '', '', '', '', '', [], [], [], []);
1449
- }
1450
- /**
1451
- * @param dto VasInstructionDto
1452
- * @return VasInstructionModel
1453
- */
1454
- static fromDto(dto) {
1455
- return new VasInstructionJobModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.reference || '', dto.jobStatus || '', dto.createdByName || '', dto.modifiedByName || '', (dto.notes || []).map(d => VasNoteModel.fromDto(d)), (dto.fields || []).map(d => VasInstructionJobFieldModel.fromDto(d)), (dto.files || []).map(d => VasFileModel.fromDto(d)), (dto.reports || []).map(d => VasReportModel.fromDto(d)));
1456
- }
1457
- /**
1458
- * @returns VasNoteDto
1459
- */
1460
- toDto() {
1461
- return {
1462
- id: this.id,
1463
- created: this.created,
1464
- serverCreated: this.serverCreated,
1465
- createdBy: this.createdBy,
1466
- modified: this.modified,
1467
- serverModified: this.serverModified,
1468
- modifiedBy: this.modifiedBy,
1469
- reference: this.reference,
1470
- jobStatus: this.jobStatus,
1471
- createdByName: this.createdByName,
1472
- modifiedByName: this.modifiedByName,
1473
- notes: this.notes.map(m => m.toDto()),
1474
- fields: this.fields.map(m => m.toDto()),
1475
- files: this.files.map(m => m.toDto()),
1476
- reports: this.reports.map(m => m.toDto()),
1477
- };
1478
- }
1479
- }
1480
-
1481
- /**
1482
- * VasInstructionProviderModel
1483
- */
1484
- class VasInstructionProviderModel extends VasAccountObjectModel {
1485
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, form, title, secret, portalEnabled, portalVisible) {
1486
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
1487
- this.id = id;
1488
- this.created = created;
1489
- this.serverCreated = serverCreated;
1490
- this.createdBy = createdBy;
1491
- this.modified = modified;
1492
- this.serverModified = serverModified;
1493
- this.modifiedBy = modifiedBy;
1494
- this.createdByName = createdByName;
1495
- this.modifiedByName = modifiedByName;
1496
- this.account = account;
1497
- this.form = form;
1498
- this.title = title;
1499
- this.secret = secret;
1500
- this.portalEnabled = portalEnabled;
1501
- this.portalVisible = portalVisible;
1502
- }
1503
- /**
1504
- * @param dto VasInstructionDto
1505
- * @return VasInstructionModel
1506
- */
1507
- static fromDto(dto) {
1508
- return new VasInstructionProviderModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.form ?
1509
- VasFormModel.fromDto(dto.form) :
1510
- VasFormModel.empty(), dto.title || '', dto.secret || '', dto.portalEnabled || false, dto.portalVisible || true);
1511
- }
1512
- /**
1513
- * @returns VasNoteDto
1514
- */
1515
- toDto() {
1516
- return {
1517
- id: this.id,
1518
- created: this.created,
1519
- serverCreated: this.serverCreated,
1520
- createdBy: this.createdBy,
1521
- modified: this.modified,
1522
- serverModified: this.serverModified,
1523
- modifiedBy: this.modifiedBy,
1524
- createdByName: this.createdByName,
1525
- modifiedByName: this.modifiedByName,
1526
- account: this.account,
1527
- form: this.form.toDto(),
1528
- title: this.title,
1529
- secret: this.secret,
1530
- portalEnabled: this.portalEnabled,
1531
- portalVisible: this.portalVisible
1532
- };
1533
- }
1534
- toApiDto(options) {
1535
- return Object.assign(Object.assign({}, super.toApiDto(options)), { title: this.title, form: this.form.id, portalEnabled: this.portalEnabled, portalVisible: this.portalVisible });
1536
- }
1537
- }
1538
-
1539
- /**
1540
- * VasNoteModel
1541
- */
1542
- class VasInstructionModel extends VasAccountObjectModel {
1543
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, instructionProvider) {
1544
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
1545
- this.id = id;
1546
- this.created = created;
1547
- this.serverCreated = serverCreated;
1548
- this.createdBy = createdBy;
1549
- this.modified = modified;
1550
- this.serverModified = serverModified;
1551
- this.modifiedBy = modifiedBy;
1552
- this.createdByName = createdByName;
1553
- this.modifiedByName = modifiedByName;
1554
- this.account = account;
1555
- this.job = job;
1556
- this.instructionProvider = instructionProvider;
1557
- }
1558
- /**
1559
- * @param dto VasInstructionDto
1560
- * @return VasInstructionModel
1561
- */
1562
- static fromDto(dto) {
1563
- return new VasInstructionModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job ?
1564
- VasInstructionJobModel.fromDto(dto.job) :
1565
- VasInstructionJobModel.empty(), VasInstructionProviderModel.fromDto(dto.instructionProvider || {}));
1566
- }
1567
- /**
1568
- * @returns VasNoteDto
1569
- */
1570
- toDto() {
1571
- return {
1572
- id: this.id,
1573
- created: this.created,
1574
- serverCreated: this.serverCreated,
1575
- createdBy: this.createdBy,
1576
- modified: this.modified,
1577
- serverModified: this.serverModified,
1578
- modifiedBy: this.modifiedBy,
1579
- createdByName: this.createdByName,
1580
- modifiedByName: this.modifiedByName,
1581
- account: this.account,
1582
- job: this.job.toDto(),
1583
- instructionProvider: this.instructionProvider.toDto()
1584
- };
1585
- }
1586
- }
1587
-
1588
- class VasJobEmailModel extends VasJobDataModel {
1589
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, body, cc, files, message, recipients, replyTo, reports, sender, sentTime, subject, succeeded) {
1590
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job);
1591
- this.id = id;
1592
- this.created = created;
1593
- this.serverCreated = serverCreated;
1594
- this.createdBy = createdBy;
1595
- this.modified = modified;
1596
- this.serverModified = serverModified;
1597
- this.modifiedBy = modifiedBy;
1598
- this.createdByName = createdByName;
1599
- this.modifiedByName = modifiedByName;
1600
- this.account = account;
1601
- this.job = job;
1602
- this.body = body;
1603
- this.cc = cc;
1604
- this.files = files;
1605
- this.message = message;
1606
- this.recipients = recipients;
1607
- this.replyTo = replyTo;
1608
- this.reports = reports;
1609
- this.sender = sender;
1610
- this.sentTime = sentTime;
1611
- this.subject = subject;
1612
- this.succeeded = succeeded;
1613
- }
1614
- static fromDto(dto) {
1615
- return new VasJobEmailModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job || '', dto.body || '', dto.cc || [], dto.files || [], dto.message || '', dto.recipients || [], dto.replyTo || '', dto.reports || [], dto.sender || '', dto.sentTime || '', dto.subject || '', dto.succeeded || false);
1616
- }
1617
- toDto() {
1618
- return {
1619
- id: this.id,
1620
- created: this.created,
1621
- serverCreated: this.serverCreated,
1622
- createdBy: this.createdBy,
1623
- modified: this.modified,
1624
- serverModified: this.serverModified,
1625
- modifiedBy: this.modifiedBy,
1626
- createdByName: this.createdByName,
1627
- modifiedByName: this.modifiedByName,
1628
- account: this.account,
1629
- job: this.job,
1630
- body: this.body,
1631
- cc: this.cc,
1632
- files: this.files,
1633
- message: this.message,
1634
- recipients: this.recipients,
1635
- replyTo: this.replyTo,
1636
- reports: this.reports,
1637
- sender: this.sender,
1638
- sentTime: this.sentTime,
1639
- subject: this.subject,
1640
- succeeded: this.succeeded,
1641
- };
1642
- }
1643
- toApiDto(options) {
1644
- return {
1645
- id: this.id,
1646
- created: this.created,
1647
- createdBy: this.createdBy,
1648
- modified: this.modified,
1649
- account: this.account,
1650
- job: this.job,
1651
- body: this.body,
1652
- cc: this.cc,
1653
- files: this.files,
1654
- message: this.message,
1655
- recipients: this.recipients,
1656
- replyTo: this.replyTo,
1657
- reports: this.reports,
1658
- sender: this.sender,
1659
- sentTime: this.sentTime,
1660
- subject: this.subject,
1661
- succeeded: this.succeeded,
1662
- };
1663
- }
1664
- }
1665
-
1666
- /**
1667
- * A non sophisticated way to get values from the job via paths. For example:
1668
- *
1669
- * getValueByPath(
1670
- * ['foo', 'bar'],
1671
- * {
1672
- * foo: {
1673
- * bar: 'value'
1674
- * }
1675
- * }
1676
- * );
1677
- *
1678
- * will return "value"
1679
- * @param {string[]} path
1680
- * @param {Record<string, VasFieldDtoValue>} object
1681
- * @return {T | undefined}
1682
- */
1683
- const getValueByPath = (path, object) => {
1684
- switch (path.length) {
1685
- case 0: {
1686
- return;
1687
- }
1688
- case 1: {
1689
- return (object)[path[0]];
1690
- }
1691
- case 2: {
1692
- const val0 = object[path[0]];
1693
- if (!val0) {
1694
- return undefined;
1695
- }
1696
- return val0[path[1]];
1697
- }
1698
- case 3: {
1699
- const val0 = object[path[0]];
1700
- if (!val0) {
1701
- return undefined;
1702
- }
1703
- const val1 = val0[path[1]];
1704
- if (!val1) {
1705
- return undefined;
1706
- }
1707
- return val1[path[2]];
1708
- }
1709
- case 4: {
1710
- const val0 = object[path[0]];
1711
- if (!val0) {
1712
- return undefined;
1713
- }
1714
- const val1 = val0[path[1]];
1715
- if (!val1) {
1716
- return undefined;
1717
- }
1718
- const val2 = val1[path[2]];
1719
- if (!val2) {
1720
- return undefined;
1721
- }
1722
- return val2[path[3]];
1723
- }
1724
- default: {
1725
- throw Error('path has too many segments');
1726
- }
1727
- }
1728
- };
1729
-
1730
- const getEmptyGeoLocation = () => ({
1731
- accuracy: 0,
1732
- altitude: 0,
1733
- altitudeAccuracy: 0,
1734
- geoPoint: [],
1735
- lonLat: {
1736
- lon: 0,
1737
- lat: 0,
1738
- },
1739
- timestamp: ''
1740
- });
1741
-
1742
- const isArrayString = (value) => {
1743
- return Array.isArray(value) && value.every(i => typeof i === 'string');
1744
- };
1745
-
1746
- /**
1747
- * JobModel
1748
- */
1749
- class VasJobModel extends VasRestrictedAccountObjectModel {
1750
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, reference, jobDate, jobStatus, jobType, assigneeId, formId, timeZoneOffset, pendingFields, childModified, version, fields, files, createdByDisplayName, modifiedByDisplayName, geoLocation) {
1751
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
1752
- this.id = id;
1753
- this.created = created;
1754
- this.serverCreated = serverCreated;
1755
- this.createdBy = createdBy;
1756
- this.modified = modified;
1757
- this.serverModified = serverModified;
1758
- this.modifiedBy = modifiedBy;
1759
- this.createdByName = createdByName;
1760
- this.modifiedByName = modifiedByName;
1761
- this.account = account;
1762
- this.accessGroup = accessGroup;
1763
- this.reference = reference;
1764
- this.jobDate = jobDate;
1765
- this.jobStatus = jobStatus;
1766
- this.jobType = jobType;
1767
- this.assigneeId = assigneeId;
1768
- this.formId = formId;
1769
- this.timeZoneOffset = timeZoneOffset;
1770
- this.pendingFields = pendingFields;
1771
- this.childModified = childModified;
1772
- this.version = version;
1773
- this.fields = fields;
1774
- this.files = files;
1775
- this.createdByDisplayName = createdByDisplayName;
1776
- this.modifiedByDisplayName = modifiedByDisplayName;
1777
- this.geoLocation = geoLocation;
1778
- }
1779
- /**
1780
- * Returns this with the dynamic interface
1781
- * @return {VasJobModelDynamicInterface}
1782
- */
1783
- get $this() {
1784
- return this;
1785
- }
1786
- /**
1787
- * Returns a list of Job dynamic properties i.e. those that are added by the
1788
- * dynamic forms
1789
- */
1790
- get dynamicProperties() {
1791
- const nativeProps = this.staticProperties;
1792
- return Object
1793
- .getOwnPropertyNames(this)
1794
- .filter(prop => !nativeProps.includes(prop));
1795
- }
1796
- /**
1797
- * Returns the list of properties of the Job type
1798
- */
1799
- get staticProperties() {
1800
- return Object.getOwnPropertyNames(VasJobModel.empty());
1801
- }
1802
- /**
1803
- * @return {VasJobModel}
1804
- */
1805
- static empty() {
1806
- return new VasJobModel('', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', moment$1().utcOffset(), 0, '', 0, [], [], '', '', getEmptyGeoLocation());
1807
- }
1808
- static fromDto(dto) {
1809
- 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$1().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.fields || [], dto.files || [], dto.createdByDisplayName || '', dto.modifiedByDisplayName || '', dto.geoLocation || getEmptyGeoLocation());
1810
- const emptyKeys = model.staticProperties;
1811
- Object
1812
- .keys(dto)
1813
- .filter(key => emptyKeys.indexOf(key) === -1)
1814
- .forEach((key) => model.$this[key] = dto[key]);
1815
- return model;
1816
- }
1817
- /**
1818
- * This method will instantiate a new JobModel. The difference with this
1819
- * method of instantiation is that we are coming from a relation frame i.e.
1820
- * the job has a list of {@link VasFieldDto} instead of a Job document.
1821
- *
1822
- */
1823
- static fromRelational(dto, form) {
1824
- 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$1().utcOffset(), dto.pendingFields || 0, dto.childModified || '', dto.version || 0, dto.fields || [], dto.files || [], dto.createdByDisplayName || '', dto.modifiedByDisplayName || '', dto.geoLocation || getEmptyGeoLocation());
1825
- form.groups
1826
- .forEach(group => {
1827
- group.controls
1828
- .forEach(control => {
1829
- var _a;
1830
- const field = (_a = dto.fields) === null || _a === void 0 ? void 0 : _a.find(f => f.control === control.id);
1831
- if (!field) {
1832
- return;
1833
- }
1834
- model.getGroup(group.name)[control.name] = field.value;
1835
- });
1836
- });
1837
- return model;
1838
- }
1839
- /**
1840
- * @param {VasFormModel} formModel
1841
- * @return {Record<string, VasFieldDtoValue>}
1842
- */
1843
- getFields(formModel) {
1844
- const fields = {};
1845
- formModel.groups
1846
- .forEach(group => {
1847
- group.controls.forEach(control => {
1848
- (fields)[control.reportTemplateName] =
1849
- this.getValueByPath([group.name, control.name]) || null;
1850
- });
1851
- });
1852
- return fields;
1853
- }
1854
- /**
1855
- * Will return an object whose keys are the names of all fields in the job.
1856
- * This method is similar to `getFields` except that this method will only
1857
- * return values where a value was set, as opposed to `getFields` which will
1858
- * return a value for every control even if not value was set, because it uses
1859
- * the form to drive the logic. Note also this method will return values for
1860
- * any Fields in the fields array.
1861
- * @return {Record<string, VasFieldDtoValue>}
1862
- */
1863
- getFields2() {
1864
- let fields = {};
1865
- this.dynamicProperties
1866
- .forEach((groupName) => {
1867
- Object
1868
- .keys(this.$this[groupName])
1869
- .forEach(controlName => {
1870
- fields[controlName] =
1871
- this.getValueByPath([groupName, controlName]) || null;
1872
- });
1873
- }, {});
1874
- this.fields.forEach(field => fields[field.controlName] = field.value);
1875
- return fields;
1876
- }
1877
- /**
1878
- * Returns an object describing how many attachments were added to this job
1879
- * (camera controls and files), and how many have not been uploaded yet.
1880
- *
1881
- * @param formModel instance of {@link VasFormModel} that was used when the
1882
- * job was created
1883
- */
1884
- getFilesUploadStatus(formModel) {
1885
- const pathsWithValue = formModel
1886
- .getCameraControlPaths()
1887
- .map(path => {
1888
- const value = this.getValueByPath(path);
1889
- if (value && !!value.id) {
1890
- return path;
1891
- }
1892
- return null;
1893
- })
1894
- .filter(path => path !== null ? path : null)
1895
- .filter(isArrayString);
1896
- let total = pathsWithValue.length;
1897
- total += this.files.length;
1898
- // calculate the number of camera images still to upload
1899
- let pending = pathsWithValue
1900
- .map(path => this.getValueByPath(path))
1901
- .map((value) => {
1902
- if (isFileDto(value)) {
1903
- return value.id && value.status !== 'COMPLETE';
1904
- }
1905
- else if (isCameraControlValueV1(value)) {
1906
- // if url is not set, it hasn't been uploaded
1907
- return value.id && !value.url;
1908
- }
1909
- return false;
1910
- })
1911
- .filter(hasUploaded => hasUploaded)
1912
- .length;
1913
- // add total from files that are pending
1914
- pending += this.files
1915
- .filter(value => value.status !== 'COMPLETE')
1916
- .length;
1917
- return {
1918
- pending,
1919
- total
1920
- };
1921
- }
1922
- /**
1923
- * This method will return the dynamic property from the JobModel that
1924
- * represent a group (from a form).
1925
- *
1926
- * @param name the name of the group
1927
- * @param init if true (default) and group is not found, initialise an empty
1928
- * group, otherwise throw an error
1929
- */
1930
- getGroup(name, init = true) {
1931
- let prop;
1932
- if (this.staticProperties.includes(name)) {
1933
- throw Error(`invalid group name ${name}, not a dynamic property`);
1934
- }
1935
- else if (this.$this[name] === undefined) {
1936
- if (init) {
1937
- prop = this.$this[name] = {};
1938
- }
1939
- else {
1940
- throw Error(`invalid group name ${name}, not found`);
1941
- }
1942
- }
1943
- else {
1944
- prop = this.$this[name];
1945
- if (typeof prop !== 'object') {
1946
- throw Error(`invalid group name ${name}, not an object`);
1947
- }
1948
- }
1949
- return prop;
1950
- }
1951
- /**
1952
- * @param path path segments
1953
- */
1954
- getValueByPath(path = []) {
1955
- return getValueByPath(path, this.$this);
1956
- }
1957
- /**
1958
- * In order to understand why we need this method it is important to
1959
- * understand that within the system, Jobs can be represented in one of two
1960
- * ways, document and relational.
1961
- *
1962
- * The important distinction is how values submitted by a form are stored.
1963
- *
1964
- * Jobs stored as documents (JSON objects) will store user values, as dynamic
1965
- * properties of the document.
1966
- *
1967
- * Whereas, Jobs stored as relational, will store user values in an array of
1968
- * {@link VasFieldDto} objects.
1969
- *
1970
- * Depending on where we are in the system, either one of these approaches can
1971
- * be more useful than the other.
1972
- *
1973
- * This method, assumes that the JobModel has been instantiated from a
1974
- * document representation, and serves to hydrate the fields array. In order
1975
- * to achieve this, knowledge of the {@link VasFormDto} that created the job
1976
- * is required.
1977
- *
1978
- *
1979
- * Job in document representation
1980
- * {
1981
- * id: <guid>,
1982
- * reference: "something"
1983
- * <other static job properties>...
1984
- * foo: {
1985
- * bar: "value"
1986
- * }
1987
- * }
1988
- *
1989
- * Job in relational representation
1990
- * {
1991
- * id: <guid>,
1992
- * reference: "something"
1993
- * <other static job properties>...
1994
- * <will not have dynamic properties>...
1995
- * fields: [
1996
- * {
1997
- * id: <guid>,
1998
- * <other field properties>,
1999
- * value: "value"
2000
- * }
2001
- * ]
2002
- * }
2003
- *
2004
- *
2005
- * @param formModel the VasFormModel that was used to create the job
2006
- * @param controlFieldIdMap This is used to determine the id each field.
2007
- * Either one will be found in the map, or a new one is generated.
2008
- * @param controlNames if a value is provided, it will be used
2009
- * to filter the fields that are returned.
2010
- * @return {Array<VasFieldDto>}
2011
- */
2012
- hydrateFields(formModel, controlFieldIdMap = new Map(), controlNames) {
2013
- const fields = [];
2014
- formModel.groups
2015
- .forEach(group => {
2016
- group.controls.forEach(control => {
2017
- if (!control.name.startsWith('fields.')) {
2018
- return;
2019
- }
2020
- if (controlNames && !controlNames.includes(control.name)) {
2021
- return;
2022
- }
2023
- fields.push(VasFieldModel.fromDto({
2024
- // if the controlId exists in the map, use the associated fieldId,
2025
- // otherwise generate a new id for the field.
2026
- id: controlFieldIdMap.get(control.id) || UUID.UUID(),
2027
- account: this.account,
2028
- job: this.id,
2029
- createdBy: this.createdBy,
2030
- created: this.created,
2031
- modifiedBy: this.modifiedBy,
2032
- modified: this.modified,
2033
- control: control.id,
2034
- value: this.getValueByPath([group.name, control.name])
2035
- }));
2036
- });
2037
- });
2038
- this.fields = fields;
2039
- }
2040
- /**
2041
- * A very non sophisticated way to set values in the job via paths
2042
- *
2043
- * For example:
2044
- *
2045
- * setValueByPath('value', ['foo', 'bar']);
2046
- *
2047
- * will make results in job
2048
- * {
2049
- * foo: {
2050
- * bar: 'value'
2051
- * }
2052
- * }
2053
- *
2054
- * @param value the value to set
2055
- * @param path path segments
2056
- */
2057
- setValueByPath(value, path = []) {
2058
- switch (path.length) {
2059
- case 0: {
2060
- return;
2061
- }
2062
- case 1: {
2063
- this[path[0]] = value;
2064
- return;
2065
- }
2066
- case 2: {
2067
- // eslint-disable-next-line max-len
2068
- this.$this[path[0]][path[1]] = value;
2069
- return;
2070
- }
2071
- case 3: {
2072
- // eslint-disable-next-line max-len
2073
- this.$this[path[0]][path[1]][path[2]] = value;
2074
- return;
2075
- }
2076
- default: {
2077
- throw Error('path has too many segments');
2078
- }
2079
- }
2080
- }
2081
- /**
2082
- * @param staticOnly if true, will only output values for the static
2083
- * properties in the dto
2084
- */
2085
- toDto(staticOnly = false) {
2086
- if (staticOnly) {
2087
- return {
2088
- id: this.id,
2089
- created: this.created,
2090
- createdBy: this.createdBy,
2091
- modified: this.modified,
2092
- modifiedBy: this.modifiedBy,
2093
- serverCreated: this.serverCreated,
2094
- serverModified: this.serverModified,
2095
- createdByName: this.createdByName,
2096
- modifiedByName: this.modifiedByName,
2097
- account: this.account,
2098
- accessGroup: this.accessGroup,
2099
- reference: this.reference,
2100
- jobDate: this.jobDate,
2101
- jobStatus: this.jobStatus,
2102
- jobType: this.jobType,
2103
- assigneeId: this.assigneeId,
2104
- formId: this.formId,
2105
- timeZoneOffset: this.timeZoneOffset,
2106
- pendingFields: this.pendingFields,
2107
- childModified: this.childModified,
2108
- version: this.version,
2109
- fields: this.fields,
2110
- files: this.files,
2111
- createdByDisplayName: this.createdByDisplayName,
2112
- modifiedByDisplayName: this.modifiedByDisplayName,
2113
- geoLocation: this.geoLocation
2114
- };
2115
- }
2116
- const dto = {};
2117
- [...this.staticProperties, ...this.dynamicProperties]
2118
- .forEach(prop => dto[prop] = this.$this[prop]);
2119
- return dto;
2120
- }
2121
- /**
2122
- * This method will parse a syntax that allows us to build strings from the
2123
- * values of from the job model. For example if the job model was:
2124
- *
2125
- * {
2126
- * foo: 'bar'
2127
- * }
2128
- *
2129
- * and we pass "i am foo {foo}", the result would be:
2130
- *
2131
- * "i am foo bar"
2132
- *
2133
- * we can also use moment to parse dates, for example if the job model was:
2134
- *
2135
- * {
2136
- * created: "2022-01-01T00:00:00+0000"
2137
- * }
2138
- *
2139
- * and we pass "{created|date:YY-MM-DD}", the result would be:
2140
- *
2141
- * "2022-01-01"
2142
- *
2143
- * @param {string} value a string with the syntax
2144
- * @param {ParseSyntaxOptions} options
2145
- * @return the results of parsing the syntax on this job
2146
- */
2147
- parseSyntax(value, options = {
2148
- timeZoneOffset: 0
2149
- }) {
2150
- if (!value || typeof value !== 'string') {
2151
- return '';
2152
- }
2153
- return value.replace(/({[^}]*})/g, (match, token) => {
2154
- const syntax = token.substring(1, token.length - 1);
2155
- let [key, filter] = syntax.split('|');
2156
- key = (key || '').trim();
2157
- filter = (filter || '').trim();
2158
- let filterName, filterArg = '';
2159
- if (filter) {
2160
- const splitIndex = filter.indexOf(':');
2161
- if (splitIndex !== -1) {
2162
- filterName = filter.substring(0, splitIndex);
2163
- filterArg = filter.substring(splitIndex + 1);
2164
- }
2165
- else {
2166
- filterName = filter;
2167
- filterArg = '';
2168
- }
2169
- filterName = (filterName || '').trim();
2170
- filterArg = (filterArg || '').trim();
2171
- }
2172
- const path = key.split('.');
2173
- const objectKey = path.shift() || '';
2174
- let result = '';
2175
- if (objectKey === 'job') {
2176
- result = (this.getValueByPath(path) || '').toString();
2177
- }
2178
- else if (objectKey === 'fields') {
2179
- result = (getValueByPath(['fields.' + path.shift(), ...path], this.getFields2()) || '').toString();
2180
- }
2181
- else if (objectKey.length) {
2182
- if (options.objects) {
2183
- if (options.objects[objectKey] === undefined) {
2184
- console.debug(`objectKey ${objectKey} is not present in options.object`);
2185
- result = '';
2186
- }
2187
- else {
2188
- result = (getValueByPath(path, options.objects[objectKey]) || '')
2189
- .toString();
2190
- }
2191
- }
2192
- else {
2193
- console.debug(`objectKey ${objectKey} was used but options.object is not set`);
2194
- return '';
2195
- }
2196
- }
2197
- else {
2198
- return '';
2199
- }
2200
- if (filterName && result) {
2201
- switch (filterName) {
2202
- case 'date': {
2203
- return moment$1(result)
2204
- .utcOffset(options.timeZoneOffset)
2205
- .format(filterArg || '');
2206
- }
2207
- default: {
2208
- console.warn('unknown filter %s', filterName);
2209
- }
2210
- }
2211
- }
2212
- return result;
2213
- }).trim();
2214
- }
2215
- ;
2216
- /**
2217
- * @return {object}
2218
- */
2219
- toApiDto() {
2220
- 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, lastForm: this.formId || '~' });
2221
- }
2222
- }
2223
-
2224
- /**
2225
- * VasMembershipModel
2226
- */
2227
- class VasMembershipModel extends VasAccountObjectModel {
2228
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, user, admin, lookupTypes, contactTypes, accessGroups, jobStatuses, jobTypes, taskTypes) {
2229
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
2230
- this.id = id;
2231
- this.created = created;
2232
- this.serverCreated = serverCreated;
2233
- this.createdBy = createdBy;
2234
- this.modified = modified;
2235
- this.serverModified = serverModified;
2236
- this.modifiedBy = modifiedBy;
2237
- this.createdByName = createdByName;
2238
- this.modifiedByName = modifiedByName;
2239
- this.account = account;
2240
- this.user = user;
2241
- this.admin = admin;
2242
- this.lookupTypes = lookupTypes;
2243
- this.contactTypes = contactTypes;
2244
- this.accessGroups = accessGroups;
2245
- this.jobStatuses = jobStatuses;
2246
- this.jobTypes = jobTypes;
2247
- this.taskTypes = taskTypes;
2248
- }
2249
- static empty() {
2250
- return VasMembershipModel.fromDto({
2251
- // eslint-disable-next-line new-cap
2252
- id: UUID.UUID()
2253
- });
2254
- }
2255
- static fromDto(dto) {
2256
- return new VasMembershipModel(
2257
- // eslint-disable-next-line new-cap
2258
- dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.user || '', dto.admin || false, dto.lookupTypes || [], dto.contactTypes || [], dto.accessGroups || [], dto.jobStatuses || [], dto.jobTypes || [], dto.taskTypes || []);
2259
- }
2260
- toDto() {
2261
- return {
2262
- id: this.id,
2263
- created: this.created,
2264
- serverCreated: this.serverCreated,
2265
- createdBy: this.createdBy,
2266
- modified: this.modified,
2267
- serverModified: this.serverModified,
2268
- modifiedBy: this.modifiedBy,
2269
- createdByName: this.createdByName,
2270
- modifiedByName: this.modifiedByName,
2271
- account: this.account,
2272
- user: this.user,
2273
- admin: this.admin,
2274
- lookupTypes: this.lookupTypes,
2275
- contactTypes: this.contactTypes,
2276
- accessGroups: this.accessGroups,
2277
- jobStatuses: this.jobStatuses,
2278
- jobTypes: this.jobTypes,
2279
- taskTypes: this.taskTypes
2280
- };
2281
- }
2282
- }
2283
-
2284
- class VasReportLayoutModel extends VasRestrictedAccountObjectModel {
2285
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup, jobType, title, description, entryPoint) {
2286
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, accessGroup);
2287
- this.id = id;
2288
- this.created = created;
2289
- this.serverCreated = serverCreated;
2290
- this.createdBy = createdBy;
2291
- this.modified = modified;
2292
- this.serverModified = serverModified;
2293
- this.modifiedBy = modifiedBy;
2294
- this.createdByName = createdByName;
2295
- this.modifiedByName = modifiedByName;
2296
- this.account = account;
2297
- this.accessGroup = accessGroup;
2298
- this.jobType = jobType;
2299
- this.title = title;
2300
- this.description = description;
2301
- this.entryPoint = entryPoint;
2302
- }
2303
- }
2304
-
2305
- class VasReportRequestModel extends VasAccountObjectModel {
2306
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, error, jobId, title, url, reportId) {
2307
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
2308
- this.id = id;
2309
- this.created = created;
2310
- this.serverCreated = serverCreated;
2311
- this.createdBy = createdBy;
2312
- this.modified = modified;
2313
- this.serverModified = serverModified;
2314
- this.modifiedBy = modifiedBy;
2315
- this.createdByName = createdByName;
2316
- this.modifiedByName = modifiedByName;
2317
- this.account = account;
2318
- this.error = error;
2319
- this.jobId = jobId;
2320
- this.title = title;
2321
- this.url = url;
2322
- this.reportId = reportId;
2323
- }
2324
- static fromDto(dto) {
2325
- return new VasReportRequestModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.error || '', dto.jobId || '', dto.title || '', dto.url || '', dto.reportId || '');
2326
- }
2327
- toDto() {
2328
- return {
2329
- id: this.id,
2330
- created: this.created,
2331
- serverCreated: this.serverCreated,
2332
- createdBy: this.createdBy,
2333
- modified: this.modified,
2334
- serverModified: this.serverModified,
2335
- modifiedBy: this.modifiedBy,
2336
- createdByName: this.createdByName,
2337
- modifiedByName: this.modifiedByName,
2338
- account: this.account,
2339
- error: this.error,
2340
- jobId: this.jobId,
2341
- title: this.title,
2342
- url: this.url,
2343
- reportId: this.reportId
2344
- };
2345
- }
2346
- }
2347
-
2348
- /**
2349
- * VasTaskModel
2350
- */
2351
- class VasTaskModel extends VasJobDataModel {
2352
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job, assignee, done, dueDate, taskType, title) {
2353
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, job);
2354
- this.id = id;
2355
- this.created = created;
2356
- this.serverCreated = serverCreated;
2357
- this.createdBy = createdBy;
2358
- this.modified = modified;
2359
- this.serverModified = serverModified;
2360
- this.modifiedBy = modifiedBy;
2361
- this.createdByName = createdByName;
2362
- this.modifiedByName = modifiedByName;
2363
- this.account = account;
2364
- this.job = job;
2365
- this.assignee = assignee;
2366
- this.done = done;
2367
- this.dueDate = dueDate;
2368
- this.taskType = taskType;
2369
- this.title = title;
2370
- }
2371
- /**
2372
- * @param dto VasTaskDto
2373
- * @return VasNoteModel
2374
- */
2375
- static fromDto(dto) {
2376
- return new VasTaskModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.job || '', dto.assignee || '', dto.done || false, dto.dueDate || '', dto.taskType || '', dto.title || '');
2377
- }
2378
- /**
2379
- * @returns VasTaskDto
2380
- */
2381
- toDto() {
2382
- return {
2383
- id: this.id,
2384
- created: this.created,
2385
- serverCreated: this.serverCreated,
2386
- createdBy: this.createdBy,
2387
- modified: this.modified,
2388
- serverModified: this.serverModified,
2389
- modifiedBy: this.modifiedBy,
2390
- createdByName: this.createdByName,
2391
- modifiedByName: this.modifiedByName,
2392
- account: this.account,
2393
- job: this.job,
2394
- assignee: this.assignee,
2395
- done: this.done,
2396
- dueDate: this.dueDate,
2397
- taskType: this.taskType,
2398
- title: this.title,
2399
- };
2400
- }
2401
- toApiDto(options) {
2402
- return Object.assign(Object.assign({}, super.toApiDto(options)), { assignee: this.assignee, done: this.done, dueDate: this.dueDate, taskType: this.taskType, title: this.title });
2403
- }
2404
- }
2405
-
2406
- class VasVehicleModel extends VasAccountObjectModel {
2407
- constructor(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account, registration, make, model, archived, description) {
2408
- super(id, created, serverCreated, createdBy, modified, serverModified, modifiedBy, createdByName, modifiedByName, account);
2409
- this.id = id;
2410
- this.created = created;
2411
- this.serverCreated = serverCreated;
2412
- this.createdBy = createdBy;
2413
- this.modified = modified;
2414
- this.serverModified = serverModified;
2415
- this.modifiedBy = modifiedBy;
2416
- this.createdByName = createdByName;
2417
- this.modifiedByName = modifiedByName;
2418
- this.account = account;
2419
- this.registration = registration;
2420
- this.make = make;
2421
- this.model = model;
2422
- this.archived = archived;
2423
- this.description = description;
2424
- }
2425
- static fromDto(dto) {
2426
- return new VasVehicleModel(dto.id || '', dto.created || '', dto.serverCreated || '', dto.createdBy || '', dto.modified || '', dto.serverModified || '', dto.modifiedBy || '', dto.createdByName || '', dto.modifiedByName || '', dto.account || '', dto.registration || '', dto.make || '', dto.model || '', dto.archived || false, dto.description || '');
2427
- }
2428
- toDto() {
2429
- return {
2430
- id: this.id,
2431
- created: this.created,
2432
- serverCreated: this.serverCreated,
2433
- createdBy: this.createdBy,
2434
- modified: this.modified,
2435
- serverModified: this.serverModified,
2436
- modifiedBy: this.modifiedBy,
2437
- createdByName: this.createdByName,
2438
- modifiedByName: this.modifiedByName,
2439
- account: this.account,
2440
- registration: this.registration,
2441
- make: this.make,
2442
- model: this.model,
2443
- archived: this.archived,
2444
- description: this.description
2445
- };
2446
- }
2447
- toApiDto(options) {
2448
- return {
2449
- id: this.id,
2450
- created: this.created,
2451
- modified: this.modified,
2452
- account: this.account,
2453
- registration: this.registration,
2454
- make: this.make,
2455
- model: this.model,
2456
- archived: this.archived,
2457
- description: this.description
2458
- };
2459
- }
2460
- static toApiPatchDto(dto) {
2461
- return only(dto, [
2462
- 'created',
2463
- 'modified',
2464
- 'registration',
2465
- 'make',
2466
- 'model',
2467
- 'description',
2468
- 'archived'
2469
- ]);
2470
- }
2471
- }
2472
-
2473
- /**
2474
- * Generated bundle index. Do not edit.
2475
- */
2476
-
2477
- export { VasAccountIndexingMode, VasAccountObjectModel, VasBaseModel, VasBranchModel, VasContactModel, VasControlConfigDirection, VasControlModel, VasControlTypeModel, VasFieldModel, VasFileModel, VasFireUserModel, VasFormConfigModel, VasFormModel, VasGroupModel, VasInstructionJobFieldModel, VasInstructionJobModel, VasInstructionModel, VasInstructionProviderModel, VasInvitationModel, VasInvitationTypeEnum, VasJobDataModel, VasJobEmailModel, VasJobModel, VasMembershipModel, VasNoteModel, VasReportLayoutModel, VasReportModel, VasReportRequestModel, VasRestrictedAccountObjectModel, VasTaskModel, VasUserModel, VasVehicleModel, getEmptyGeoLocation, isCameraControlValueV1, isFileDto };
2478
- //# sourceMappingURL=ironcode-vas-lib.mjs.map