openchs-models 1.30.73 → 1.30.75

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.
@@ -167,7 +167,9 @@ const refData = (clazz, {
167
167
  translated,
168
168
  parent,
169
169
  syncWeight,
170
- resUrl
170
+ resUrl,
171
+ syncPushRequired = true,
172
+ syncPullRequired = true
171
173
  } = {}) => ({
172
174
  schemaName: clazz.schema.name,
173
175
  entityName: clazz.schema.name,
@@ -178,20 +180,14 @@ const refData = (clazz, {
178
180
  resourceSearchFilterURL: filter,
179
181
  parent: parent,
180
182
  syncWeight: syncWeight,
181
- resourceUrl: resUrl
183
+ resourceUrl: resUrl,
184
+ syncPushRequired,
185
+ syncPullRequired
182
186
  });
183
187
 
184
188
  const refDataNameTranslated = (clazz, attrs = {}) => refData(clazz, _objectSpread({}, attrs, {
185
189
  translated: true
186
190
  }));
187
- /*
188
- const userInfo = txData(UserInfo, {
189
- resUrl: "me",
190
- apiVersion: "v2",
191
- syncWeight: 1,
192
- });
193
- */
194
-
195
191
 
196
192
  const txData = (clazz, {
197
193
  entityName,
@@ -206,7 +202,9 @@ const txData = (clazz, {
206
202
  queryParam,
207
203
  hasMoreThanOneAssociation,
208
204
  apiQueryParams,
209
- apiQueryParamKey
205
+ apiQueryParamKey,
206
+ syncPushRequired = true,
207
+ syncPullRequired = true
210
208
  } = {}) => ({
211
209
  schemaName: clazz.schema.name,
212
210
  entityName: entityName || clazz.schema.name,
@@ -224,7 +222,9 @@ const txData = (clazz, {
224
222
  queryParam,
225
223
  hasMoreThanOneAssociation: !!hasMoreThanOneAssociation,
226
224
  apiQueryParams,
227
- apiQueryParamKey
225
+ apiQueryParamKey,
226
+ syncPushRequired,
227
+ syncPullRequired
228
228
  });
229
229
 
230
230
  const checklistDetail = refData(_ChecklistDetail.default, {
@@ -394,10 +394,10 @@ const syncTelemetry = txData(_SyncTelemetry.default, {
394
394
  syncWeight: 1,
395
395
  syncPullRequired: false
396
396
  });
397
- const userInfo = refData(_UserInfo.default, {
398
- resUrl: "v2/me",
399
- syncWeight: 1,
400
- filter: ""
397
+ const userInfo = txData(_UserInfo.default, {
398
+ resUrl: "me",
399
+ apiVersion: "v2",
400
+ syncWeight: 1
401
401
  });
402
402
  const identifierAssignment = txData(_IdentifierAssignment.default, {
403
403
  syncWeight: 0
@@ -68,6 +68,14 @@ class IdentifierAssignment extends _BaseEntity.default {
68
68
  this.that.programEnrolment = this.fromObject(x);
69
69
  }
70
70
 
71
+ get used() {
72
+ return this.that.used;
73
+ }
74
+
75
+ set used(x) {
76
+ this.that.used = x;
77
+ }
78
+
71
79
  static fromResource(identifierAssignmentResource, entityService) {
72
80
  const identifierAssignment = _General.default.assignFields(identifierAssignmentResource, new IdentifierAssignment(), ["uuid", "identifier", "assignmentOrder", "voided"]);
73
81
 
@@ -120,6 +128,11 @@ _defineProperty(IdentifierAssignment, "schema", {
120
128
  programEnrolment: {
121
129
  type: "ProgramEnrolment",
122
130
  optional: true
131
+ },
132
+ used: {
133
+ type: "bool",
134
+ default: false,
135
+ optional: false
123
136
  }
124
137
  }
125
138
  });
package/dist/Schema.js CHANGED
@@ -200,7 +200,7 @@ const entities = [_DashboardFilter.default, _LocaleMapping.default, _Settings.de
200
200
  function createRealmConfig() {
201
201
  return {
202
202
  //order is important, should be arranged according to the dependency
203
- schemaVersion: 178,
203
+ schemaVersion: 179,
204
204
  onMigration: function (oldDB, newDB) {
205
205
  console.log("[AvniModels.Schema]", `Running migration with old schema version: ${oldDB.schemaVersion} and new schema version: ${newDB.schemaVersion}`);
206
206
 
@@ -766,6 +766,14 @@ function createRealmConfig() {
766
766
  const pushOnlyEntities = newDB.objects(_SchemaNames.default.EntitySyncStatus).filtered("entityName = 'EntityApprovalStatus' OR entityName = 'SyncTelemetry' OR entityName = 'VideoTelemetric' OR entityName = 'RuleFailureTelemetry'");
767
767
  newDB.delete(pushOnlyEntities);
768
768
  }
769
+
770
+ if (oldDB.schemaVersion < 179) {
771
+ _lodash.default.forEach(newDB.objects(_IdentifierAssignment.default.schema.name), identifierAssignment => {
772
+ if (identifierAssignment.individual !== null || identifierAssignment.programEnrolment !== null) {
773
+ identifierAssignment.used = true;
774
+ }
775
+ });
776
+ }
769
777
  }
770
778
  };
771
779
  }
@@ -140,6 +140,7 @@ class FormElementGroup extends _BaseEntity.default {
140
140
  }
141
141
 
142
142
  addFormElement(formElement) {
143
+ formElement.formElementGroup = this;
143
144
  this.formElements.push(formElement);
144
145
  }
145
146
 
@@ -64,7 +64,8 @@ class ValidationResult {
64
64
 
65
65
  _defineProperty(ValidationResult, "ValidationTypes", {
66
66
  Form: "Form",
67
- Rule: "Rule"
67
+ Rule: "Rule",
68
+ Database: "Database"
68
69
  });
69
70
 
70
71
  var _default = ValidationResult;
@@ -59,7 +59,9 @@ class RealmResultsProxy {
59
59
  }
60
60
 
61
61
  getAt(index) {
62
- return this.createEntity(this.realmCollection[index]);
62
+ const realmCollectionElement = this.realmCollection[index];
63
+ if (_lodash.default.isNil(realmCollectionElement)) return null;
64
+ return this.createEntity(realmCollectionElement);
63
65
  }
64
66
 
65
67
  forEach(callback, thisArg) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "openchs-models",
3
3
  "description": "OpenCHS data model to be used by front end clients",
4
- "version": "1.30.73",
4
+ "version": "1.30.75",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",