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,68 +4,50 @@ 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
9
  var _moment = _interopRequireDefault(require("moment"));
13
-
14
10
  var _lodash = _interopRequireDefault(require("lodash"));
15
-
16
11
  var _Video = _interopRequireDefault(require("./Video"));
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
  class VideoTelemetric extends _BaseEntity.default {
25
18
  constructor(that = null) {
26
19
  super(that);
27
20
  }
28
-
29
21
  get video() {
30
22
  return this.toEntity("video", _Video.default);
31
23
  }
32
-
33
24
  set video(x) {
34
25
  this.that.video = this.fromObject(x);
35
26
  }
36
-
37
27
  get playerOpenTime() {
38
28
  return this.that.playerOpenTime;
39
29
  }
40
-
41
30
  set playerOpenTime(x) {
42
31
  this.that.playerOpenTime = x;
43
32
  }
44
-
45
33
  get playerCloseTime() {
46
34
  return this.that.playerCloseTime;
47
35
  }
48
-
49
36
  set playerCloseTime(x) {
50
37
  this.that.playerCloseTime = x;
51
38
  }
52
-
53
39
  get videoStartTime() {
54
40
  return this.that.videoStartTime;
55
41
  }
56
-
57
42
  set videoStartTime(x) {
58
43
  this.that.videoStartTime = x;
59
44
  }
60
-
61
45
  get videoEndTime() {
62
46
  return this.that.videoEndTime;
63
47
  }
64
-
65
48
  set videoEndTime(x) {
66
49
  this.that.videoEndTime = x;
67
50
  }
68
-
69
51
  static create(obj = {}) {
70
52
  const {
71
53
  uuid = _General.default.randomUUID()
@@ -74,51 +56,40 @@ class VideoTelemetric extends _BaseEntity.default {
74
56
  uuid
75
57
  });
76
58
  }
77
-
78
59
  static fromResource() {
79
60
  _General.default.logWarn("This should never be called. The server should always return empty array.\n" + "So, no need to create realm entities.");
80
-
81
61
  return VideoTelemetric.create({});
82
62
  }
83
-
84
63
  cloneForReference() {
85
64
  return VideoTelemetric.create(_lodash.default.assignIn({}, this));
86
65
  }
87
-
88
66
  setPlayerOpenTime() {
89
67
  this.playerOpenTime = (0, _moment.default)().toDate();
90
68
  }
91
-
92
69
  setPlayerCloseTime() {
93
70
  this.playerCloseTime = (0, _moment.default)().toDate();
94
71
  }
95
-
96
72
  setOnceVideoStartTime(videoTime) {
97
73
  if (_lodash.default.isNil(this.videoStartTime)) {
98
74
  this.videoStartTime = this._roundToNearestPoint5(videoTime);
99
75
  }
100
76
  }
101
-
102
77
  setVideoEndTime(videoTime) {
103
78
  this.videoEndTime = this._roundToNearestPoint5(videoTime);
104
79
  }
105
-
106
80
  get toResource() {
107
81
  const resource = _lodash.default.pick(this, ["uuid", "videoStartTime", "videoEndTime"]);
108
-
109
82
  resource.playerOpenTime = _General.default.isoFormat(this.playerOpenTime);
110
83
  resource.playerCloseTime = _General.default.isoFormat(this.playerCloseTime);
111
84
  resource.videoUUID = this.video.uuid;
112
85
  return resource;
113
- } //valid outputs 0,0.5,1,1.5,2,2.5,3,3.5...
114
-
86
+ }
115
87
 
88
+ //valid outputs 0,0.5,1,1.5,2,2.5,3,3.5...
116
89
  _roundToNearestPoint5(n) {
117
90
  return Math.round(n * 2) / 2;
118
91
  }
119
-
120
92
  }
121
-
122
93
  _defineProperty(VideoTelemetric, "schema", {
123
94
  name: _SchemaNames.default.VideoTelemetric,
124
95
  primaryKey: "uuid",
@@ -133,9 +104,7 @@ _defineProperty(VideoTelemetric, "schema", {
133
104
  videoStartTime: "double",
134
105
  //in seconds
135
106
  videoEndTime: "double" //in seconds
136
-
137
107
  }
138
108
  });
139
-
140
109
  var _default = VideoTelemetric;
141
110
  exports.default = _default;
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.33.2",
4
+ "version": "1.33.4",
5
5
  "private": false,
6
6
  "repository": {
7
7
  "type": "git",
@@ -11,12 +11,14 @@
11
11
  "scripts": {
12
12
  "test": "jest",
13
13
  "test-ci": "jest --verbose --forceExit --maxWorkers=2 --ci",
14
+ "test:realm-v12": "jest test/framework/RealmV12CompatibilityTest.js",
14
15
  "build": "babel src --out-dir dist --extensions '.js','.ts' && tsc",
15
16
  "coverage": "istanbul cover --report lcov _mocha --require $(find ./src/test -name '*Test.js')",
16
17
  "doc": "yarn doc:html && open docs/index.html",
17
18
  "doc:html": "typedoc",
18
19
  "doc:publish": "gh-pages -m \"[ci skip] Updates\" -d docs",
19
- "prettier-all": "prettier --write \"src/**/*.ts\" \"src/**/*.js\""
20
+ "prettier-all": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
21
+ "validate:schemas": "node scripts/validateSchemas.js"
20
22
  },
21
23
  "jest": {
22
24
  "testMatch": [
@@ -54,8 +56,9 @@
54
56
  "moment": "^2.22.2",
55
57
  "nyc": "^14.1.1",
56
58
  "prettier": "2.0.5",
59
+ "realm": "^12.14.2",
57
60
  "typedoc": "^0.17.4",
58
- "typescript": "^3.7.4",
61
+ "typescript": "^5.0.4",
59
62
  "uglifyjs-webpack-plugin": "^2.1.3",
60
63
  "webpack": "^4.12.2",
61
64
  "webpack-cli": "^3.0.8",
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Realm Schema Validator - Validates schema compatibility
4
+ * Critical for Realm v12+: All list properties must have explicit objectType
5
+ */
6
+
7
+ const EntityMappingConfig = require('../dist/Schema').default;
8
+
9
+ function validateSchemas() {
10
+ const config = EntityMappingConfig.getInstance().getRealmConfig();
11
+ const issues = [];
12
+
13
+ config.schema.forEach(schema => {
14
+ Object.entries(schema.properties).forEach(([propName, propDef]) => {
15
+ // Critical: Realm v12 requires explicit objectType for list properties
16
+ if (propDef.type === 'list' && !propDef.objectType) {
17
+ issues.push(`${schema.name}.${propName}: Missing objectType`);
18
+ }
19
+ // Critical: No implicit "[]" shorthand allowed in v12
20
+ if (propDef === '[]') {
21
+ issues.push(`${schema.name}.${propName}: Use "mixed[]" instead of "[]"`);
22
+ }
23
+ });
24
+ });
25
+
26
+ if (issues.length > 0) {
27
+ console.error('\n❌ Schema validation failed:\n');
28
+ issues.forEach(issue => console.error(` ${issue}`));
29
+ process.exit(1);
30
+ }
31
+
32
+ console.log(`✓ All ${config.schema.length} schemas valid (v${config.schemaVersion})`);
33
+ }
34
+
35
+ try {
36
+ validateSchemas();
37
+ } catch (error) {
38
+ console.error('Validation failed:', error.message);
39
+ process.exit(1);
40
+ }
package/tsconfig.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "noEmit": true,
8
8
  "target": "es5",
9
9
  "moduleResolution": "node",
10
- "lib": ["es2015", "dom"]
10
+ "lib": ["es2020", "dom"]
11
11
  },
12
12
  "exclude": [
13
13
  "node_modules"