clarion-shared-types 1.0.84 → 1.0.86

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 (63) hide show
  1. package/dist/cjs/index.js +1 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +15 -7
  4. package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -1
  5. package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js +50 -15
  6. package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -1
  7. package/dist/cjs/modules/entitlement/enums/incident-entitlement-scope.enum.js +16 -5
  8. package/dist/cjs/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -1
  9. package/dist/cjs/modules/partner/enums/partner-enums.js +128 -0
  10. package/dist/cjs/modules/partner/enums/partner-enums.js.map +1 -0
  11. package/dist/cjs/modules/partner/index.js +27 -0
  12. package/dist/cjs/modules/partner/index.js.map +1 -0
  13. package/dist/cjs/modules/partner/interfaces/incident-partner-routing.dto.js +3 -0
  14. package/dist/cjs/modules/partner/interfaces/incident-partner-routing.dto.js.map +1 -0
  15. package/dist/cjs/modules/partner/interfaces/partner-coverage-rule.dto.js +3 -0
  16. package/dist/cjs/modules/partner/interfaces/partner-coverage-rule.dto.js.map +1 -0
  17. package/dist/cjs/modules/partner/interfaces/partner-dispatch.dto.js +3 -0
  18. package/dist/cjs/modules/partner/interfaces/partner-dispatch.dto.js.map +1 -0
  19. package/dist/cjs/modules/partner/interfaces/partner-integration.dto.js +3 -0
  20. package/dist/cjs/modules/partner/interfaces/partner-integration.dto.js.map +1 -0
  21. package/dist/cjs/modules/partner/interfaces/partner-provider.dto.js +3 -0
  22. package/dist/cjs/modules/partner/interfaces/partner-provider.dto.js.map +1 -0
  23. package/dist/cjs/modules/partner/utils/partner-display.util.js +116 -0
  24. package/dist/cjs/modules/partner/utils/partner-display.util.js.map +1 -0
  25. package/dist/esm/index.js +1 -0
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +15 -7
  28. package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -1
  29. package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js +48 -15
  30. package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -1
  31. package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js +16 -5
  32. package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -1
  33. package/dist/esm/modules/partner/enums/partner-enums.js +125 -0
  34. package/dist/esm/modules/partner/enums/partner-enums.js.map +1 -0
  35. package/dist/esm/modules/partner/index.js +11 -0
  36. package/dist/esm/modules/partner/index.js.map +1 -0
  37. package/dist/esm/modules/partner/interfaces/incident-partner-routing.dto.js +2 -0
  38. package/dist/esm/modules/partner/interfaces/incident-partner-routing.dto.js.map +1 -0
  39. package/dist/esm/modules/partner/interfaces/partner-coverage-rule.dto.js +2 -0
  40. package/dist/esm/modules/partner/interfaces/partner-coverage-rule.dto.js.map +1 -0
  41. package/dist/esm/modules/partner/interfaces/partner-dispatch.dto.js +2 -0
  42. package/dist/esm/modules/partner/interfaces/partner-dispatch.dto.js.map +1 -0
  43. package/dist/esm/modules/partner/interfaces/partner-integration.dto.js +2 -0
  44. package/dist/esm/modules/partner/interfaces/partner-integration.dto.js.map +1 -0
  45. package/dist/esm/modules/partner/interfaces/partner-provider.dto.js +2 -0
  46. package/dist/esm/modules/partner/interfaces/partner-provider.dto.js.map +1 -0
  47. package/dist/esm/modules/partner/utils/partner-display.util.js +110 -0
  48. package/dist/esm/modules/partner/utils/partner-display.util.js.map +1 -0
  49. package/dist/types/index.d.ts +1 -0
  50. package/dist/types/modules/alert-dispatch/enums/incident-dispatch-scope.enum.d.ts +15 -7
  51. package/dist/types/modules/alert-dispatch/interfaces/alert-dispatch.d.ts +13 -0
  52. package/dist/types/modules/alert-dispatch/utils/alert-dispatch.util.d.ts +43 -15
  53. package/dist/types/modules/entitlement/enums/incident-entitlement-scope.enum.d.ts +17 -6
  54. package/dist/types/modules/incident/intefaces/incident.d.ts +15 -0
  55. package/dist/types/modules/partner/enums/partner-enums.d.ts +112 -0
  56. package/dist/types/modules/partner/index.d.ts +7 -0
  57. package/dist/types/modules/partner/interfaces/incident-partner-routing.dto.d.ts +30 -0
  58. package/dist/types/modules/partner/interfaces/partner-coverage-rule.dto.d.ts +42 -0
  59. package/dist/types/modules/partner/interfaces/partner-dispatch.dto.d.ts +126 -0
  60. package/dist/types/modules/partner/interfaces/partner-integration.dto.d.ts +86 -0
  61. package/dist/types/modules/partner/interfaces/partner-provider.dto.d.ts +53 -0
  62. package/dist/types/modules/partner/utils/partner-display.util.d.ts +37 -0
  63. package/package.json +1 -1
@@ -1,14 +1,25 @@
1
1
  /**
2
2
  * List filter applied to incident queries.
3
3
  *
4
- * ALL — no entitlement filter (default; preserves legacy behaviour).
5
- * ENTITLED — everything except Free-user incidents. Used by the primary admin
6
- * incident list, map and kanban views.
7
- * FREE — only Free-user incidents. Backs the "Incident List - Free Users"
8
- * admin view.
4
+ * ALL — no entitlement filter (default; preserves legacy behaviour).
5
+ * ENTITLED — everything except incidents the reporter was not entitled
6
+ * to send. Used by the primary admin list, map and kanban.
7
+ * FREE — reporters with no entitlement at all: never subscribed,
8
+ * lapsed, or a spent/expired trial. Backs
9
+ * "Incident List - Free Users".
10
+ * UNCOVERED_TYPE — reporters who DO pay, but whose package excludes the
11
+ * incident type they raised. Backs
12
+ * "Incident List - Uncovered Types".
13
+ *
14
+ * The last two both carry tier FREE, because that is what billing stamps in
15
+ * either case, but they are very different situations for an operator: one is
16
+ * an upsell, the other is a paying customer discovering a gap in their cover.
17
+ * `FREE` therefore excludes uncovered-type incidents rather than absorbing
18
+ * them, so the three scopes partition the data with no overlap and no gaps.
9
19
  */
10
20
  export declare enum IncidentEntitlementScope {
11
21
  ALL = "ALL",
12
22
  ENTITLED = "ENTITLED",
13
- FREE = "FREE"
23
+ FREE = "FREE",
24
+ UNCOVERED_TYPE = "UNCOVERED_TYPE"
14
25
  }
@@ -16,6 +16,7 @@ import { IncidentReport } from "./incident-report";
16
16
  import { IncidentEmergencyType } from "../enums/incident-emergency-type.enum";
17
17
  import { IncidentEntitlementSnapshot } from "../../entitlement/interfaces/entitlement-evaluation";
18
18
  import { IncidentEntitlementTier } from "../../entitlement/enums/incident-entitlement-tier.enum";
19
+ import { EntitlementDecisionReason } from "../../entitlement/enums/entitlement-decision-reason.enum";
19
20
  export interface Incident {
20
21
  id?: number;
21
22
  appId: IncidentAppId;
@@ -52,6 +53,14 @@ export interface Incident {
52
53
  entitlementTier?: IncidentEntitlementTier;
53
54
  /** Point-in-time audit of how `entitlementTier` was decided. */
54
55
  entitlementSnapshot?: IncidentEntitlementSnapshot | null;
56
+ /**
57
+ * Why `entitlementTier` came out the way it did, promoted out of the
58
+ * snapshot so it can be filtered and indexed. It is what separates a
59
+ * reporter with no entitlement at all from a paying one whose package
60
+ * excludes the incident type they raised - both carry tier FREE, but they
61
+ * are different conversations and get their own admin views.
62
+ */
63
+ entitlementReason?: EntitlementDecisionReason;
55
64
  /**
56
65
  * Who the reporter asked to be alerted, resolved against their entitlement
57
66
  * at creation. `false` on the provider flag withholds the incident from the
@@ -62,6 +71,12 @@ export interface Incident {
62
71
  */
63
72
  notifyServiceProvider?: boolean;
64
73
  notifyGuardians?: boolean;
74
+ /**
75
+ * What the reporter asked for before entitlement had its say. The
76
+ * "Marked Ignore" views read this rather than the outcome above: an alert
77
+ * billing withheld is not an alert somebody chose to withhold.
78
+ */
79
+ notifyServiceProviderRequested?: boolean;
65
80
  createdAt?: string;
66
81
  updatedAt?: string;
67
82
  category?: IncidentCategory;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Frontend mirrors of the partner enums in grm-shared-library.
3
+ *
4
+ * Kept in ONE file rather than one per enum: the admin's partner screens import
5
+ * most of them together, and the set only means anything as a whole. The values
6
+ * are byte-identical to the backend's, because they travel over the wire as
7
+ * strings and any drift would show up as a silently unstyled chip rather than a
8
+ * compile error.
9
+ */
10
+ /** The third-party partner behind a partnership. */
11
+ export declare enum PartnerProviderCode {
12
+ RESCUE_CO = "RESCUE_CO",
13
+ AAR = "AAR",
14
+ ST_JOHN = "ST_JOHN",
15
+ GENERIC_REST = "GENERIC_REST"
16
+ }
17
+ /** A class of emergency service a partner can be asked to provide. */
18
+ export declare enum PartnerServiceCapability {
19
+ AMBULANCE = "AMBULANCE",
20
+ MEDICAL_EVACUATION = "MEDICAL_EVACUATION",
21
+ FIRE_RESPONSE = "FIRE_RESPONSE",
22
+ SECURITY_RESPONSE = "SECURITY_RESPONSE",
23
+ ROADSIDE_ASSISTANCE = "ROADSIDE_ASSISTANCE",
24
+ TOWING = "TOWING",
25
+ OTHER = "OTHER"
26
+ }
27
+ /** How an incident a partnership covers reaches the partner. */
28
+ export declare enum PartnerRoutingMode {
29
+ /** Sent as soon as the incident is created. */
30
+ AUTO = "AUTO",
31
+ /** Held until an operator confirms it. */
32
+ MANUAL = "MANUAL",
33
+ /** Configuration kept, nothing routed. */
34
+ DISABLED = "DISABLED"
35
+ }
36
+ /** Which of a partner's environments a partnership points at. */
37
+ export declare enum PartnerIntegrationEnvironment {
38
+ SANDBOX = "SANDBOX",
39
+ PRODUCTION = "PRODUCTION"
40
+ }
41
+ /** Last known health of a partnership's connection. Advisory only. */
42
+ export declare enum PartnerIntegrationStatus {
43
+ UNKNOWN = "UNKNOWN",
44
+ HEALTHY = "HEALTHY",
45
+ DEGRADED = "DEGRADED",
46
+ UNREACHABLE = "UNREACHABLE"
47
+ }
48
+ /** What a coverage rule matches an incident on. */
49
+ export declare enum PartnerCoverageMatchType {
50
+ ALL = "ALL",
51
+ INCIDENT_TYPE = "INCIDENT_TYPE",
52
+ INCIDENT_CATEGORY = "INCIDENT_CATEGORY",
53
+ EMERGENCY_TYPE = "EMERGENCY_TYPE"
54
+ }
55
+ /** Lifecycle of one incident's routing to one partner. */
56
+ export declare enum PartnerDispatchStatus {
57
+ PENDING_APPROVAL = "PENDING_APPROVAL",
58
+ QUEUED = "QUEUED",
59
+ SENDING = "SENDING",
60
+ SENT = "SENT",
61
+ ACKNOWLEDGED = "ACKNOWLEDGED",
62
+ FAILED = "FAILED",
63
+ REJECTED = "REJECTED",
64
+ CANCELLED = "CANCELLED",
65
+ EXPIRED = "EXPIRED"
66
+ }
67
+ /** Why a dispatch did not reach its partner. */
68
+ export declare enum PartnerDispatchFailureReason {
69
+ INVALID_PAYLOAD = "INVALID_PAYLOAD",
70
+ MISSING_REQUIRED_FIELD = "MISSING_REQUIRED_FIELD",
71
+ AUTHENTICATION_FAILED = "AUTHENTICATION_FAILED",
72
+ FEATURE_NOT_ENABLED = "FEATURE_NOT_ENABLED",
73
+ PROVIDER_REJECTED = "PROVIDER_REJECTED",
74
+ ADAPTER_NOT_SUPPORTED = "ADAPTER_NOT_SUPPORTED",
75
+ INTEGRATION_DISABLED = "INTEGRATION_DISABLED",
76
+ CREDENTIAL_UNAVAILABLE = "CREDENTIAL_UNAVAILABLE",
77
+ RATE_LIMITED = "RATE_LIMITED",
78
+ PROVIDER_UNAVAILABLE = "PROVIDER_UNAVAILABLE",
79
+ TIMEOUT = "TIMEOUT",
80
+ MAX_ATTEMPTS_EXCEEDED = "MAX_ATTEMPTS_EXCEEDED",
81
+ UNKNOWN = "UNKNOWN"
82
+ }
83
+ /** How the location attached to a dispatch was obtained. */
84
+ export declare enum PartnerLocationProvider {
85
+ GPS = "GPS",
86
+ NETWORK = "NETWORK",
87
+ FUSED = "FUSED"
88
+ }
89
+ /** The outbound partner call an attempt record describes. */
90
+ export declare enum PartnerAdapterOperation {
91
+ AUTHENTICATE = "AUTHENTICATE",
92
+ HEALTH_CHECK = "HEALTH_CHECK",
93
+ DISPATCH = "DISPATCH"
94
+ }
95
+ /** The incident-side summary of third-party routing, stored on the incident row. */
96
+ export declare enum IncidentPartnerRoutingStatus {
97
+ NOT_ROUTED = "NOT_ROUTED",
98
+ PENDING = "PENDING",
99
+ AWAITING_APPROVAL = "AWAITING_APPROVAL",
100
+ ROUTED = "ROUTED",
101
+ PARTIALLY_ROUTED = "PARTIALLY_ROUTED",
102
+ FAILED = "FAILED",
103
+ DECLINED = "DECLINED"
104
+ }
105
+ /** List filter for the admin's partner-routing incident views. */
106
+ export declare enum PartnerDispatchScope {
107
+ ALL = "ALL",
108
+ ROUTED = "ROUTED",
109
+ AWAITING_APPROVAL = "AWAITING_APPROVAL",
110
+ FAILED = "FAILED",
111
+ NOT_ROUTED = "NOT_ROUTED"
112
+ }
@@ -0,0 +1,7 @@
1
+ export * from './enums/partner-enums';
2
+ export * from './interfaces/partner-provider.dto';
3
+ export * from './interfaces/partner-integration.dto';
4
+ export * from './interfaces/partner-coverage-rule.dto';
5
+ export * from './interfaces/partner-dispatch.dto';
6
+ export * from './interfaces/incident-partner-routing.dto';
7
+ export * from './utils/partner-display.util';
@@ -0,0 +1,30 @@
1
+ import { IncidentPartnerRoutingStatus, PartnerDispatchStatus, PartnerProviderCode, PartnerRoutingMode, PartnerServiceCapability } from '../enums/partner-enums';
2
+ /** One partner's leg of an incident's routing, as stored on the incident. */
3
+ export interface IncidentPartnerRoutingEntryDto {
4
+ integrationId: number;
5
+ providerCode: PartnerProviderCode;
6
+ providerName?: string | null;
7
+ capability: PartnerServiceCapability;
8
+ routingMode: PartnerRoutingMode;
9
+ dispatchId: number;
10
+ dispatchReference: string;
11
+ status: PartnerDispatchStatus;
12
+ partnerReference?: string | null;
13
+ updatedAt: string;
14
+ }
15
+ /**
16
+ * The third-party routing summary carried on an incident.
17
+ *
18
+ * A read model owned by clarion-partner-services, so the incident list and
19
+ * detail can answer "was an ambulance called for this?" without a second
20
+ * request. The dispatches themselves live behind
21
+ * `GET /partner-services/dispatches/incidents/:incidentId`.
22
+ */
23
+ export interface IncidentPartnerRoutingSnapshotDto {
24
+ status: IncidentPartnerRoutingStatus;
25
+ evaluatedAt: string;
26
+ consideredIntegrationCount: number;
27
+ entries: IncidentPartnerRoutingEntryDto[];
28
+ /** True when produced without a live answer from clarion-partner-services. */
29
+ degraded?: boolean;
30
+ }
@@ -0,0 +1,42 @@
1
+ import { IncidentEmergencyType } from '../../incident/enums/incident-emergency-type.enum';
2
+ import { PartnerCoverageMatchType, PartnerRoutingMode, PartnerServiceCapability } from '../enums/partner-enums';
3
+ /**
4
+ * One "this kind of incident goes to this partner" statement.
5
+ *
6
+ * The match key must agree with `matchType`: INCIDENT_TYPE needs
7
+ * `incidentTypeId`, INCIDENT_CATEGORY needs `incidentCategoryId`,
8
+ * EMERGENCY_TYPE needs `emergencyType`, ALL needs none. The backend enforces
9
+ * that and blanks the other two, so a form that switches match type must clear
10
+ * the previous key rather than leaving it in the payload.
11
+ */
12
+ export interface PartnerCoverageRuleDto {
13
+ id: number;
14
+ integrationId: number;
15
+ organizationId: number;
16
+ matchType: PartnerCoverageMatchType;
17
+ incidentTypeId: number | null;
18
+ incidentCategoryId: number | null;
19
+ emergencyType: IncidentEmergencyType | null;
20
+ capability: PartnerServiceCapability;
21
+ routingModeOverride: PartnerRoutingMode | null;
22
+ priority: number;
23
+ enabled: boolean;
24
+ notes: string | null;
25
+ createdBy: number | null;
26
+ updatedBy: number | null;
27
+ createdAt: string;
28
+ updatedAt: string;
29
+ }
30
+ export interface CreatePartnerCoverageRuleDto {
31
+ matchType: PartnerCoverageMatchType;
32
+ incidentTypeId?: number;
33
+ incidentCategoryId?: number;
34
+ emergencyType?: IncidentEmergencyType;
35
+ /** Must be a capability the partnership declares. */
36
+ capability: PartnerServiceCapability;
37
+ routingModeOverride?: PartnerRoutingMode;
38
+ priority?: number;
39
+ enabled?: boolean;
40
+ notes?: string;
41
+ }
42
+ export type UpdatePartnerCoverageRuleDto = Partial<CreatePartnerCoverageRuleDto>;
@@ -0,0 +1,126 @@
1
+ import { CountryCode } from '../../country/enums/country-code.enum';
2
+ import { PartnerAdapterOperation, PartnerDispatchFailureReason, PartnerDispatchStatus, PartnerLocationProvider, PartnerProviderCode, PartnerRoutingMode, PartnerServiceCapability } from '../enums/partner-enums';
3
+ /** Where the emergency is, as sent to the partner. */
4
+ export interface PartnerDispatchLocationDto {
5
+ latitude: number;
6
+ longitude: number;
7
+ measuredAt: string;
8
+ provider: PartnerLocationProvider;
9
+ address?: string | null;
10
+ }
11
+ /** Who the partner should call about the person in trouble. */
12
+ export interface PartnerEmergencyContactDto {
13
+ emergencyContactName: string;
14
+ /** E.164 numbers, primary guardian first. */
15
+ phoneNumbers: string[];
16
+ relationship?: string;
17
+ }
18
+ /** The incident facts a dispatch was built from, frozen at routing time. */
19
+ export interface PartnerDispatchIncidentSnapshotDto {
20
+ incidentId: number;
21
+ organizationId: number;
22
+ controlCentreId?: number | null;
23
+ incidentTypeId?: number | null;
24
+ incidentTypeName?: string | null;
25
+ incidentCategoryId?: number | null;
26
+ incidentCategoryName?: string | null;
27
+ emergencyType?: string | null;
28
+ incidentClass?: string | null;
29
+ channel?: string | null;
30
+ priority?: string | null;
31
+ description?: string | null;
32
+ createdAt: string;
33
+ reporterName?: string | null;
34
+ reporterPhoneNumber?: string | null;
35
+ reporterUserId?: number | null;
36
+ location?: PartnerDispatchLocationDto | null;
37
+ address?: string | null;
38
+ }
39
+ /** One outbound call made on a dispatch's behalf, success or failure. */
40
+ export interface PartnerDispatchAttemptDto {
41
+ id: number;
42
+ dispatchId: number;
43
+ attemptNumber: number;
44
+ operation: PartnerAdapterOperation;
45
+ /** Query string already masked by the backend. */
46
+ requestUrl: string;
47
+ httpStatus: number | null;
48
+ success: boolean;
49
+ failureReason: PartnerDispatchFailureReason | null;
50
+ errorCode: string | null;
51
+ errorMessage: string | null;
52
+ durationMs: number;
53
+ responseSnapshot: Record<string, unknown> | null;
54
+ createdAt: string;
55
+ }
56
+ /**
57
+ * One incident's routing to one partnership.
58
+ *
59
+ * `requestPayload` and `responsePayload` are sanitized by the backend before
60
+ * they are stored, so they are safe to render verbatim in a support view.
61
+ */
62
+ export interface PartnerDispatchDto {
63
+ id: number;
64
+ /** Stable reference, safe to quote to the partner or in a support ticket. */
65
+ dispatchReference: string;
66
+ organizationId: number;
67
+ controlCentreId: number | null;
68
+ integrationId: number;
69
+ providerCode: PartnerProviderCode;
70
+ capability: PartnerServiceCapability;
71
+ coverageRuleId: number | null;
72
+ incidentId: number;
73
+ incidentTypeId: number | null;
74
+ incidentCategoryId: number | null;
75
+ routingMode: PartnerRoutingMode;
76
+ status: PartnerDispatchStatus;
77
+ countryCode: CountryCode;
78
+ attemptCount: number;
79
+ maxAttempts: number;
80
+ nextAttemptAt: string | null;
81
+ approvalExpiresAt: string | null;
82
+ approvedByUserId: number | null;
83
+ approvedAt: string | null;
84
+ rejectedByUserId: number | null;
85
+ rejectedAt: string | null;
86
+ cancelledByUserId: number | null;
87
+ cancelledAt: string | null;
88
+ decisionReason: string | null;
89
+ /** The partner's own identifier, e.g. a Rescue.co SOS request id. */
90
+ partnerReference: string | null;
91
+ partnerNumber: string | null;
92
+ partnerStatus: string | null;
93
+ requestPayload: Record<string, unknown> | null;
94
+ responsePayload: Record<string, unknown> | null;
95
+ failureReason: PartnerDispatchFailureReason | null;
96
+ lastErrorCode: string | null;
97
+ lastErrorMessage: string | null;
98
+ incidentSnapshot: PartnerDispatchIncidentSnapshotDto;
99
+ emergencyContact: PartnerEmergencyContactDto | null;
100
+ sentAt: string | null;
101
+ completedAt: string | null;
102
+ createdAt: string;
103
+ updatedAt: string;
104
+ /** Present on the detail endpoint. */
105
+ attempts?: PartnerDispatchAttemptDto[];
106
+ }
107
+ /** Body for approve / reject / cancel. The acting user comes from the session. */
108
+ export interface PartnerDispatchDecisionDto {
109
+ reason?: string;
110
+ }
111
+ /** List filters for the dispatches table. */
112
+ export interface PartnerDispatchQueryParams {
113
+ page?: number;
114
+ limit?: number;
115
+ sortBy?: string;
116
+ sortOrder?: 'ASC' | 'DESC';
117
+ /** Super-Admin only. */
118
+ organizationId?: number;
119
+ incidentId?: number;
120
+ integrationId?: number;
121
+ status?: PartnerDispatchStatus;
122
+ providerCode?: PartnerProviderCode;
123
+ capability?: PartnerServiceCapability;
124
+ routingMode?: PartnerRoutingMode;
125
+ countryCode?: CountryCode;
126
+ }
@@ -0,0 +1,86 @@
1
+ import { CountryCode } from '../../country/enums/country-code.enum';
2
+ import { PartnerIntegrationEnvironment, PartnerIntegrationStatus, PartnerProviderCode, PartnerRoutingMode, PartnerServiceCapability } from '../enums/partner-enums';
3
+ import { PartnerCoverageRuleDto } from './partner-coverage-rule.dto';
4
+ /**
5
+ * Frontend view of an organization's partnership with a third-party service
6
+ * partner.
7
+ *
8
+ * NEVER carries the credential value, and never even the reference: the backend
9
+ * returns `credentialConfigured` instead, so the admin can show "configured" or
10
+ * "not configured" without any part of the secret reaching the browser.
11
+ */
12
+ export interface PartnerIntegrationDto {
13
+ id: number;
14
+ organizationId: number;
15
+ controlCentreId: number | null;
16
+ providerCode: PartnerProviderCode;
17
+ name: string;
18
+ environment: PartnerIntegrationEnvironment;
19
+ baseUrl: string;
20
+ credentialConfigured: boolean;
21
+ configuration: Record<string, unknown>;
22
+ capabilities: PartnerServiceCapability[];
23
+ routingMode: PartnerRoutingMode;
24
+ approvalWindowMinutes: number | null;
25
+ enabled: boolean;
26
+ priority: number;
27
+ countryCode: CountryCode;
28
+ status: PartnerIntegrationStatus;
29
+ partnerContactName: string | null;
30
+ partnerContactPhone: string | null;
31
+ partnerContactEmail: string | null;
32
+ lastHealthCheckAt: string | null;
33
+ lastSuccessAt: string | null;
34
+ lastErrorAt: string | null;
35
+ lastErrorCode: string | null;
36
+ lastErrorMessage: string | null;
37
+ createdBy: number | null;
38
+ updatedBy: number | null;
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ /** Present on the detail endpoint. */
42
+ coverageRules?: PartnerCoverageRuleDto[];
43
+ }
44
+ export interface CreatePartnerIntegrationDto {
45
+ /** Super-Admin only: which tenant the partnership belongs to. */
46
+ organizationId?: number;
47
+ controlCentreId?: number;
48
+ providerCode: PartnerProviderCode;
49
+ name: string;
50
+ environment?: PartnerIntegrationEnvironment;
51
+ /** Defaults to the adapter's base URL for the chosen environment. */
52
+ baseUrl?: string;
53
+ /** A secret NAME/reference - never the credential value. */
54
+ credentialReference: string;
55
+ configuration?: Record<string, unknown>;
56
+ capabilities: PartnerServiceCapability[];
57
+ /** Defaults to MANUAL, so a new partnership never dispatches unattended. */
58
+ routingMode?: PartnerRoutingMode;
59
+ approvalWindowMinutes?: number;
60
+ enabled?: boolean;
61
+ priority?: number;
62
+ countryCode?: CountryCode;
63
+ partnerContactName?: string;
64
+ partnerContactPhone?: string;
65
+ partnerContactEmail?: string;
66
+ }
67
+ /**
68
+ * `providerCode` and `organizationId` are deliberately absent: changing either
69
+ * would repoint an existing dispatch history at a different partner or tenant,
70
+ * so a move is a delete and a create.
71
+ */
72
+ export type UpdatePartnerIntegrationDto = Partial<Omit<CreatePartnerIntegrationDto, 'providerCode' | 'organizationId'>>;
73
+ /** List filters for the partnerships table. */
74
+ export interface PartnerIntegrationQueryParams {
75
+ page?: number;
76
+ limit?: number;
77
+ sortBy?: string;
78
+ sortOrder?: 'ASC' | 'DESC';
79
+ /** Super-Admin only. */
80
+ organizationId?: number;
81
+ providerCode?: PartnerProviderCode;
82
+ environment?: PartnerIntegrationEnvironment;
83
+ routingMode?: PartnerRoutingMode;
84
+ countryCode?: CountryCode;
85
+ enabled?: boolean;
86
+ }
@@ -0,0 +1,53 @@
1
+ import { PartnerIntegrationEnvironment, PartnerProviderCode, PartnerServiceCapability } from '../enums/partner-enums';
2
+ /** A credential a partnership must supply, described by the backend adapter. */
3
+ export interface PartnerProviderCredentialFieldDto {
4
+ key: string;
5
+ label: string;
6
+ description?: string;
7
+ required: boolean;
8
+ /** Always true: a credential is supplied as a secret REFERENCE, never a value. */
9
+ secret: boolean;
10
+ }
11
+ /** A non-secret setting a partnership must (or may) supply for a provider. */
12
+ export interface PartnerProviderConfigFieldDto {
13
+ key: string;
14
+ label: string;
15
+ description?: string;
16
+ required: boolean;
17
+ type: 'string' | 'number' | 'boolean' | 'enum';
18
+ allowedValues?: string[];
19
+ defaultValue?: string | number | boolean;
20
+ maxLength?: number;
21
+ }
22
+ /**
23
+ * What one partner adapter can do, served by `GET /partner-services/providers`.
24
+ *
25
+ * The "add a partner" form is BUILT from these descriptors rather than
26
+ * hard-coded, so the fields the admin asks for can never drift from what the
27
+ * backend adapter actually needs. `available: false` marks a reserved partner
28
+ * that has no adapter yet - show it, but do not let anyone configure it.
29
+ */
30
+ export interface PartnerProviderDescriptorDto {
31
+ providerCode: PartnerProviderCode;
32
+ name: string;
33
+ description: string;
34
+ capabilities: PartnerServiceCapability[];
35
+ defaultBaseUrls: Partial<Record<PartnerIntegrationEnvironment, string>>;
36
+ configFields: PartnerProviderConfigFieldDto[];
37
+ credentialFields: PartnerProviderCredentialFieldDto[];
38
+ supportsHealthCheck: boolean;
39
+ available: boolean;
40
+ }
41
+ /** Result of the admin's "test connection" button. Never creates an emergency. */
42
+ export interface PartnerConnectionTestResultDto {
43
+ integrationId: number;
44
+ status: string;
45
+ success: boolean;
46
+ /** True when the stored credential was accepted, even if health then failed. */
47
+ authenticated: boolean;
48
+ partnerServiceVersion?: string | null;
49
+ latencyMs: number;
50
+ checkedAt: string;
51
+ errorCode?: string | null;
52
+ errorMessage?: string | null;
53
+ }
@@ -0,0 +1,37 @@
1
+ import { IncidentPartnerRoutingStatus, PartnerCoverageMatchType, PartnerDispatchStatus, PartnerIntegrationStatus, PartnerRoutingMode, PartnerServiceCapability } from '../enums/partner-enums';
2
+ /**
3
+ * Human labels for the partner enums.
4
+ *
5
+ * Kept in the shared package rather than in the admin app so every screen that
6
+ * shows a dispatch - the list, the detail drawer, the incident view - names the
7
+ * same state the same way. An operator reading "Waiting for confirmation" in one
8
+ * place and "Pending approval" in another would reasonably assume they were
9
+ * different things.
10
+ */
11
+ export declare const PARTNER_DISPATCH_STATUS_LABELS: Readonly<Record<PartnerDispatchStatus, string>>;
12
+ export declare const INCIDENT_PARTNER_ROUTING_STATUS_LABELS: Readonly<Record<IncidentPartnerRoutingStatus, string>>;
13
+ export declare const PARTNER_ROUTING_MODE_LABELS: Readonly<Record<PartnerRoutingMode, string>>;
14
+ export declare const PARTNER_INTEGRATION_STATUS_LABELS: Readonly<Record<PartnerIntegrationStatus, string>>;
15
+ export declare const PARTNER_CAPABILITY_LABELS: Readonly<Record<PartnerServiceCapability, string>>;
16
+ export declare const PARTNER_COVERAGE_MATCH_TYPE_LABELS: Readonly<Record<PartnerCoverageMatchType, string>>;
17
+ /**
18
+ * Chip family for a dispatch status, matching the admin's existing chip
19
+ * vocabulary: `success` for anything the partner has, `warn` for anything still
20
+ * needing a human, `danger` for a failure, `neutral` for a settled non-event.
21
+ */
22
+ export declare function partnerDispatchStatusTone(status: PartnerDispatchStatus): 'success' | 'warn' | 'danger' | 'neutral';
23
+ /** The same tone mapping for the incident-level rolled-up status. */
24
+ export declare function incidentPartnerRoutingTone(status: IncidentPartnerRoutingStatus): 'success' | 'warn' | 'danger' | 'neutral';
25
+ /**
26
+ * Whether an operator can act on a dispatch, so a table can enable or hide its
27
+ * buttons without duplicating the backend's transition rules.
28
+ *
29
+ * Withdrawing is deliberately impossible once the partner has the emergency:
30
+ * standing an ambulance down is a phone call to the partner, not a button here.
31
+ */
32
+ export declare function partnerDispatchActions(status: PartnerDispatchStatus): {
33
+ canApprove: boolean;
34
+ canReject: boolean;
35
+ canCancel: boolean;
36
+ canResend: boolean;
37
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarion-shared-types",
3
- "version": "1.0.84",
3
+ "version": "1.0.86",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",