grm-shared-library 1.1.197 → 1.1.199

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 (61) hide show
  1. package/dist/cjs/modules/partner/constants/partner-defaults.const.js +25 -1
  2. package/dist/cjs/modules/partner/constants/partner-defaults.const.js.map +1 -1
  3. package/dist/cjs/modules/partner/dtos/amend-partner-dispatch.dto.js +95 -0
  4. package/dist/cjs/modules/partner/dtos/amend-partner-dispatch.dto.js.map +1 -0
  5. package/dist/cjs/modules/partner/dtos/update-incident-partner-routing.dto.js +72 -1
  6. package/dist/cjs/modules/partner/dtos/update-incident-partner-routing.dto.js.map +1 -1
  7. package/dist/cjs/modules/partner/enums/partner-adapter-operation.enum.js +13 -0
  8. package/dist/cjs/modules/partner/enums/partner-adapter-operation.enum.js.map +1 -1
  9. package/dist/cjs/modules/partner/enums/partner-dispatch-status.enum.js +40 -11
  10. package/dist/cjs/modules/partner/enums/partner-dispatch-status.enum.js.map +1 -1
  11. package/dist/cjs/modules/partner/enums/partner-engagement-state.enum.js +24 -0
  12. package/dist/cjs/modules/partner/enums/partner-engagement-state.enum.js.map +1 -0
  13. package/dist/cjs/modules/partner/index.js +3 -0
  14. package/dist/cjs/modules/partner/index.js.map +1 -1
  15. package/dist/cjs/modules/partner/interfaces/partner-dispatch-progress.js +3 -0
  16. package/dist/cjs/modules/partner/interfaces/partner-dispatch-progress.js.map +1 -0
  17. package/dist/cjs/modules/partner/utils/partner-routing.util.js +10 -0
  18. package/dist/cjs/modules/partner/utils/partner-routing.util.js.map +1 -1
  19. package/dist/cjs/modules/permission/data/permissions.data.js +1 -0
  20. package/dist/cjs/modules/permission/data/permissions.data.js.map +1 -1
  21. package/dist/cjs/modules/permission/enums/permission-actions.enum.js +5 -0
  22. package/dist/cjs/modules/permission/enums/permission-actions.enum.js.map +1 -1
  23. package/dist/cjs/modules/role/data/roles.data.js +4 -0
  24. package/dist/cjs/modules/role/data/roles.data.js.map +1 -1
  25. package/dist/esm/modules/partner/constants/partner-defaults.const.js +24 -0
  26. package/dist/esm/modules/partner/constants/partner-defaults.const.js.map +1 -1
  27. package/dist/esm/modules/partner/dtos/amend-partner-dispatch.dto.js +90 -0
  28. package/dist/esm/modules/partner/dtos/amend-partner-dispatch.dto.js.map +1 -0
  29. package/dist/esm/modules/partner/dtos/update-incident-partner-routing.dto.js +69 -0
  30. package/dist/esm/modules/partner/dtos/update-incident-partner-routing.dto.js.map +1 -1
  31. package/dist/esm/modules/partner/enums/partner-adapter-operation.enum.js +13 -0
  32. package/dist/esm/modules/partner/enums/partner-adapter-operation.enum.js.map +1 -1
  33. package/dist/esm/modules/partner/enums/partner-dispatch-status.enum.js +39 -10
  34. package/dist/esm/modules/partner/enums/partner-dispatch-status.enum.js.map +1 -1
  35. package/dist/esm/modules/partner/enums/partner-engagement-state.enum.js +21 -0
  36. package/dist/esm/modules/partner/enums/partner-engagement-state.enum.js.map +1 -0
  37. package/dist/esm/modules/partner/index.js +3 -0
  38. package/dist/esm/modules/partner/index.js.map +1 -1
  39. package/dist/esm/modules/partner/interfaces/partner-dispatch-progress.js +2 -0
  40. package/dist/esm/modules/partner/interfaces/partner-dispatch-progress.js.map +1 -0
  41. package/dist/esm/modules/partner/utils/partner-routing.util.js +10 -0
  42. package/dist/esm/modules/partner/utils/partner-routing.util.js.map +1 -1
  43. package/dist/esm/modules/permission/data/permissions.data.js +1 -0
  44. package/dist/esm/modules/permission/data/permissions.data.js.map +1 -1
  45. package/dist/esm/modules/permission/enums/permission-actions.enum.js +5 -0
  46. package/dist/esm/modules/permission/enums/permission-actions.enum.js.map +1 -1
  47. package/dist/esm/modules/role/data/roles.data.js +4 -0
  48. package/dist/esm/modules/role/data/roles.data.js.map +1 -1
  49. package/dist/types/modules/partner/constants/partner-defaults.const.d.ts +24 -0
  50. package/dist/types/modules/partner/dtos/amend-partner-dispatch.dto.d.ts +27 -0
  51. package/dist/types/modules/partner/dtos/update-incident-partner-routing.dto.d.ts +16 -0
  52. package/dist/types/modules/partner/enums/partner-adapter-operation.enum.d.ts +14 -1
  53. package/dist/types/modules/partner/enums/partner-dispatch-status.enum.d.ts +33 -8
  54. package/dist/types/modules/partner/enums/partner-engagement-state.enum.d.ts +19 -0
  55. package/dist/types/modules/partner/index.d.ts +3 -0
  56. package/dist/types/modules/partner/interfaces/incident-partner-routing.d.ts +13 -0
  57. package/dist/types/modules/partner/interfaces/partner-dispatch-progress.d.ts +48 -0
  58. package/dist/types/modules/partner/interfaces/partner-dispatch.d.ts +22 -0
  59. package/dist/types/modules/partner/interfaces/partner-provider-descriptor.d.ts +29 -0
  60. package/dist/types/modules/permission/enums/permission-actions.enum.d.ts +1 -0
  61. package/package.json +1 -1
@@ -0,0 +1,27 @@
1
+ /** A corrected location for an emergency a partner is already working. */
2
+ export declare class AmendPartnerDispatchLocationDto {
3
+ latitude: number;
4
+ longitude: number;
5
+ measuredAt?: string;
6
+ }
7
+ /**
8
+ * Correct the details of an emergency a partner already has.
9
+ *
10
+ * The case this exists for is the ordinary one: a caller rings back with a
11
+ * better address while a responder is already moving. Sending the correction
12
+ * beats hoping the crew works it out.
13
+ *
14
+ * Only the fields a partner will actually accept mid-flight are here - who the
15
+ * emergency is FOR never changes, so the reporter and their phone number are
16
+ * deliberately absent. Every field is optional; sending none is a no-op rather
17
+ * than an error.
18
+ *
19
+ * Only meaningful for a partner whose descriptor sets `supportsAmendment`. For
20
+ * anyone else clarion-partner-services refuses plainly rather than pretending.
21
+ */
22
+ export declare class AmendPartnerDispatchDto {
23
+ address?: string;
24
+ issue?: string;
25
+ location?: AmendPartnerDispatchLocationDto;
26
+ reason?: string;
27
+ }
@@ -1,8 +1,21 @@
1
1
  import { IncidentPartnerRoutingStatus } from '../enums/incident-partner-routing-status.enum';
2
+ import { PartnerEngagementState } from '../enums/partner-engagement-state.enum';
2
3
  import { PartnerDispatchStatus } from '../enums/partner-dispatch-status.enum';
3
4
  import { PartnerProviderCode } from '../enums/partner-provider-code.enum';
4
5
  import { PartnerRoutingMode } from '../enums/partner-routing-mode.enum';
5
6
  import { PartnerServiceCapability } from '../enums/partner-service-capability.enum';
7
+ /** Whoever the partner has put on the job, as carried on the incident. */
8
+ export declare class IncidentPartnerResponderDto {
9
+ name?: string;
10
+ phoneNumber?: string;
11
+ reference?: string;
12
+ }
13
+ /** The unit the partner has assigned, as carried on the incident. */
14
+ export declare class IncidentPartnerVehicleDto {
15
+ identifier?: string;
16
+ description?: string;
17
+ serviceType?: string;
18
+ }
6
19
  /** One partner's leg of an incident's routing, as pushed back to clarion-incident. */
7
20
  export declare class IncidentPartnerRoutingEntryDto {
8
21
  integrationId: number;
@@ -14,6 +27,9 @@ export declare class IncidentPartnerRoutingEntryDto {
14
27
  dispatchReference: string;
15
28
  status: PartnerDispatchStatus;
16
29
  partnerReference?: string;
30
+ engagementState?: PartnerEngagementState;
31
+ responder?: IncidentPartnerResponderDto;
32
+ vehicle?: IncidentPartnerVehicleDto;
17
33
  updatedAt: string;
18
34
  }
19
35
  /**
@@ -9,5 +9,18 @@ export declare enum PartnerAdapterOperation {
9
9
  /** A non-mutating connectivity probe. */
10
10
  HEALTH_CHECK = "HEALTH_CHECK",
11
11
  /** Submitting the emergency itself. */
12
- DISPATCH = "DISPATCH"
12
+ DISPATCH = "DISPATCH",
13
+ /** Asking the partner what has happened since. */
14
+ FETCH_STATUS = "FETCH_STATUS",
15
+ /** Standing the partner down after they had already accepted it. */
16
+ WITHDRAW = "WITHDRAW",
17
+ /** Correcting details of an emergency the partner is already working. */
18
+ AMEND = "AMEND",
19
+ /**
20
+ * Asking the partner whether a request we may have already sent exists.
21
+ *
22
+ * Used after a timeout, where the request might have landed but the reply
23
+ * never arrived - the one case where re-sending could produce a duplicate.
24
+ */
25
+ LOOKUP = "LOOKUP"
13
26
  }
@@ -1,15 +1,18 @@
1
1
  /**
2
2
  * Lifecycle of one incident's routing to one partner.
3
3
  *
4
- * Terminal states are SENT/ACKNOWLEDGED (the partner has the emergency),
5
- * FAILED, REJECTED, CANCELLED and EXPIRED. Everything else is in flight.
6
- *
7
4
  * MANUAL routing starts at PENDING_APPROVAL and reaches QUEUED only when an
8
5
  * operator approves; declining gives REJECTED, withdrawing gives CANCELLED and
9
6
  * letting the approval window elapse gives EXPIRED. AUTO routing starts at
10
7
  * QUEUED directly. QUEUED -> SENDING -> SENT on success, or back to QUEUED for a
11
8
  * transient retry, or FAILED when the failure is permanent or the attempts run
12
- * out. SENT -> ACKNOWLEDGED when the partner later reports progress.
9
+ * out.
10
+ *
11
+ * Once the partner has it, the remaining transitions come from THEM rather than
12
+ * from us: SENT -> ACKNOWLEDGED when they assign a responder, and either of
13
+ * those -> COMPLETED when they close it. WITHDRAWN is the one exception - an
14
+ * organization standing a partner down after the fact, which is only possible
15
+ * with a partner whose API supports it.
13
16
  */
14
17
  export declare enum PartnerDispatchStatus {
15
18
  /** MANUAL routing: waiting for the organization to confirm or decline. */
@@ -20,18 +23,40 @@ export declare enum PartnerDispatchStatus {
20
23
  SENDING = "SENDING",
21
24
  /** The partner accepted the request and returned its own reference. */
22
25
  SENT = "SENT",
23
- /** The partner has since confirmed progress on the request (status callback). */
26
+ /** The partner has assigned a responder, or otherwise confirmed it is working it. */
24
27
  ACKNOWLEDGED = "ACKNOWLEDGED",
28
+ /** The partner has closed the request. The engagement is over. */
29
+ COMPLETED = "COMPLETED",
25
30
  /** Permanently failed - rejected by the partner, or out of attempts. */
26
31
  FAILED = "FAILED",
27
32
  /** Declined by the organization instead of being sent. */
28
33
  REJECTED = "REJECTED",
29
- /** Withdrawn by the organization (before or after approval, never after SENT). */
34
+ /** Withdrawn by the organization BEFORE the partner ever received it. */
30
35
  CANCELLED = "CANCELLED",
36
+ /**
37
+ * Stood down by the organization AFTER the partner received it.
38
+ *
39
+ * Kept apart from CANCELLED because they are very different facts: one is an
40
+ * emergency a partner never heard about, the other is a responder who was
41
+ * dispatched and recalled. Only the second one costs a partner anything, and
42
+ * only the second one needs explaining in a monthly report.
43
+ */
44
+ WITHDRAWN = "WITHDRAWN",
31
45
  /** The manual-approval window elapsed with no decision. */
32
46
  EXPIRED = "EXPIRED"
33
47
  }
34
- /** Statuses from which no further transition happens. */
48
+ /**
49
+ * Statuses from which no further transition happens.
50
+ *
51
+ * SENT and ACKNOWLEDGED are deliberately NOT terminal: with a partner that
52
+ * publishes request status, both still move - to COMPLETED when the partner
53
+ * closes the request, or to WITHDRAWN if the organization stands them down.
54
+ */
35
55
  export declare const TERMINAL_PARTNER_DISPATCH_STATUSES: readonly PartnerDispatchStatus[];
36
- /** Statuses that mean the partner is (or should shortly be) working the emergency. */
56
+ /** Statuses that mean the partner received the emergency and acted on it. */
37
57
  export declare const DELIVERED_PARTNER_DISPATCH_STATUSES: readonly PartnerDispatchStatus[];
58
+ /**
59
+ * Statuses where the partner holds the emergency and it is not finished, so
60
+ * asking them for progress is worthwhile.
61
+ */
62
+ export declare const POLLABLE_PARTNER_DISPATCH_STATUSES: readonly PartnerDispatchStatus[];
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What a partner says is happening with an emergency we handed them, reduced to
3
+ * the only three answers every partner can give.
4
+ *
5
+ * Provider-neutral on purpose. Partners describe progress in their own
6
+ * vocabulary - Rescue.co says CURRENT and CLOSED, another will say OPEN and
7
+ * RESOLVED, a third will have six intermediate states - and the platform must
8
+ * not learn any of them. The adapter maps its partner's word onto one of these,
9
+ * and keeps the original in `partnerStatus` so an operator still sees exactly
10
+ * what the partner said.
11
+ */
12
+ export declare enum PartnerEngagementState {
13
+ /** The partner is working the emergency. */
14
+ ACTIVE = "ACTIVE",
15
+ /** The partner has closed it. Nothing further will happen on their side. */
16
+ CLOSED = "CLOSED",
17
+ /** The partner reported something this adapter does not recognise. */
18
+ UNKNOWN = "UNKNOWN"
19
+ }
@@ -5,6 +5,7 @@ export * from './enums/partner-integration-environment.enum';
5
5
  export * from './enums/partner-integration-status.enum';
6
6
  export * from './enums/partner-coverage-match-type.enum';
7
7
  export * from './enums/partner-dispatch-status.enum';
8
+ export * from './enums/partner-engagement-state.enum';
8
9
  export * from './enums/partner-dispatch-failure-reason.enum';
9
10
  export * from './enums/partner-location-provider.enum';
10
11
  export * from './enums/partner-adapter-operation.enum';
@@ -14,6 +15,7 @@ export * from './interfaces/partner-provider-descriptor';
14
15
  export * from './interfaces/partner-integration';
15
16
  export * from './interfaces/partner-coverage-rule';
16
17
  export * from './interfaces/partner-dispatch-location';
18
+ export * from './interfaces/partner-dispatch-progress';
17
19
  export * from './interfaces/partner-emergency-contact';
18
20
  export * from './interfaces/partner-dispatch';
19
21
  export * from './interfaces/incident-partner-routing';
@@ -28,6 +30,7 @@ export * from './dtos/create-partner-coverage-rule.dto';
28
30
  export * from './dtos/update-partner-coverage-rule.dto';
29
31
  export * from './dtos/route-incident-to-partners.dto';
30
32
  export * from './dtos/partner-dispatch-decision.dto';
33
+ export * from './dtos/amend-partner-dispatch.dto';
31
34
  export * from './dtos/update-incident-partner-routing.dto';
32
35
  export * from './utils/partner-routing.util';
33
36
  export * from './utils/partner-payload.util';
@@ -1,8 +1,10 @@
1
1
  import { IncidentPartnerRoutingStatus } from '../enums/incident-partner-routing-status.enum';
2
+ import { PartnerEngagementState } from '../enums/partner-engagement-state.enum';
2
3
  import { PartnerDispatchStatus } from '../enums/partner-dispatch-status.enum';
3
4
  import { PartnerProviderCode } from '../enums/partner-provider-code.enum';
4
5
  import { PartnerRoutingMode } from '../enums/partner-routing-mode.enum';
5
6
  import { PartnerServiceCapability } from '../enums/partner-service-capability.enum';
7
+ import { PartnerResponderInfo, PartnerResponderVehicle } from './partner-dispatch-progress';
6
8
  /** One partner's leg of an incident's routing, as recorded on the incident. */
7
9
  export interface IncidentPartnerRoutingEntry {
8
10
  integrationId: number;
@@ -16,6 +18,17 @@ export interface IncidentPartnerRoutingEntry {
16
18
  status: PartnerDispatchStatus;
17
19
  /** The partner's own reference once it has accepted the request. */
18
20
  partnerReference?: string | null;
21
+ /**
22
+ * What the partner last reported, carried on the incident itself.
23
+ *
24
+ * Denormalized deliberately: "an ambulance is on its way, registration
25
+ * KAA 123B, crew reachable on +254..." is the single most useful sentence
26
+ * on an incident screen, and it should not cost a second request to another
27
+ * service to render it.
28
+ */
29
+ engagementState?: PartnerEngagementState | null;
30
+ responder?: PartnerResponderInfo | null;
31
+ vehicle?: PartnerResponderVehicle | null;
19
32
  updatedAt: string;
20
33
  }
21
34
  /**
@@ -0,0 +1,48 @@
1
+ import { PartnerEngagementState } from '../enums/partner-engagement-state.enum';
2
+ /** Whoever the partner has put on the job. */
3
+ export interface PartnerResponderInfo {
4
+ name?: string | null;
5
+ /** E.164 where the partner gives one. */
6
+ phoneNumber?: string | null;
7
+ /** The partner's own identifier for the responder. */
8
+ reference?: string | null;
9
+ }
10
+ /** The unit the partner has assigned, described the way a control room needs it. */
11
+ export interface PartnerResponderVehicle {
12
+ /** Registration, call sign, or whatever the partner uses to identify the unit. */
13
+ identifier?: string | null;
14
+ /** Human description, e.g. "White Toyota HiAce". */
15
+ description?: string | null;
16
+ /** The partner's own classification of the unit, e.g. "ADVANCED_LIFE_SUPPORT". */
17
+ serviceType?: string | null;
18
+ }
19
+ /**
20
+ * What a partner reports about an emergency they are already working.
21
+ *
22
+ * This is the answer to the question a control room actually asks after
23
+ * dispatching: "is anyone coming, who, and where are they taking them?" Every
24
+ * field is optional because partners differ enormously in what they publish -
25
+ * some return a full crew and vehicle, some return nothing but a status - and
26
+ * the platform must be useful with either.
27
+ *
28
+ * Provider-neutral: `partnerStatus` keeps the partner's own word verbatim so an
29
+ * operator sees exactly what was said, while `state` reduces it to something
30
+ * every screen and every report can rely on.
31
+ */
32
+ export interface PartnerDispatchProgress {
33
+ state: PartnerEngagementState;
34
+ /** The partner's own status string, unmodified. */
35
+ partnerStatus?: string | null;
36
+ /** The partner's human-facing reference, if it appears or changes here. */
37
+ partnerNumber?: string | null;
38
+ responder?: PartnerResponderInfo | null;
39
+ vehicle?: PartnerResponderVehicle | null;
40
+ /** Where the responder is taking the patient, when the partner says. */
41
+ destination?: string | null;
42
+ /** The partner's own label for the journey, e.g. "PENDING", "EN_ROUTE". */
43
+ journeyStatus?: string | null;
44
+ /** When the partner last changed anything, as the partner reports it. */
45
+ partnerUpdatedAt?: string | null;
46
+ /** When this platform last read it. */
47
+ observedAt: string;
48
+ }
@@ -5,7 +5,9 @@ import { PartnerDispatchStatus } from '../enums/partner-dispatch-status.enum';
5
5
  import { PartnerProviderCode } from '../enums/partner-provider-code.enum';
6
6
  import { PartnerRoutingMode } from '../enums/partner-routing-mode.enum';
7
7
  import { PartnerServiceCapability } from '../enums/partner-service-capability.enum';
8
+ import { PartnerEngagementState } from '../enums/partner-engagement-state.enum';
8
9
  import { PartnerDispatchLocation } from './partner-dispatch-location';
10
+ import { PartnerDispatchProgress } from './partner-dispatch-progress';
9
11
  import { PartnerEmergencyContact } from './partner-emergency-contact';
10
12
  /**
11
13
  * The incident facts a dispatch was built from, frozen at routing time.
@@ -100,6 +102,26 @@ export interface PartnerDispatch {
100
102
  partnerNumber?: string | null;
101
103
  /** The partner's own status string, passed through verbatim. */
102
104
  partnerStatus?: string | null;
105
+ /**
106
+ * The partner's status reduced to something every screen can rely on.
107
+ * Absent for a partner that publishes no status at all.
108
+ */
109
+ engagementState?: PartnerEngagementState | null;
110
+ /**
111
+ * What the partner last reported - responder, vehicle, destination.
112
+ *
113
+ * This is the answer to "is anyone actually coming?", which is the only
114
+ * question a control room has once a dispatch has left the building.
115
+ */
116
+ progress?: PartnerDispatchProgress | null;
117
+ /** When progress was last read from the partner. */
118
+ lastPolledAt?: string | null;
119
+ /** When the partner first confirmed it was working the emergency. */
120
+ acknowledgedAt?: string | null;
121
+ /** When the partner closed the request. */
122
+ closedAt?: string | null;
123
+ withdrawnByUserId?: number | null;
124
+ withdrawnAt?: string | null;
103
125
  /** The sanitized body sent to the partner. Never contains a credential. */
104
126
  requestPayload?: Record<string, unknown> | null;
105
127
  /** The sanitized body the partner returned. */
@@ -51,6 +51,35 @@ export interface PartnerProviderDescriptor {
51
51
  credentialFields: PartnerProviderCredentialField[];
52
52
  /** True when the adapter implements a non-mutating connectivity probe. */
53
53
  supportsHealthCheck: boolean;
54
+ /**
55
+ * True when the partner publishes the state of a request we have already
56
+ * sent, so progress can be polled and shown to a control room.
57
+ */
58
+ supportsStatusPolling: boolean;
59
+ /**
60
+ * True when the partner lets a request be stood down after they accepted it.
61
+ *
62
+ * When false, an organization that changes its mind has to telephone the
63
+ * partner - and the platform says so plainly rather than offering a button
64
+ * that quietly does nothing.
65
+ */
66
+ supportsWithdrawal: boolean;
67
+ /**
68
+ * True when the partner lets the details of a live request be corrected.
69
+ *
70
+ * The case that matters is a caller ringing back with a better location
71
+ * after a responder is already moving.
72
+ */
73
+ supportsAmendment: boolean;
74
+ /**
75
+ * True when the partner can be asked whether a request we may already have
76
+ * sent exists.
77
+ *
78
+ * This is what makes a retry after a TIMEOUT safe. Without it, a request
79
+ * that landed but whose reply was lost can only be retried blind, and a
80
+ * blind retry on a non-idempotent emergency API means two ambulances.
81
+ */
82
+ supportsDuplicateDetection: boolean;
54
83
  /** False for reserved provider codes that have no working adapter yet. */
55
84
  available: boolean;
56
85
  }
@@ -9,6 +9,7 @@ export declare enum PermissionActions {
9
9
  DELETE_PARTNER = "delete:partner",
10
10
  READ_PARTNER_DISPATCH = "read:partner-dispatch",
11
11
  APPROVE_PARTNER_DISPATCH = "approve:partner-dispatch",
12
+ UPDATE_PARTNER_DISPATCH = "update:partner-dispatch",
12
13
  CANCEL_PARTNER_DISPATCH = "cancel:partner-dispatch",
13
14
  RESEND_PARTNER_DISPATCH = "resend:partner-dispatch",
14
15
  CREATE_CONTROL_CENTRE = "create:control-centre",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grm-shared-library",
3
- "version": "1.1.197",
3
+ "version": "1.1.199",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",