clarion-shared-types 1.0.82 → 1.0.83

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 (27) 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 +27 -0
  4. package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -0
  5. package/dist/cjs/modules/alert-dispatch/index.js +23 -0
  6. package/dist/cjs/modules/alert-dispatch/index.js.map +1 -0
  7. package/dist/cjs/modules/alert-dispatch/interfaces/alert-dispatch.js +3 -0
  8. package/dist/cjs/modules/alert-dispatch/interfaces/alert-dispatch.js.map +1 -0
  9. package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js +86 -0
  10. package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -0
  11. package/dist/esm/index.js +1 -0
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +24 -0
  14. package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -0
  15. package/dist/esm/modules/alert-dispatch/index.js +7 -0
  16. package/dist/esm/modules/alert-dispatch/index.js.map +1 -0
  17. package/dist/esm/modules/alert-dispatch/interfaces/alert-dispatch.js +2 -0
  18. package/dist/esm/modules/alert-dispatch/interfaces/alert-dispatch.js.map +1 -0
  19. package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js +78 -0
  20. package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -0
  21. package/dist/types/index.d.ts +1 -0
  22. package/dist/types/modules/alert-dispatch/enums/incident-dispatch-scope.enum.d.ts +22 -0
  23. package/dist/types/modules/alert-dispatch/index.d.ts +3 -0
  24. package/dist/types/modules/alert-dispatch/interfaces/alert-dispatch.d.ts +33 -0
  25. package/dist/types/modules/alert-dispatch/utils/alert-dispatch.util.d.ts +51 -0
  26. package/dist/types/modules/incident/intefaces/incident.d.ts +10 -0
  27. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -35,6 +35,7 @@ __exportStar(require("./modules/chat/index"), exports);
35
35
  __exportStar(require("./modules/country/index"), exports);
36
36
  __exportStar(require("./modules/tracking/index"), exports);
37
37
  __exportStar(require("./modules/entitlement/index"), exports);
38
+ __exportStar(require("./modules/alert-dispatch/index"), exports);
38
39
  // Interfaces
39
40
  __exportStar(require("./modules/common/interfaces/server-message"), exports);
40
41
  __exportStar(require("./modules/common/interfaces/pagination"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,8DAA4C;AAE5C,aAAa;AACb,6EAA2D;AAC3D,yEAAuD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,8DAA4C;AAC5C,iEAA+C;AAE/C,aAAa;AACb,6EAA2D;AAC3D,yEAAuD"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IncidentDispatchScope = void 0;
4
+ /**
5
+ * List filter applied to incident queries on the *dispatch* dimension - i.e.
6
+ * whether the reporter asked for the service provider to be alerted at all.
7
+ *
8
+ * ALL - no dispatch filter (default; preserves legacy behaviour).
9
+ * DISPATCHED - only incidents the provider was asked to receive. Used by the
10
+ * primary admin incident list, map and kanban views.
11
+ * SUPPRESSED - only incidents the reporter explicitly withheld from the
12
+ * provider. Backs the "Incident List - Marked Ignore" admin
13
+ * view.
14
+ *
15
+ * Deliberately separate from {@link IncidentEntitlementScope}: entitlement is a
16
+ * billing fact about the reporter, dispatch is a choice the reporter made on
17
+ * this one alert. The two compose - the control room asks for
18
+ * `ENTITLED` + `DISPATCHED`, "Marked Ignore" asks for `ENTITLED` + `SUPPRESSED`,
19
+ * and "Free Users" asks for `FREE` on the entitlement dimension alone.
20
+ */
21
+ var IncidentDispatchScope;
22
+ (function (IncidentDispatchScope) {
23
+ IncidentDispatchScope["ALL"] = "ALL";
24
+ IncidentDispatchScope["DISPATCHED"] = "DISPATCHED";
25
+ IncidentDispatchScope["SUPPRESSED"] = "SUPPRESSED";
26
+ })(IncidentDispatchScope || (exports.IncidentDispatchScope = IncidentDispatchScope = {}));
27
+ //# sourceMappingURL=incident-dispatch-scope.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incident-dispatch-scope.enum.js","sourceRoot":"","sources":["../../../../../src/modules/alert-dispatch/enums/incident-dispatch-scope.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,oCAAW,CAAA;IACX,kDAAyB,CAAA;IACzB,kDAAyB,CAAA;AAC7B,CAAC,EAJW,qBAAqB,qCAArB,qBAAqB,QAIhC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Enums
18
+ __exportStar(require("./enums/incident-dispatch-scope.enum"), exports);
19
+ // Interfaces
20
+ __exportStar(require("./interfaces/alert-dispatch"), exports);
21
+ // Utilities
22
+ __exportStar(require("./utils/alert-dispatch.util"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-dispatch/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,uEAAqD;AAErD,aAAa;AACb,8DAA4C;AAE5C,YAAY;AACZ,8DAA4C"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=alert-dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dispatch.js","sourceRoot":"","sources":["../../../../../src/modules/alert-dispatch/interfaces/alert-dispatch.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.reachesControlRoom = reachesControlRoom;
4
+ exports.reachesGuardians = reachesGuardians;
5
+ exports.isMarkedIgnore = isMarkedIgnore;
6
+ exports.resolveIncidentAlertDispatch = resolveIncidentAlertDispatch;
7
+ exports.reachesNobody = reachesNobody;
8
+ exports.parseIncidentDispatchScope = parseIncidentDispatchScope;
9
+ const entitlement_util_1 = require("../../entitlement/utils/entitlement.util");
10
+ const incident_dispatch_scope_enum_1 = require("../enums/incident-dispatch-scope.enum");
11
+ /**
12
+ * Whether an incident reaches the provider control room - live map, live list,
13
+ * kanban, operator assignment and operator notifications.
14
+ *
15
+ * Two independent reasons keep an alert out, and this is the single place both
16
+ * are expressed so no consumer can honour one and forget the other:
17
+ *
18
+ * 1. the reporter is a Free user, so the provider was never entitled to it;
19
+ * 2. the reporter explicitly unchecked the provider option ("Marked Ignore").
20
+ *
21
+ * A missing flag counts as dispatched: incidents written before this feature
22
+ * existed, and every operator-created record, keep their original behaviour.
23
+ */
24
+ function reachesControlRoom(incident) {
25
+ if (!incident)
26
+ return true;
27
+ if ((0, entitlement_util_1.isFreeUserTier)(incident.entitlementTier))
28
+ return false;
29
+ return incident.notifyServiceProvider !== false;
30
+ }
31
+ /** Whether the reporter's guardians should be pulled in and notified. */
32
+ function reachesGuardians(incident) {
33
+ return !incident || incident.notifyGuardians !== false;
34
+ }
35
+ /**
36
+ * Whether the reporter deliberately withheld this alert from the provider, as
37
+ * opposed to never having been entitled to send it. Only the former belongs in
38
+ * the "Marked Ignore" admin list; a Free user's alert belongs in
39
+ * "Incident List - Free Users".
40
+ */
41
+ function isMarkedIgnore(incident) {
42
+ if (!incident)
43
+ return false;
44
+ return incident.notifyServiceProvider === false && !(0, entitlement_util_1.isFreeUserTier)(incident.entitlementTier);
45
+ }
46
+ /**
47
+ * Applies dispatch policy to what the client asked for.
48
+ *
49
+ * The client's checkboxes are an intent, never the decision: a Free user's
50
+ * provider option is unchecked and read-only in the app, and this is what makes
51
+ * that true even for a caller that ignores the UI. Anything the client omits
52
+ * defaults to "notify", so existing callers (web admin, older app builds) are
53
+ * unaffected.
54
+ *
55
+ * Returns resolved flags only - it deliberately does not reject the
56
+ * both-off combination, so callers can decide whether that is a validation
57
+ * error (the SOS path) or simply nobody to notify.
58
+ */
59
+ function resolveIncidentAlertDispatch(request) {
60
+ const applies = request.applies !== false;
61
+ if (!applies) {
62
+ return { notifyServiceProvider: true, notifyGuardians: true };
63
+ }
64
+ const notifyGuardians = request.notifyGuardians !== false;
65
+ const notifyServiceProvider = (0, entitlement_util_1.isFreeUserTier)(request.tier)
66
+ ? false
67
+ : request.notifyServiceProvider !== false;
68
+ return { notifyServiceProvider, notifyGuardians };
69
+ }
70
+ /** True when an alert would reach nobody at all. */
71
+ function reachesNobody(dispatch) {
72
+ return (dispatch === null || dispatch === void 0 ? void 0 : dispatch.notifyServiceProvider) === false && (dispatch === null || dispatch === void 0 ? void 0 : dispatch.notifyGuardians) === false;
73
+ }
74
+ /**
75
+ * Parses a client-supplied dispatch scope. Unknown/absent values fall back to
76
+ * `ALL` so an unrecognised query string never silently hides incidents.
77
+ */
78
+ function parseIncidentDispatchScope(value) {
79
+ if (!value)
80
+ return incident_dispatch_scope_enum_1.IncidentDispatchScope.ALL;
81
+ const normalized = value.trim().toUpperCase();
82
+ return Object.values(incident_dispatch_scope_enum_1.IncidentDispatchScope).includes(normalized)
83
+ ? normalized
84
+ : incident_dispatch_scope_enum_1.IncidentDispatchScope.ALL;
85
+ }
86
+ //# sourceMappingURL=alert-dispatch.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dispatch.util.js","sourceRoot":"","sources":["../../../../../src/modules/alert-dispatch/utils/alert-dispatch.util.ts"],"names":[],"mappings":";;AAkBA,gDAMC;AAGD,4CAEC;AAQD,wCAKC;AAeD,oEAaC;AAGD,sCAEC;AAMD,gEAMC;AAtFD,+EAA0E;AAC1E,wFAA8E;AAG9E;;;;;;;;;;;;GAYG;AACH,SAAgB,kBAAkB,CAC9B,QAA+F;IAE/F,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,IAAA,iCAAc,EAAC,QAAQ,CAAC,eAAe,CAAC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AAC,KAAK;QAAE,OAAO,oDAAqB,CAAC,GAAG,CAAC;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAQ,MAAM,CAAC,MAAM,CAAC,oDAAqB,CAAc,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC1E,CAAC,CAAE,UAAoC;QACvC,CAAC,CAAC,oDAAqB,CAAC,GAAG,CAAC;AACpC,CAAC"}
package/dist/esm/index.js CHANGED
@@ -19,6 +19,7 @@ export * from './modules/chat/index';
19
19
  export * from './modules/country/index';
20
20
  export * from './modules/tracking/index';
21
21
  export * from './modules/entitlement/index';
22
+ export * from './modules/alert-dispatch/index';
22
23
  // Interfaces
23
24
  export * from './modules/common/interfaces/server-message';
24
25
  export * from './modules/common/interfaces/pagination';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAE5C,aAAa;AACb,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAE/C,aAAa;AACb,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * List filter applied to incident queries on the *dispatch* dimension - i.e.
3
+ * whether the reporter asked for the service provider to be alerted at all.
4
+ *
5
+ * ALL - no dispatch filter (default; preserves legacy behaviour).
6
+ * DISPATCHED - only incidents the provider was asked to receive. Used by the
7
+ * primary admin incident list, map and kanban views.
8
+ * SUPPRESSED - only incidents the reporter explicitly withheld from the
9
+ * provider. Backs the "Incident List - Marked Ignore" admin
10
+ * view.
11
+ *
12
+ * Deliberately separate from {@link IncidentEntitlementScope}: entitlement is a
13
+ * billing fact about the reporter, dispatch is a choice the reporter made on
14
+ * this one alert. The two compose - the control room asks for
15
+ * `ENTITLED` + `DISPATCHED`, "Marked Ignore" asks for `ENTITLED` + `SUPPRESSED`,
16
+ * and "Free Users" asks for `FREE` on the entitlement dimension alone.
17
+ */
18
+ export var IncidentDispatchScope;
19
+ (function (IncidentDispatchScope) {
20
+ IncidentDispatchScope["ALL"] = "ALL";
21
+ IncidentDispatchScope["DISPATCHED"] = "DISPATCHED";
22
+ IncidentDispatchScope["SUPPRESSED"] = "SUPPRESSED";
23
+ })(IncidentDispatchScope || (IncidentDispatchScope = {}));
24
+ //# sourceMappingURL=incident-dispatch-scope.enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incident-dispatch-scope.enum.js","sourceRoot":"","sources":["../../../../../src/modules/alert-dispatch/enums/incident-dispatch-scope.enum.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAN,IAAY,qBAIX;AAJD,WAAY,qBAAqB;IAC7B,oCAAW,CAAA;IACX,kDAAyB,CAAA;IACzB,kDAAyB,CAAA;AAC7B,CAAC,EAJW,qBAAqB,KAArB,qBAAqB,QAIhC"}
@@ -0,0 +1,7 @@
1
+ // Enums
2
+ export * from './enums/incident-dispatch-scope.enum';
3
+ // Interfaces
4
+ export * from './interfaces/alert-dispatch';
5
+ // Utilities
6
+ export * from './utils/alert-dispatch.util';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/alert-dispatch/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,sCAAsC,CAAC;AAErD,aAAa;AACb,cAAc,6BAA6B,CAAC;AAE5C,YAAY;AACZ,cAAc,6BAA6B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=alert-dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dispatch.js","sourceRoot":"","sources":["../../../../../src/modules/alert-dispatch/interfaces/alert-dispatch.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ import { isFreeUserTier } from '../../entitlement/utils/entitlement.util';
2
+ import { IncidentDispatchScope } from '../enums/incident-dispatch-scope.enum';
3
+ /**
4
+ * Whether an incident reaches the provider control room - live map, live list,
5
+ * kanban, operator assignment and operator notifications.
6
+ *
7
+ * Two independent reasons keep an alert out, and this is the single place both
8
+ * are expressed so no consumer can honour one and forget the other:
9
+ *
10
+ * 1. the reporter is a Free user, so the provider was never entitled to it;
11
+ * 2. the reporter explicitly unchecked the provider option ("Marked Ignore").
12
+ *
13
+ * A missing flag counts as dispatched: incidents written before this feature
14
+ * existed, and every operator-created record, keep their original behaviour.
15
+ */
16
+ export function reachesControlRoom(incident) {
17
+ if (!incident)
18
+ return true;
19
+ if (isFreeUserTier(incident.entitlementTier))
20
+ return false;
21
+ return incident.notifyServiceProvider !== false;
22
+ }
23
+ /** Whether the reporter's guardians should be pulled in and notified. */
24
+ export function reachesGuardians(incident) {
25
+ return !incident || incident.notifyGuardians !== false;
26
+ }
27
+ /**
28
+ * Whether the reporter deliberately withheld this alert from the provider, as
29
+ * opposed to never having been entitled to send it. Only the former belongs in
30
+ * the "Marked Ignore" admin list; a Free user's alert belongs in
31
+ * "Incident List - Free Users".
32
+ */
33
+ export function isMarkedIgnore(incident) {
34
+ if (!incident)
35
+ return false;
36
+ return incident.notifyServiceProvider === false && !isFreeUserTier(incident.entitlementTier);
37
+ }
38
+ /**
39
+ * Applies dispatch policy to what the client asked for.
40
+ *
41
+ * The client's checkboxes are an intent, never the decision: a Free user's
42
+ * provider option is unchecked and read-only in the app, and this is what makes
43
+ * that true even for a caller that ignores the UI. Anything the client omits
44
+ * defaults to "notify", so existing callers (web admin, older app builds) are
45
+ * unaffected.
46
+ *
47
+ * Returns resolved flags only - it deliberately does not reject the
48
+ * both-off combination, so callers can decide whether that is a validation
49
+ * error (the SOS path) or simply nobody to notify.
50
+ */
51
+ export function resolveIncidentAlertDispatch(request) {
52
+ const applies = request.applies !== false;
53
+ if (!applies) {
54
+ return { notifyServiceProvider: true, notifyGuardians: true };
55
+ }
56
+ const notifyGuardians = request.notifyGuardians !== false;
57
+ const notifyServiceProvider = isFreeUserTier(request.tier)
58
+ ? false
59
+ : request.notifyServiceProvider !== false;
60
+ return { notifyServiceProvider, notifyGuardians };
61
+ }
62
+ /** True when an alert would reach nobody at all. */
63
+ export function reachesNobody(dispatch) {
64
+ return (dispatch === null || dispatch === void 0 ? void 0 : dispatch.notifyServiceProvider) === false && (dispatch === null || dispatch === void 0 ? void 0 : dispatch.notifyGuardians) === false;
65
+ }
66
+ /**
67
+ * Parses a client-supplied dispatch scope. Unknown/absent values fall back to
68
+ * `ALL` so an unrecognised query string never silently hides incidents.
69
+ */
70
+ export function parseIncidentDispatchScope(value) {
71
+ if (!value)
72
+ return IncidentDispatchScope.ALL;
73
+ const normalized = value.trim().toUpperCase();
74
+ return Object.values(IncidentDispatchScope).includes(normalized)
75
+ ? normalized
76
+ : IncidentDispatchScope.ALL;
77
+ }
78
+ //# sourceMappingURL=alert-dispatch.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alert-dispatch.util.js","sourceRoot":"","sources":["../../../../../src/modules/alert-dispatch/utils/alert-dispatch.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAG9E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAC9B,QAA+F;IAE/F,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3D,OAAO,QAAQ,CAAC,qBAAqB,KAAK,KAAK,CAAC;AACpD,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,gBAAgB,CAAC,QAA+B;IAC5D,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,eAAe,KAAK,KAAK,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC1B,QAA+F;IAE/F,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OA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18
  export * from './modules/country/index';
19
19
  export * from './modules/tracking/index';
20
20
  export * from './modules/entitlement/index';
21
+ export * from './modules/alert-dispatch/index';
21
22
  export * from './modules/common/interfaces/server-message';
22
23
  export * from './modules/common/interfaces/pagination';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * List filter applied to incident queries on the *dispatch* dimension - i.e.
3
+ * whether the reporter asked for the service provider to be alerted at all.
4
+ *
5
+ * ALL - no dispatch filter (default; preserves legacy behaviour).
6
+ * DISPATCHED - only incidents the provider was asked to receive. Used by the
7
+ * primary admin incident list, map and kanban views.
8
+ * SUPPRESSED - only incidents the reporter explicitly withheld from the
9
+ * provider. Backs the "Incident List - Marked Ignore" admin
10
+ * view.
11
+ *
12
+ * Deliberately separate from {@link IncidentEntitlementScope}: entitlement is a
13
+ * billing fact about the reporter, dispatch is a choice the reporter made on
14
+ * this one alert. The two compose - the control room asks for
15
+ * `ENTITLED` + `DISPATCHED`, "Marked Ignore" asks for `ENTITLED` + `SUPPRESSED`,
16
+ * and "Free Users" asks for `FREE` on the entitlement dimension alone.
17
+ */
18
+ export declare enum IncidentDispatchScope {
19
+ ALL = "ALL",
20
+ DISPATCHED = "DISPATCHED",
21
+ SUPPRESSED = "SUPPRESSED"
22
+ }
@@ -0,0 +1,3 @@
1
+ export * from './enums/incident-dispatch-scope.enum';
2
+ export * from './interfaces/alert-dispatch';
3
+ export * from './utils/alert-dispatch.util';
@@ -0,0 +1,33 @@
1
+ import { IncidentEntitlementTier } from '../../entitlement/enums/incident-entitlement-tier.enum';
2
+ /**
3
+ * Who an incident's alert was actually dispatched to.
4
+ *
5
+ * Both flags are resolved server-side at creation and then stored on the
6
+ * incident, so every downstream consumer (realtime publisher, notification
7
+ * service, admin lists, the mobile confirmation dialog) reads one recorded fact
8
+ * rather than re-deriving policy. `undefined` means "not recorded" and is
9
+ * always treated as `true`, which is what every incident written before this
10
+ * existed implicitly did.
11
+ */
12
+ export interface IncidentAlertDispatch {
13
+ /**
14
+ * False when the alert must not reach the provider control room: the
15
+ * reporter unchecked the option, or they are a Free user who never had it.
16
+ */
17
+ notifyServiceProvider?: boolean;
18
+ /**
19
+ * False when the reporter's guardians must not be pulled into the incident
20
+ * chat or notified about the alert.
21
+ */
22
+ notifyGuardians?: boolean;
23
+ }
24
+ /** The inputs {@link resolveIncidentAlertDispatch} decides from. */
25
+ export interface AlertDispatchRequest extends IncidentAlertDispatch {
26
+ /** Entitlement tier already decided for this incident. */
27
+ tier?: IncidentEntitlementTier | string | null;
28
+ /**
29
+ * False for records that predate or sit outside the SOS flow (grievances,
30
+ * operator-created incidents), which keep both channels on.
31
+ */
32
+ applies?: boolean;
33
+ }
@@ -0,0 +1,51 @@
1
+ import { IncidentEntitlementTier } from '../../entitlement/enums/incident-entitlement-tier.enum';
2
+ import { IncidentDispatchScope } from '../enums/incident-dispatch-scope.enum';
3
+ import { AlertDispatchRequest, IncidentAlertDispatch } from '../interfaces/alert-dispatch';
4
+ /**
5
+ * Whether an incident reaches the provider control room - live map, live list,
6
+ * kanban, operator assignment and operator notifications.
7
+ *
8
+ * Two independent reasons keep an alert out, and this is the single place both
9
+ * are expressed so no consumer can honour one and forget the other:
10
+ *
11
+ * 1. the reporter is a Free user, so the provider was never entitled to it;
12
+ * 2. the reporter explicitly unchecked the provider option ("Marked Ignore").
13
+ *
14
+ * A missing flag counts as dispatched: incidents written before this feature
15
+ * existed, and every operator-created record, keep their original behaviour.
16
+ */
17
+ export declare function reachesControlRoom(incident: IncidentAlertDispatch & {
18
+ entitlementTier?: IncidentEntitlementTier | string | null;
19
+ }): boolean;
20
+ /** Whether the reporter's guardians should be pulled in and notified. */
21
+ export declare function reachesGuardians(incident: IncidentAlertDispatch): boolean;
22
+ /**
23
+ * Whether the reporter deliberately withheld this alert from the provider, as
24
+ * opposed to never having been entitled to send it. Only the former belongs in
25
+ * the "Marked Ignore" admin list; a Free user's alert belongs in
26
+ * "Incident List - Free Users".
27
+ */
28
+ export declare function isMarkedIgnore(incident: IncidentAlertDispatch & {
29
+ entitlementTier?: IncidentEntitlementTier | string | null;
30
+ }): boolean;
31
+ /**
32
+ * Applies dispatch policy to what the client asked for.
33
+ *
34
+ * The client's checkboxes are an intent, never the decision: a Free user's
35
+ * provider option is unchecked and read-only in the app, and this is what makes
36
+ * that true even for a caller that ignores the UI. Anything the client omits
37
+ * defaults to "notify", so existing callers (web admin, older app builds) are
38
+ * unaffected.
39
+ *
40
+ * Returns resolved flags only - it deliberately does not reject the
41
+ * both-off combination, so callers can decide whether that is a validation
42
+ * error (the SOS path) or simply nobody to notify.
43
+ */
44
+ export declare function resolveIncidentAlertDispatch(request: AlertDispatchRequest): Required<IncidentAlertDispatch>;
45
+ /** True when an alert would reach nobody at all. */
46
+ export declare function reachesNobody(dispatch: IncidentAlertDispatch): boolean;
47
+ /**
48
+ * Parses a client-supplied dispatch scope. Unknown/absent values fall back to
49
+ * `ALL` so an unrecognised query string never silently hides incidents.
50
+ */
51
+ export declare function parseIncidentDispatchScope(value?: string | null): IncidentDispatchScope;
@@ -52,6 +52,16 @@ export interface Incident {
52
52
  entitlementTier?: IncidentEntitlementTier;
53
53
  /** Point-in-time audit of how `entitlementTier` was decided. */
54
54
  entitlementSnapshot?: IncidentEntitlementSnapshot | null;
55
+ /**
56
+ * Who the reporter asked to be alerted, resolved against their entitlement
57
+ * at creation. `false` on the provider flag withholds the incident from the
58
+ * control room exactly as a FREE tier does, and lands it in the
59
+ * "Incident List - Marked Ignore" view instead; `false` on the guardian flag
60
+ * kept guardians out of the incident chat and its notifications. Absent on
61
+ * incidents raised before the options existed, which notified both.
62
+ */
63
+ notifyServiceProvider?: boolean;
64
+ notifyGuardians?: boolean;
55
65
  createdAt?: string;
56
66
  updatedAt?: string;
57
67
  category?: IncidentCategory;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarion-shared-types",
3
- "version": "1.0.82",
3
+ "version": "1.0.83",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",