openchs-models 1.33.2 → 1.33.4

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 (153) hide show
  1. package/.circleci/config.yml +15 -5
  2. package/.commit-message.txt +21 -0
  3. package/.nvmrc +1 -1
  4. package/Makefile +32 -10
  5. package/REALM_V12_NOTES.md +46 -0
  6. package/dist/AbstractEncounter.js +4 -105
  7. package/dist/AddressLevel.js +5 -62
  8. package/dist/ApprovalStatus.js +4 -17
  9. package/dist/BaseEntity.js +5 -42
  10. package/dist/BeneficiaryModePin.js +4 -13
  11. package/dist/Checklist.js +6 -52
  12. package/dist/ChecklistDetail.js +4 -22
  13. package/dist/ChecklistItem.js +16 -96
  14. package/dist/ChecklistItemDetail.js +4 -43
  15. package/dist/ChecklistItemStatus.js +4 -33
  16. package/dist/Comment.js +6 -51
  17. package/dist/CommentThread.js +4 -26
  18. package/dist/CompositeDuration.js +1 -18
  19. package/dist/Concept.js +5 -107
  20. package/dist/ConceptAnswer.js +4 -21
  21. package/dist/CustomDashboardCache.js +4 -38
  22. package/dist/CustomFilter.js +5 -15
  23. package/dist/Dashboard.js +4 -23
  24. package/dist/DashboardCache.js +4 -23
  25. package/dist/DashboardSection.js +4 -24
  26. package/dist/DashboardSectionCardMapping.js +4 -21
  27. package/dist/Displayable.js +3 -11
  28. package/dist/Documentation.js +4 -21
  29. package/dist/DocumentationItem.js +4 -20
  30. package/dist/Duration.js +4 -39
  31. package/dist/Encounter.js +6 -41
  32. package/dist/EncounterType.js +4 -26
  33. package/dist/EntityApprovalStatus.js +6 -56
  34. package/dist/EntityMetaData.js +7 -105
  35. package/dist/EntityQueue.js +4 -15
  36. package/dist/EntityRule.js +1 -29
  37. package/dist/EntitySyncStatus.js +4 -19
  38. package/dist/Extension.js +4 -18
  39. package/dist/Family.js +4 -56
  40. package/dist/FileFormat.js +0 -7
  41. package/dist/Gender.js +4 -17
  42. package/dist/GroupDashboard.js +4 -23
  43. package/dist/GroupPrivileges.js +4 -28
  44. package/dist/GroupRole.js +4 -34
  45. package/dist/GroupSubject.js +6 -59
  46. package/dist/Groups.js +4 -14
  47. package/dist/Identifier.js +4 -20
  48. package/dist/IdentifierAssignment.js +6 -45
  49. package/dist/IdentifierSource.js +4 -15
  50. package/dist/Individual.js +17 -265
  51. package/dist/LocaleMapping.js +4 -13
  52. package/dist/LocationHierarchy.js +4 -25
  53. package/dist/Media.js +35 -35
  54. package/dist/MediaQueue.js +4 -26
  55. package/dist/MigrationsHelper.js +15 -22
  56. package/dist/MyGroups.js +4 -14
  57. package/dist/News.js +4 -31
  58. package/dist/Observation.js +4 -54
  59. package/dist/ObservationsHolder.js +104 -216
  60. package/dist/OrganisationConfig.js +4 -19
  61. package/dist/PersistedObject.js +1 -19
  62. package/dist/PhoneNumber.js +0 -11
  63. package/dist/PlatformTranslation.js +4 -17
  64. package/dist/Privilege.js +5 -22
  65. package/dist/Program.js +4 -39
  66. package/dist/ProgramEncounter.js +6 -48
  67. package/dist/ProgramEnrolment.js +8 -162
  68. package/dist/ReferenceEntity.js +1 -10
  69. package/dist/ReportCard.js +5 -60
  70. package/dist/ResetSync.js +4 -17
  71. package/dist/Rule.js +4 -28
  72. package/dist/RuleDependency.js +4 -17
  73. package/dist/RuleFailureTelemetry.js +4 -36
  74. package/dist/Schema.js +16 -268
  75. package/dist/SchemaNames.js +3 -46
  76. package/dist/Settings.js +4 -53
  77. package/dist/StandardReportCardType.js +4 -39
  78. package/dist/SubjectMigration.js +6 -45
  79. package/dist/SubjectType.js +6 -72
  80. package/dist/SyncTelemetry.js +4 -40
  81. package/dist/Translation.js +4 -17
  82. package/dist/UserInfo.js +4 -33
  83. package/dist/application/DashboardCacheFilter.js +4 -24
  84. package/dist/application/Filter.js +3 -16
  85. package/dist/application/Form.js +6 -93
  86. package/dist/application/FormElement.js +5 -100
  87. package/dist/application/FormElementGroup.js +4 -75
  88. package/dist/application/FormElementStatus.js +1 -11
  89. package/dist/application/FormMapping.js +6 -44
  90. package/dist/application/Format.js +4 -20
  91. package/dist/application/KeyValue.js +4 -19
  92. package/dist/application/MenuItem.js +4 -35
  93. package/dist/application/MultiSelectFilter.js +1 -11
  94. package/dist/application/NullProgramEnrolment.js +0 -8
  95. package/dist/application/SingleSelectFilter.js +1 -12
  96. package/dist/application/StaticFormElementGroup.js +0 -11
  97. package/dist/application/StringKeyNumericValue.js +4 -17
  98. package/dist/application/ValidationResult.js +6 -20
  99. package/dist/application/ValidationResults.js +1 -14
  100. package/dist/application/WorkItem.js +4 -20
  101. package/dist/application/WorkList.js +1 -24
  102. package/dist/application/WorkLists.js +1 -13
  103. package/dist/assignment/UserSubjectAssignment.js +6 -26
  104. package/dist/draft/DraftEncounter.js +4 -40
  105. package/dist/draft/DraftSubject.js +4 -46
  106. package/dist/error/IgnorableSyncError.js +1 -6
  107. package/dist/error/SyncError.js +1 -6
  108. package/dist/framework/ArrayHelper.js +3 -11
  109. package/dist/framework/DefinedObjectSchema.js +4 -12
  110. package/dist/framework/RealmCollectionHelper.js +1 -9
  111. package/dist/framework/RealmListProxy.js +1 -10
  112. package/dist/framework/RealmObjectSchema.js +1 -11
  113. package/dist/framework/RealmProxy.js +2 -31
  114. package/dist/framework/RealmResultsProxy.js +3 -37
  115. package/dist/framework/RealmResultsProxyHandler.js +2 -5
  116. package/dist/geo/Point.js +4 -17
  117. package/dist/index.js +2 -137
  118. package/dist/location/Locations.js +1 -6
  119. package/dist/observation/MultipleCodedValues.js +1 -21
  120. package/dist/observation/PrimitiveValue.js +1 -17
  121. package/dist/observation/QuestionGroup.js +1 -36
  122. package/dist/observation/RepeatableQuestionGroup.js +4 -27
  123. package/dist/observation/SingleCodedValue.js +1 -15
  124. package/dist/program/SubjectProgramEligibility.js +6 -56
  125. package/dist/relationship/IndividualRelation.js +6 -18
  126. package/dist/relationship/IndividualRelationGenderMapping.js +4 -22
  127. package/dist/relationship/IndividualRelationship.js +6 -51
  128. package/dist/relationship/IndividualRelationshipType.js +4 -24
  129. package/dist/relationship/IndividualRelative.js +4 -31
  130. package/dist/reports/DashboardFilter.js +4 -20
  131. package/dist/reports/DashboardFilterConfig.js +5 -85
  132. package/dist/reports/NestedReportCardResult.js +5 -35
  133. package/dist/reports/Range.js +4 -13
  134. package/dist/reports/ReportCardResult.js +5 -24
  135. package/dist/service/MetaDataService.js +1 -30
  136. package/dist/task/Task.js +6 -62
  137. package/dist/task/TaskStatus.js +4 -21
  138. package/dist/task/TaskType.js +4 -23
  139. package/dist/task/TaskUnAssignment.js +6 -30
  140. package/dist/utility/AgeUtil.js +1 -15
  141. package/dist/utility/ArrayUtil.js +1 -6
  142. package/dist/utility/AuditUtil.js +1 -8
  143. package/dist/utility/DateTimeUtil.js +1 -8
  144. package/dist/utility/General.js +4 -71
  145. package/dist/utility/JsonStringify.js +15 -28
  146. package/dist/utility/MergeUtil.js +1 -10
  147. package/dist/utility/ResourceUtil.js +1 -7
  148. package/dist/videos/Video.js +4 -23
  149. package/dist/videos/VideoTelemetric.js +6 -37
  150. package/package.json +6 -3
  151. package/scripts/validateSchemas.js +40 -0
  152. package/tsconfig.json +1 -1
  153. package/yarn.lock +0 -6744
@@ -4,54 +4,40 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.LocationMapping = void 0;
7
-
8
7
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
-
10
8
  var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
11
-
12
9
  var _General = _interopRequireDefault(require("./utility/General"));
13
-
14
10
  var _lodash = _interopRequireDefault(require("lodash"));
15
-
16
11
  var _Observation = _interopRequireDefault(require("./Observation"));
17
-
18
12
  var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
-
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
17
  const PARENT_LOCATION_UUID = "parentLocationUUID";
25
18
  const CHILD_LOCATION_UUID = "locationUUID";
26
-
27
19
  function appendLineage(addressLevel, accumulator) {
28
20
  if (_lodash.default.isNil(addressLevel)) return accumulator;
29
21
  accumulator.push(addressLevel);
30
22
  const parent = addressLevel.getParent();
31
23
  return appendLineage(parent, accumulator);
32
24
  }
33
-
34
25
  class LocationMapping extends _BaseEntity.default {
35
26
  constructor(that = null) {
36
27
  super(that);
37
28
  }
38
-
39
29
  get parent() {
40
30
  return this.toEntity("parent", AddressLevel);
41
31
  }
42
-
43
32
  set parent(x) {
44
33
  this.that.parent = this.fromObject(x);
45
34
  }
46
-
47
35
  get child() {
48
36
  return this.toEntity("child", AddressLevel);
49
37
  }
50
-
51
38
  set child(x) {
52
39
  this.that.child = this.fromObject(x);
53
40
  }
54
-
55
41
  static create({
56
42
  uuid,
57
43
  parent,
@@ -65,7 +51,6 @@ class LocationMapping extends _BaseEntity.default {
65
51
  voided
66
52
  });
67
53
  }
68
-
69
54
  static fromResource(resource, entityService) {
70
55
  return LocationMapping.create({
71
56
  uuid: resource.uuid,
@@ -74,11 +59,8 @@ class LocationMapping extends _BaseEntity.default {
74
59
  voided: !!resource.voided
75
60
  });
76
61
  }
77
-
78
62
  }
79
-
80
63
  exports.LocationMapping = LocationMapping;
81
-
82
64
  _defineProperty(LocationMapping, "schema", {
83
65
  name: _SchemaNames.default.LocationMapping,
84
66
  primaryKey: "uuid",
@@ -98,76 +80,58 @@ _defineProperty(LocationMapping, "schema", {
98
80
  }
99
81
  }
100
82
  });
101
-
102
83
  class AddressLevel extends _BaseEntity.default {
103
84
  constructor(that = null) {
104
85
  super(that);
105
86
  }
106
-
107
87
  get name() {
108
88
  return this.that.name;
109
89
  }
110
-
111
90
  set name(x) {
112
91
  this.that.name = x;
113
92
  }
114
-
115
93
  get level() {
116
94
  return this.that.level;
117
95
  }
118
-
119
96
  set level(x) {
120
97
  this.that.level = x;
121
98
  }
122
-
123
99
  get type() {
124
100
  return this.that.type;
125
101
  }
126
-
127
102
  set type(x) {
128
103
  this.that.type = x;
129
104
  }
130
-
131
105
  get locationMappings() {
132
106
  return this.toEntityList("locationMappings", LocationMapping);
133
107
  }
134
-
135
108
  set locationMappings(x) {
136
109
  this.that.locationMappings = this.fromEntityList(x);
137
110
  }
138
-
139
111
  get locationProperties() {
140
112
  return this.toEntityList("locationProperties", _Observation.default);
141
113
  }
142
-
143
114
  set locationProperties(x) {
144
115
  this.that.locationProperties = this.fromEntityList(x);
145
116
  }
146
-
147
117
  get titleLineage() {
148
118
  return this.that.titleLineage;
149
119
  }
150
-
151
120
  set titleLineage(x) {
152
121
  this.that.titleLineage = x;
153
122
  }
154
-
155
123
  get parentUuid() {
156
124
  return this.that.parentUuid;
157
125
  }
158
-
159
126
  set parentUuid(x) {
160
127
  this.that.parentUuid = x;
161
128
  }
162
-
163
129
  get typeUuid() {
164
130
  return this.that.typeUuid;
165
131
  }
166
-
167
132
  set typeUuid(x) {
168
133
  this.that.typeUuid = x;
169
134
  }
170
-
171
135
  static create({
172
136
  uuid,
173
137
  title,
@@ -191,38 +155,28 @@ class AddressLevel extends _BaseEntity.default {
191
155
  parentUuid,
192
156
  typeUuid
193
157
  });
194
-
195
158
  return _General.default.assignObsFields({
196
159
  locationProperties
197
160
  }, addressLevel, ['locationProperties'], entityService);
198
161
  }
199
-
200
162
  static fromResource(resource, entityService) {
201
163
  return AddressLevel.create(resource, entityService);
202
164
  }
203
-
204
165
  static associateLocationMapping(locationMapping, locationMappingRes, entityService) {
205
166
  let location = _BaseEntity.default.getParentEntity(entityService, LocationMapping, locationMappingRes, CHILD_LOCATION_UUID, AddressLevel.schema.name);
206
-
207
167
  location = _General.default.pick(location, ["uuid"], ["locationMappings"]);
208
-
209
168
  _BaseEntity.default.addNewChild(locationMapping, location.locationMappings);
210
-
211
169
  return location;
212
170
  }
213
-
214
171
  static associateChild(child, childEntityClass, childResource, entityService) {
215
172
  if (childEntityClass === LocationMapping) {
216
173
  return AddressLevel.associateLocationMapping(child, childResource, entityService);
217
174
  }
218
-
219
175
  throw `${childEntityClass.name} not support by ${AddressLevel.schema.name}.associateChild()`;
220
176
  }
221
-
222
177
  getParentLocations() {
223
178
  return _lodash.default.filter(this.locationMappings, locationMapping => !locationMapping.voided).map(locationMapping => locationMapping.parent);
224
179
  }
225
-
226
180
  cloneForReference() {
227
181
  return AddressLevel.create(_lodash.default.assignIn({
228
182
  title: this.name,
@@ -231,43 +185,34 @@ class AddressLevel extends _BaseEntity.default {
231
185
  voided: this.voided
232
186
  }, this));
233
187
  }
234
-
235
188
  get translatedFieldValue() {
236
189
  return this.name;
237
190
  }
238
-
239
191
  getParent() {
240
192
  return _lodash.default.get(this, "locationMappings[0].parent");
241
193
  }
194
+
242
195
  /**
243
196
  * return all parent
244
197
  */
245
-
246
-
247
198
  getLineage() {
248
199
  return appendLineage(this, []);
249
200
  }
250
-
251
201
  findObservation(conceptNameOrUuid, parentConceptNameOrUuid) {
252
202
  const observations = _lodash.default.isNil(parentConceptNameOrUuid) ? this.locationProperties : this.findGroupedObservation(parentConceptNameOrUuid);
253
203
  return _lodash.default.find(observations, observation => {
254
204
  return observation.concept.name === conceptNameOrUuid || observation.concept.uuid === conceptNameOrUuid;
255
205
  });
256
206
  }
257
-
258
207
  findGroupedObservation(parentConceptNameOrUuid) {
259
208
  const groupedObservations = _lodash.default.find(this.locationProperties, observation => observation.concept.name === parentConceptNameOrUuid || observation.concept.uuid === parentConceptNameOrUuid);
260
-
261
209
  return _lodash.default.isEmpty(groupedObservations) ? [] : groupedObservations.getValue();
262
210
  }
263
-
264
211
  getObservationReadableValue(conceptNameOrUuid, parentConceptNameOrUuid) {
265
212
  const observationForConcept = this.findObservation(conceptNameOrUuid, parentConceptNameOrUuid);
266
213
  return _lodash.default.isEmpty(observationForConcept) ? observationForConcept : observationForConcept.getReadableValue();
267
214
  }
268
-
269
215
  }
270
-
271
216
  _defineProperty(AddressLevel, "schema", {
272
217
  name: "AddressLevel",
273
218
  primaryKey: "uuid",
@@ -305,8 +250,6 @@ _defineProperty(AddressLevel, "schema", {
305
250
  }
306
251
  }
307
252
  });
308
-
309
253
  _defineProperty(AddressLevel, "merge", () => _BaseEntity.default.mergeOn("locationMappings"));
310
-
311
254
  var _default = AddressLevel;
312
255
  exports.default = _default;
@@ -4,46 +4,35 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _BaseEntity = _interopRequireDefault(require("./BaseEntity"));
9
-
10
8
  var _General = _interopRequireDefault(require("./utility/General"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
13
  class ApprovalStatus extends _BaseEntity.default {
17
14
  constructor(that = null) {
18
15
  super(that);
19
16
  }
20
-
21
17
  get status() {
22
18
  return this.that.status;
23
19
  }
24
-
25
20
  set status(x) {
26
21
  this.that.status = x;
27
22
  }
28
-
29
23
  get isPending() {
30
24
  return this.status === ApprovalStatus.statuses.Pending;
31
25
  }
32
-
33
26
  get isApproved() {
34
27
  return this.status === ApprovalStatus.statuses.Approved;
35
28
  }
36
-
37
29
  get isRejected() {
38
30
  return this.status === ApprovalStatus.statuses.Rejected;
39
31
  }
40
-
41
32
  static fromResource(resource) {
42
33
  return _General.default.assignFields(resource, new ApprovalStatus(), ["uuid", "status", "voided"]);
43
34
  }
44
-
45
35
  }
46
-
47
36
  _defineProperty(ApprovalStatus, "schema", {
48
37
  name: "ApprovalStatus",
49
38
  primaryKey: "uuid",
@@ -56,12 +45,10 @@ _defineProperty(ApprovalStatus, "schema", {
56
45
  }
57
46
  }
58
47
  });
59
-
60
48
  _defineProperty(ApprovalStatus, "statuses", {
61
49
  Pending: "Pending",
62
50
  Approved: "Approved",
63
51
  Rejected: "Rejected"
64
52
  });
65
-
66
53
  var _default = ApprovalStatus;
67
54
  exports.default = _default;
@@ -4,48 +4,34 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _ValidationResult = _interopRequireDefault(require("./application/ValidationResult"));
11
-
12
9
  var _ResourceUtil = _interopRequireDefault(require("./utility/ResourceUtil"));
13
-
14
10
  var _SyncError = _interopRequireDefault(require("./error/SyncError"));
15
-
16
11
  var _ErrorCodes = require("./error/ErrorCodes");
17
-
18
12
  var _PersistedObject = _interopRequireDefault(require("./PersistedObject"));
19
-
20
13
  var _ArrayHelper = _interopRequireDefault(require("./framework/ArrayHelper"));
21
-
22
14
  var _IgnorableSyncError = _interopRequireDefault(require("./error/IgnorableSyncError"));
23
-
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
-
26
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
-
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
18
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
28
19
  class BaseEntity extends _PersistedObject.default {
29
20
  constructor(that) {
30
21
  super(that);
31
22
  }
32
-
33
23
  get voided() {
34
24
  return this.that.voided;
35
25
  }
36
-
37
26
  set voided(x) {
38
27
  this.that.voided = x;
39
28
  }
40
-
41
29
  set uuid(x) {
42
30
  this.that.uuid = x;
43
31
  }
44
-
45
32
  get uuid() {
46
33
  return this.that.uuid;
47
34
  }
48
-
49
35
  static mergeOn(key) {
50
36
  return entities => {
51
37
  const mergedUuidToChildMap = entities.reduce((accumulatedUuidToChildMap, entity) => {
@@ -53,96 +39,73 @@ class BaseEntity extends _PersistedObject.default {
53
39
  return accumulatedUuidToChildMap;
54
40
  }, {});
55
41
  const entityWithMergedChildren = entities[0]; //Set merged children to the first instance of parent entity
56
-
57
42
  BaseEntity.replaceCollection(_lodash.default.values(mergedUuidToChildMap), entityWithMergedChildren[key]);
58
43
  return entityWithMergedChildren;
59
44
  };
60
45
  }
46
+
61
47
  /*
62
48
  to be used only during sync where entities are handled generically and not via model classes
63
49
  */
64
-
65
-
66
50
  static addNewChild(newChild, existingChildren) {
67
51
  if (!BaseEntity.collectionHasEntity(existingChildren, newChild)) {
68
52
  this._setChild(newChild, existingChildren);
69
53
  }
70
54
  }
71
-
72
55
  static replaceCollection(newChildren = [], existingChildren = []) {
73
56
  existingChildren.splice(0, existingChildren.length); //Clear old entries
74
-
75
57
  newChildren.forEach(newChild => {
76
58
  this._setChild(newChild, existingChildren); //Add new entry
77
-
78
59
  });
79
60
  }
80
-
81
61
  static _setChild(newChild, existingChildren) {
82
62
  const child = _lodash.default.isNil(newChild.that) ? newChild : newChild.that;
83
63
  existingChildren.push(child);
84
64
  }
85
-
86
65
  static collectionHasEntity(collection, entity) {
87
66
  return _lodash.default.some(collection, item => item.uuid === entity.uuid);
88
67
  }
89
-
90
68
  static removeFromCollection(collection, entity) {
91
69
  _ArrayHelper.default.remove(collection, item => item.uuid === entity.uuid);
92
70
  }
93
-
94
71
  equals(other) {
95
72
  return !_lodash.default.isNil(other) && other.uuid === this.uuid;
96
73
  }
97
-
98
74
  validateFieldForEmpty(value, key) {
99
75
  if (value instanceof Date) {
100
76
  return _lodash.default.isNil(value) ? _ValidationResult.default.failure(key, "emptyValidationMessage") : _ValidationResult.default.successful(key);
101
77
  }
102
-
103
78
  return _lodash.default.isEmpty(value) ? _ValidationResult.default.failure(key, "emptyValidationMessage") : _ValidationResult.default.successful(key);
104
79
  }
105
-
106
80
  validateFieldForNull(value, key) {
107
81
  return _lodash.default.isNil(value) ? _ValidationResult.default.failure(key, "emptyValidationMessage") : _ValidationResult.default.successful(key);
108
82
  }
109
-
110
83
  print() {
111
84
  return this.toString();
112
85
  }
113
-
114
86
  static getParentEntity(entityService, childEntityClass, childResource, parentUUIDField, parentSchema, isIgnorable = false, explicitErrorCodeKey = undefined) {
115
87
  const childUuid = childResource.uuid;
116
-
117
88
  const parentUuid = _ResourceUtil.default.getUUIDFor(childResource, parentUUIDField);
118
-
119
89
  const childSchema = childEntityClass.schema.name;
120
90
  const parent = entityService.findByKey("uuid", parentUuid, parentSchema);
121
-
122
91
  if (!_lodash.default.isNil(parent)) {
123
92
  return parent;
124
93
  }
125
-
126
94
  BaseEntity.throwSyncError(childSchema, parentSchema, childUuid, parentUuid, isIgnorable, explicitErrorCodeKey);
127
95
  }
128
-
129
96
  static throwSyncError(childSchema, parentSchema, childUuid, parentUuid, isIgnorable, explicitErrorCodeKey) {
130
97
  const errorCodeKey = explicitErrorCodeKey ? explicitErrorCodeKey : `${childSchema}-${parentSchema}-Association`;
131
98
  const code = _ErrorCodes.ErrorCodes[errorCodeKey];
132
99
  const message = `${childSchema}{uuid='${childUuid}'} is unable to find ${parentSchema}{uuid='${parentUuid}'}`;
133
-
134
100
  if (isIgnorable) {
135
101
  throw new _IgnorableSyncError.default(code, message);
136
102
  } else {
137
103
  throw new _SyncError.default(code, message);
138
104
  }
139
105
  }
140
-
141
106
  }
142
-
143
107
  _defineProperty(BaseEntity, "fieldKeys", {
144
108
  EXTERNAL_RULE: "EXTERNAL_RULE"
145
109
  });
146
-
147
110
  var _default = BaseEntity;
148
111
  exports.default = _default;
@@ -4,40 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _PersistedObject = _interopRequireDefault(require("./PersistedObject"));
9
-
10
8
  var _SchemaNames = _interopRequireDefault(require("./SchemaNames"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
-
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
13
  class BeneficiaryModePin extends _PersistedObject.default {
17
14
  constructor(that = null) {
18
15
  super(that);
19
16
  }
20
-
21
17
  get pin() {
22
18
  return this.that.pin;
23
19
  }
24
-
25
20
  set pin(x) {
26
21
  this.that.pin = x;
27
22
  }
28
-
29
23
  pinMatches(enteredPin) {
30
24
  return enteredPin === this.pin;
31
25
  }
32
-
33
26
  }
34
-
35
27
  _defineProperty(BeneficiaryModePin, "schema", {
36
28
  name: _SchemaNames.default.BeneficiaryModePin,
37
29
  properties: {
38
30
  pin: "int"
39
31
  }
40
32
  });
41
-
42
33
  var _default = BeneficiaryModePin;
43
34
  exports.default = _default;