clarion-shared-types 1.0.133 → 1.0.134

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 (53) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/modules/permission/enums/permission-actions.enum.js +7 -0
  4. package/dist/cjs/modules/permission/enums/permission-actions.enum.js.map +1 -1
  5. package/dist/cjs/modules/permission/enums/permissions-moudule.enum.js +1 -0
  6. package/dist/cjs/modules/permission/enums/permissions-moudule.enum.js.map +1 -1
  7. package/dist/cjs/modules/safety-profile/constants/safety-profile.const.js +110 -0
  8. package/dist/cjs/modules/safety-profile/constants/safety-profile.const.js.map +1 -0
  9. package/dist/cjs/modules/safety-profile/enums/safety-profile.enums.js +188 -0
  10. package/dist/cjs/modules/safety-profile/enums/safety-profile.enums.js.map +1 -0
  11. package/dist/cjs/modules/safety-profile/index.js +27 -0
  12. package/dist/cjs/modules/safety-profile/index.js.map +1 -0
  13. package/dist/cjs/modules/safety-profile/interfaces/safety-profile-sections.js +4 -0
  14. package/dist/cjs/modules/safety-profile/interfaces/safety-profile-sections.js.map +1 -0
  15. package/dist/cjs/modules/safety-profile/interfaces/safety-profile-views.js +3 -0
  16. package/dist/cjs/modules/safety-profile/interfaces/safety-profile-views.js.map +1 -0
  17. package/dist/cjs/modules/safety-profile/utils/safety-profile-display.util.js +137 -0
  18. package/dist/cjs/modules/safety-profile/utils/safety-profile-display.util.js.map +1 -0
  19. package/dist/cjs/modules/safety-profile/utils/safety-profile-visibility.util.js +43 -0
  20. package/dist/cjs/modules/safety-profile/utils/safety-profile-visibility.util.js.map +1 -0
  21. package/dist/esm/index.js +1 -0
  22. package/dist/esm/index.js.map +1 -1
  23. package/dist/esm/modules/permission/enums/permission-actions.enum.js +7 -0
  24. package/dist/esm/modules/permission/enums/permission-actions.enum.js.map +1 -1
  25. package/dist/esm/modules/permission/enums/permissions-moudule.enum.js +1 -0
  26. package/dist/esm/modules/permission/enums/permissions-moudule.enum.js.map +1 -1
  27. package/dist/esm/modules/safety-profile/constants/safety-profile.const.js +107 -0
  28. package/dist/esm/modules/safety-profile/constants/safety-profile.const.js.map +1 -0
  29. package/dist/esm/modules/safety-profile/enums/safety-profile.enums.js +185 -0
  30. package/dist/esm/modules/safety-profile/enums/safety-profile.enums.js.map +1 -0
  31. package/dist/esm/modules/safety-profile/index.js +11 -0
  32. package/dist/esm/modules/safety-profile/index.js.map +1 -0
  33. package/dist/esm/modules/safety-profile/interfaces/safety-profile-sections.js +2 -0
  34. package/dist/esm/modules/safety-profile/interfaces/safety-profile-sections.js.map +1 -0
  35. package/dist/esm/modules/safety-profile/interfaces/safety-profile-views.js +2 -0
  36. package/dist/esm/modules/safety-profile/interfaces/safety-profile-views.js.map +1 -0
  37. package/dist/esm/modules/safety-profile/utils/safety-profile-display.util.js +132 -0
  38. package/dist/esm/modules/safety-profile/utils/safety-profile-display.util.js.map +1 -0
  39. package/dist/esm/modules/safety-profile/utils/safety-profile-visibility.util.js +40 -0
  40. package/dist/esm/modules/safety-profile/utils/safety-profile-visibility.util.js.map +1 -0
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/modules/permission/enums/permission-actions.enum.d.ts +3 -0
  43. package/dist/types/modules/permission/enums/permissions-moudule.enum.d.ts +1 -0
  44. package/dist/types/modules/safety-profile/constants/safety-profile.const.d.ts +69 -0
  45. package/dist/types/modules/safety-profile/enums/safety-profile.enums.d.ts +168 -0
  46. package/dist/types/modules/safety-profile/index.d.ts +6 -0
  47. package/dist/types/modules/safety-profile/interfaces/safety-profile-sections.d.ts +163 -0
  48. package/dist/types/modules/safety-profile/interfaces/safety-profile-views.d.ts +249 -0
  49. package/dist/types/modules/safety-profile/utils/safety-profile-display.util.d.ts +25 -0
  50. package/dist/types/modules/safety-profile/utils/safety-profile-visibility.util.d.ts +38 -0
  51. package/dist/types/modules/user/interfaces/guardian.d.ts +2 -0
  52. package/dist/types/modules/user/interfaces/guardians-response.d.ts +2 -0
  53. package/package.json +1 -1
@@ -0,0 +1,249 @@
1
+ import { SavedPlaceView } from '../../gis/interfaces/routing';
2
+ import { GuardianRelationship } from '../../user/enums/guardian-relationship.enum';
3
+ import { SafetyProfileAudience, SafetyProfileCategory, SafetyProfileGender, SafetyProfileHiddenReason, SafetyProfilePhotoKind } from '../enums/safety-profile.enums';
4
+ import { SafetyProfileSectionData, StoredSafetyProfileCategory } from './safety-profile-sections';
5
+ /** A category's sharing choices. */
6
+ export interface SafetyProfileSectionSettings {
7
+ /** When the person agreed to share this category; null = not agreed (nothing stored). */
8
+ consentedAt: string | null;
9
+ /** The consent text version agreed to (SAFETY_PROFILE_CONSENT_VERSION at the time). */
10
+ consentVersion: string | null;
11
+ /** Shown to the control room and responders only during an active emergency. Default on. */
12
+ onlyDuringSos: boolean;
13
+ /** Shown to the person's guardians too (never SAFETY_RISK or DEVICE). Default off. */
14
+ shareWithGuardians: boolean;
15
+ }
16
+ export interface SafetyProfileCategoryCompletion {
17
+ category: SafetyProfileCategory;
18
+ filled: number;
19
+ total: number;
20
+ /** 0-100, rounded down; 100 only when everything is filled. */
21
+ percent: number;
22
+ complete: boolean;
23
+ }
24
+ export interface SafetyProfileCompletion {
25
+ /** The mean of the categories' percents, rounded down. */
26
+ percent: number;
27
+ completeCategories: number;
28
+ totalCategories: number;
29
+ categories: SafetyProfileCategoryCompletion[];
30
+ }
31
+ /** One category as its owner sees it. */
32
+ export interface SafetyProfileSectionState<T = SafetyProfileSectionData> {
33
+ category: StoredSafetyProfileCategory;
34
+ /** Null when nothing has been saved. */
35
+ data: T | null;
36
+ settings: SafetyProfileSectionSettings;
37
+ /** Optimistic-concurrency version; send it back as expectedVersion. 0 = never saved. */
38
+ version: number;
39
+ updatedAt: string | null;
40
+ }
41
+ /** The account fields the profile shows but does not own (users table). */
42
+ export interface SafetyProfileAccount {
43
+ userId: number;
44
+ name: string;
45
+ avatar: string | null;
46
+ nickname: string | null;
47
+ /** The name the person appears under on the newsfeed (unique; see PublicUserProfile). */
48
+ publicName: string | null;
49
+ /** YYYY-MM-DD. */
50
+ dateOfBirth: string | null;
51
+ phoneNumber: string | null;
52
+ phoneVerified: boolean;
53
+ email: string | null;
54
+ emailVerified: boolean;
55
+ countryCode: string | null;
56
+ lastLoginAt: string | null;
57
+ lastActiveAt: string | null;
58
+ createdAt: string | null;
59
+ }
60
+ /** A device the app reported (PUT /safety-profile/me/devices/current). */
61
+ export interface SafetyProfileDeviceView {
62
+ /** The app installation's own id - distinguishes a person's devices. */
63
+ installationId: string;
64
+ platform: string;
65
+ manufacturer: string | null;
66
+ model: string | null;
67
+ osVersion: string | null;
68
+ appVersion: string | null;
69
+ simCountryIso: string | null;
70
+ simCarrier: string | null;
71
+ firstSeenAt: string;
72
+ lastActiveAt: string;
73
+ }
74
+ /** A contact of the person: a guardian (alerted on SOS) or an emergency contact (not alerted). */
75
+ export interface SafetyProfileContactView {
76
+ id: number;
77
+ name: string;
78
+ phoneNumber: string | null;
79
+ relationship: GuardianRelationship | null;
80
+ isPrimary: boolean;
81
+ notifyOnSos: boolean;
82
+ /** True when the contact is an app account of the same organization. */
83
+ isAppUser: boolean;
84
+ }
85
+ export interface SafetyProfileEmergencyContactsSummary {
86
+ guardians: number;
87
+ emergencyContacts: number;
88
+ hasPrimary: boolean;
89
+ }
90
+ /** GET /safety-profile/me - everything, for the owner. */
91
+ export interface MySafetyProfile {
92
+ account: SafetyProfileAccount;
93
+ sections: SafetyProfileSectionState[];
94
+ emergencyContacts: SafetyProfileEmergencyContactsSummary;
95
+ devices: SafetyProfileDeviceView[];
96
+ /** The saved places the sections reference, by id. A missing id = the place was deleted. */
97
+ places: Record<string, SavedPlaceView>;
98
+ completion: SafetyProfileCompletion;
99
+ consentVersion: string;
100
+ explanation: string;
101
+ }
102
+ /** A photo, with a short-lived link the viewer can load. */
103
+ export interface SafetyProfilePhotoView {
104
+ kind: SafetyProfilePhotoKind;
105
+ imageId: number;
106
+ url: string | null;
107
+ thumbnailUrl: string | null;
108
+ takenOn: string | null;
109
+ }
110
+ export interface SafetyProfileHiddenCategory {
111
+ category: SafetyProfileCategory;
112
+ reason: SafetyProfileHiddenReason;
113
+ }
114
+ /** What the emergency context was when the view was built. */
115
+ export interface SafetyProfileEmergencyContext {
116
+ incidentId: number | null;
117
+ dispatchId: number | null;
118
+ active: boolean;
119
+ }
120
+ /** One visible category in a viewer's profile. */
121
+ export interface SafetyProfileVisibleSection<T = SafetyProfileSectionData> {
122
+ category: StoredSafetyProfileCategory;
123
+ data: T;
124
+ updatedAt: string | null;
125
+ }
126
+ /** The subscription standing the control room sees on the device card. */
127
+ export interface SafetyProfileSubscriptionView {
128
+ tier: string;
129
+ canAlertProvider: boolean;
130
+ reason: string | null;
131
+ expiresAt: string | null;
132
+ }
133
+ /** POST /safety-profiles/users/:userId/view (FULL) - another person's profile, filtered for the viewer. */
134
+ export interface SafetyProfileAudienceView {
135
+ audience: SafetyProfileAudience;
136
+ subject: {
137
+ userId: number;
138
+ name: string;
139
+ avatar: string | null;
140
+ nickname: string | null;
141
+ phoneNumber: string | null;
142
+ phoneVerified: boolean;
143
+ email: string | null;
144
+ emailVerified: boolean;
145
+ /** Only when IDENTITY is visible. */
146
+ dateOfBirth: string | null;
147
+ countryCode: string | null;
148
+ };
149
+ emergency: SafetyProfileEmergencyContext;
150
+ /** True when an authorised control-room user overrode "only during SOS" (logged with the reason). */
151
+ override: boolean;
152
+ sections: SafetyProfileVisibleSection[];
153
+ hidden: SafetyProfileHiddenCategory[];
154
+ /** Every contact for the control room; none for a guardian. */
155
+ contacts: SafetyProfileContactView[];
156
+ places: Record<string, SavedPlaceView>;
157
+ photos: SafetyProfilePhotoView[];
158
+ /** The control room only, when DEVICE is visible. */
159
+ device: {
160
+ lastLoginAt: string | null;
161
+ lastActiveAt: string | null;
162
+ devices: SafetyProfileDeviceView[];
163
+ subscription: SafetyProfileSubscriptionView | null;
164
+ } | null;
165
+ completion: SafetyProfileCompletion;
166
+ viewedAt: string;
167
+ }
168
+ export interface SafetyProfileCompactPlace {
169
+ label: string | null;
170
+ address: string | null;
171
+ lat: number | null;
172
+ lng: number | null;
173
+ /** Building, house number and floor, joined - for the responder at the gate. */
174
+ detail: string | null;
175
+ landmarks: string | null;
176
+ }
177
+ /**
178
+ * POST /safety-profiles/users/:userId/view (COMPACT) - the responder's single card,
179
+ * most useful first. Everything absent is null rather than omitted.
180
+ */
181
+ export interface SafetyProfileCompactView {
182
+ subjectUserId: number;
183
+ name: string;
184
+ nickname: string | null;
185
+ /** The best photo: the recent / front photo when shared, else the account photo. */
186
+ photoUrl: string | null;
187
+ phoneNumber: string | null;
188
+ phoneVerified: boolean;
189
+ alternativePhones: string[];
190
+ gender: SafetyProfileGender | null;
191
+ age: number | null;
192
+ /** The person asked not to be called in an emergency. Shown first, loudly. */
193
+ silentEmergency: boolean;
194
+ primaryGuardian: {
195
+ name: string;
196
+ phoneNumber: string | null;
197
+ relationship: GuardianRelationship | null;
198
+ } | null;
199
+ home: SafetyProfileCompactPlace | null;
200
+ workplace: (SafetyProfileCompactPlace & {
201
+ employerName: string | null;
202
+ }) | null;
203
+ vehicles: Array<{
204
+ description: string;
205
+ registrationNumber: string | null;
206
+ colour: string | null;
207
+ }>;
208
+ medical: {
209
+ bloodGroup: string | null;
210
+ allergies: string[];
211
+ conditions: string[];
212
+ disabilities: string[];
213
+ pregnant: boolean;
214
+ notes: string | null;
215
+ } | null;
216
+ /** Categories the person keeps from responders, so the card can say so. */
217
+ withheld: SafetyProfileCategory[];
218
+ emergency: SafetyProfileEmergencyContext;
219
+ viewedAt: string;
220
+ }
221
+ /** One line of "who viewed my profile". */
222
+ export interface SafetyProfileAccessLogEntry {
223
+ id: number;
224
+ audience: SafetyProfileAudience;
225
+ viewer: {
226
+ userId: number | null;
227
+ name: string | null;
228
+ /** Role names, for the console; the app shows a plain label. */
229
+ roles: string[];
230
+ organizationId: number | null;
231
+ controlCentreId: number | null;
232
+ };
233
+ incidentId: number | null;
234
+ dispatchId: number | null;
235
+ emergencyActive: boolean;
236
+ override: boolean;
237
+ reason: string | null;
238
+ categories: SafetyProfileCategory[];
239
+ createdAt: string;
240
+ }
241
+ export interface SafetyProfileAccessLogPage {
242
+ data: SafetyProfileAccessLogEntry[];
243
+ meta: {
244
+ total: number;
245
+ page: number;
246
+ limit: number;
247
+ totalPages: number;
248
+ };
249
+ }
@@ -0,0 +1,25 @@
1
+ import { BloodGroup, ChronicCondition, DisabilityType, FrequentPlaceType, HighRiskOccupation, PregnancyStatus, SafetyProfileAudience, SafetyProfileGender, SafetyProfileHiddenReason, SafetyProfilePhotoKind, VehicleOwnership, VehicleType, WorkSchedule } from '../enums/safety-profile.enums';
2
+ /**
3
+ * Human labels for the Safety Profile enums, so every console screen names a
4
+ * value the same way the app does.
5
+ */
6
+ export declare const SAFETY_PROFILE_GENDER_LABELS: Readonly<Record<SafetyProfileGender, string>>;
7
+ export declare const SAFETY_PROFILE_PHOTO_KIND_LABELS: Readonly<Record<SafetyProfilePhotoKind, string>>;
8
+ export declare const BLOOD_GROUP_LABELS: Readonly<Record<BloodGroup, string>>;
9
+ export declare const CHRONIC_CONDITION_LABELS: Readonly<Record<ChronicCondition, string>>;
10
+ export declare const DISABILITY_TYPE_LABELS: Readonly<Record<DisabilityType, string>>;
11
+ export declare const PREGNANCY_STATUS_LABELS: Readonly<Record<PregnancyStatus, string>>;
12
+ export declare const WORK_SCHEDULE_LABELS: Readonly<Record<WorkSchedule, string>>;
13
+ export declare const FREQUENT_PLACE_TYPE_LABELS: Readonly<Record<FrequentPlaceType, string>>;
14
+ export declare const VEHICLE_OWNERSHIP_LABELS: Readonly<Record<VehicleOwnership, string>>;
15
+ export declare const VEHICLE_TYPE_LABELS: Readonly<Record<VehicleType, string>>;
16
+ export declare const HIGH_RISK_OCCUPATION_LABELS: Readonly<Record<HighRiskOccupation, string>>;
17
+ export declare const SAFETY_PROFILE_AUDIENCE_LABELS: Readonly<Record<SafetyProfileAudience, string>>;
18
+ export declare const SAFETY_PROFILE_HIDDEN_REASON_LABELS: Readonly<Record<SafetyProfileHiddenReason, string>>;
19
+ /**
20
+ * The label for a value of any of the maps above, or the raw value when it is
21
+ * unknown (a newer server) - never blank.
22
+ */
23
+ export declare function safetyProfileLabel<K extends string>(labels: Readonly<Record<K, string>>, value: K | string | null | undefined): string;
24
+ /** "35 years" from a YYYY-MM-DD date of birth, or null; `today` is injectable for tests. */
25
+ export declare function safetyProfileAge(dateOfBirth: string | null | undefined, today?: Date): number | null;
@@ -0,0 +1,38 @@
1
+ import { SafetyProfileAudience, SafetyProfileCategory, SafetyProfileHiddenReason } from '../enums/safety-profile.enums';
2
+ /**
3
+ * Who sees which category, and when - the whole rule in one function, so the
4
+ * console, the responder card and the guardian view cannot drift apart.
5
+ *
6
+ * - Nothing is shown of a category the person never consented to or never filled.
7
+ * - A responder sees anything only during an ACTIVE dispatch to the person's
8
+ * emergency, and only the categories of their compact card.
9
+ * - The control room sees a category when the person shares it at all times, or
10
+ * during an active emergency of theirs, or under an emergency override
11
+ * (override:safety-profile, with a logged reason).
12
+ * - A guardian sees a category only if the person chose to share it with their
13
+ * guardians, and - when it is "only during SOS" - only during the person's SOS.
14
+ * Never the safe word or threats, never the device; never by override.
15
+ */
16
+ export interface SafetyProfileVisibilityInput {
17
+ audience: SafetyProfileAudience;
18
+ category: SafetyProfileCategory;
19
+ /** The category's settings; null when it has none (never consented / saved). */
20
+ settings: {
21
+ consented: boolean;
22
+ onlyDuringSos: boolean;
23
+ shareWithGuardians: boolean;
24
+ } | null;
25
+ /** Whether there is anything to show (a stored document, or contacts). */
26
+ hasData: boolean;
27
+ emergencyActive: boolean;
28
+ override: boolean;
29
+ }
30
+ export type SafetyProfileVisibility = {
31
+ visible: true;
32
+ }
33
+ /** `reason` null: nothing to show, so nothing to mention. */
34
+ | {
35
+ visible: false;
36
+ reason: SafetyProfileHiddenReason | null;
37
+ };
38
+ export declare function safetyProfileVisibility(input: SafetyProfileVisibilityInput): SafetyProfileVisibility;
@@ -7,4 +7,6 @@ export interface Guardian {
7
7
  relationship?: GuardianRelationship;
8
8
  email?: string;
9
9
  isSystemGuardian?: boolean;
10
+ /** Alerted on SOS (a guardian); false = an emergency contact, never alerted. */
11
+ notifyOnSos?: boolean;
10
12
  }
@@ -7,4 +7,6 @@ import { GuardianRelation } from "./guardian-relation";
7
7
  export interface GuardiansResponse {
8
8
  externalGuardians: Guardian[];
9
9
  systemGuardians: GuardianRelation[];
10
+ /** Contacts the person chose NOT to alert on SOS; the two lists above are guardians only. */
11
+ emergencyContacts?: Guardian[];
10
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarion-shared-types",
3
- "version": "1.0.133",
3
+ "version": "1.0.134",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",