clarion-shared-types 1.0.81 → 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.
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +27 -0
- package/dist/cjs/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -0
- package/dist/cjs/modules/alert-dispatch/index.js +23 -0
- package/dist/cjs/modules/alert-dispatch/index.js.map +1 -0
- package/dist/cjs/modules/alert-dispatch/interfaces/alert-dispatch.js +3 -0
- package/dist/cjs/modules/alert-dispatch/interfaces/alert-dispatch.js.map +1 -0
- package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js +86 -0
- package/dist/cjs/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -0
- package/dist/cjs/modules/entitlement/constants/entitlement-defaults.const.js +20 -0
- package/dist/cjs/modules/entitlement/constants/entitlement-defaults.const.js.map +1 -0
- package/dist/cjs/modules/entitlement/enums/entitlement-decision-reason.enum.js +34 -0
- package/dist/cjs/modules/entitlement/enums/entitlement-decision-reason.enum.js.map +1 -0
- package/dist/cjs/modules/entitlement/enums/incident-entitlement-scope.enum.js +19 -0
- package/dist/cjs/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -0
- package/dist/cjs/modules/entitlement/enums/incident-entitlement-tier.enum.js +27 -0
- package/dist/cjs/modules/entitlement/enums/incident-entitlement-tier.enum.js.map +1 -0
- package/dist/cjs/modules/entitlement/enums/premium-trial-source.enum.js +12 -0
- package/dist/cjs/modules/entitlement/enums/premium-trial-source.enum.js.map +1 -0
- package/dist/cjs/modules/entitlement/enums/premium-trial-status.enum.js +18 -0
- package/dist/cjs/modules/entitlement/enums/premium-trial-status.enum.js.map +1 -0
- package/dist/cjs/modules/entitlement/index.js +29 -0
- package/dist/cjs/modules/entitlement/index.js.map +1 -0
- package/dist/cjs/modules/entitlement/interfaces/entitlement-evaluation.js +3 -0
- package/dist/cjs/modules/entitlement/interfaces/entitlement-evaluation.js.map +1 -0
- package/dist/cjs/modules/entitlement/utils/entitlement.util.js +49 -0
- package/dist/cjs/modules/entitlement/utils/entitlement.util.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js +24 -0
- package/dist/esm/modules/alert-dispatch/enums/incident-dispatch-scope.enum.js.map +1 -0
- package/dist/esm/modules/alert-dispatch/index.js +7 -0
- package/dist/esm/modules/alert-dispatch/index.js.map +1 -0
- package/dist/esm/modules/alert-dispatch/interfaces/alert-dispatch.js +2 -0
- package/dist/esm/modules/alert-dispatch/interfaces/alert-dispatch.js.map +1 -0
- package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js +78 -0
- package/dist/esm/modules/alert-dispatch/utils/alert-dispatch.util.js.map +1 -0
- package/dist/esm/modules/entitlement/constants/entitlement-defaults.const.js +17 -0
- package/dist/esm/modules/entitlement/constants/entitlement-defaults.const.js.map +1 -0
- package/dist/esm/modules/entitlement/enums/entitlement-decision-reason.enum.js +31 -0
- package/dist/esm/modules/entitlement/enums/entitlement-decision-reason.enum.js.map +1 -0
- package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js +16 -0
- package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -0
- package/dist/esm/modules/entitlement/enums/incident-entitlement-tier.enum.js +24 -0
- package/dist/esm/modules/entitlement/enums/incident-entitlement-tier.enum.js.map +1 -0
- package/dist/esm/modules/entitlement/enums/premium-trial-source.enum.js +9 -0
- package/dist/esm/modules/entitlement/enums/premium-trial-source.enum.js.map +1 -0
- package/dist/esm/modules/entitlement/enums/premium-trial-status.enum.js +15 -0
- package/dist/esm/modules/entitlement/enums/premium-trial-status.enum.js.map +1 -0
- package/dist/esm/modules/entitlement/index.js +13 -0
- package/dist/esm/modules/entitlement/index.js.map +1 -0
- package/dist/esm/modules/entitlement/interfaces/entitlement-evaluation.js +2 -0
- package/dist/esm/modules/entitlement/interfaces/entitlement-evaluation.js.map +1 -0
- package/dist/esm/modules/entitlement/utils/entitlement.util.js +42 -0
- package/dist/esm/modules/entitlement/utils/entitlement.util.js.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/modules/alert-dispatch/enums/incident-dispatch-scope.enum.d.ts +22 -0
- package/dist/types/modules/alert-dispatch/index.d.ts +3 -0
- package/dist/types/modules/alert-dispatch/interfaces/alert-dispatch.d.ts +33 -0
- package/dist/types/modules/alert-dispatch/utils/alert-dispatch.util.d.ts +51 -0
- package/dist/types/modules/common/interfaces/pagination.d.ts +10 -0
- package/dist/types/modules/entitlement/constants/entitlement-defaults.const.d.ts +16 -0
- package/dist/types/modules/entitlement/enums/entitlement-decision-reason.enum.d.ts +29 -0
- package/dist/types/modules/entitlement/enums/incident-entitlement-scope.enum.d.ts +14 -0
- package/dist/types/modules/entitlement/enums/incident-entitlement-tier.enum.d.ts +22 -0
- package/dist/types/modules/entitlement/enums/premium-trial-source.enum.d.ts +7 -0
- package/dist/types/modules/entitlement/enums/premium-trial-status.enum.d.ts +13 -0
- package/dist/types/modules/entitlement/index.d.ts +8 -0
- package/dist/types/modules/entitlement/interfaces/entitlement-evaluation.d.ts +91 -0
- package/dist/types/modules/entitlement/utils/entitlement.util.d.ts +22 -0
- package/dist/types/modules/incident/intefaces/incident.d.ts +21 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -34,6 +34,8 @@ __exportStar(require("./modules/notification/index"), exports);
|
|
|
34
34
|
__exportStar(require("./modules/chat/index"), exports);
|
|
35
35
|
__exportStar(require("./modules/country/index"), exports);
|
|
36
36
|
__exportStar(require("./modules/tracking/index"), exports);
|
|
37
|
+
__exportStar(require("./modules/entitlement/index"), exports);
|
|
38
|
+
__exportStar(require("./modules/alert-dispatch/index"), exports);
|
|
37
39
|
// Interfaces
|
|
38
40
|
__exportStar(require("./modules/common/interfaces/server-message"), exports);
|
|
39
41
|
__exportStar(require("./modules/common/interfaces/pagination"), exports);
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -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;
|
|
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 @@
|
|
|
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;QAAE,OAAO,KAAK,CAAC;IAC3D,OAAO,QAAQ,CAAC,qBAAqB,KAAK,KAAK,CAAC;AACpD,CAAC;AAED,yEAAyE;AACzE,SAAgB,gBAAgB,CAAC,QAA+B;IAC5D,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC,eAAe,KAAK,KAAK,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAC1B,QAA+F;IAE/F,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,QAAQ,CAAC,qBAAqB,KAAK,KAAK,IAAI,CAAC,IAAA,iCAAc,EAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACjG,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,4BAA4B,CAAC,OAA6B;IACtE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IAClE,CAAC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,KAAK,KAAK,CAAC;IAC1D,MAAM,qBAAqB,GAAG,IAAA,iCAAc,EAAC,OAAO,CAAC,IAAI,CAAC;QACtD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC,qBAAqB,KAAK,KAAK,CAAC;IAE9C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC;AACtD,CAAC;AAED,oDAAoD;AACpD,SAAgB,aAAa,CAAC,QAA+B;IACzD,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,qBAAqB,MAAK,KAAK,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,eAAe,MAAK,KAAK,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,SAAgB,0BAA0B,CAAC,KAAqB;IAC5D,IAAI,CAAC,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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ENTITLEMENT_IDEMPOTENCY_HEADER = exports.PREMIUM_TRIAL_DEFAULTS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Platform defaults for the premium trial. A deployment overrides these with
|
|
6
|
+
* `BILLING_TRIAL_*` environment variables, and an organization can override them
|
|
7
|
+
* again through its billing config - so these are the last fallback, not policy.
|
|
8
|
+
*/
|
|
9
|
+
exports.PREMIUM_TRIAL_DEFAULTS = {
|
|
10
|
+
/** Alerts a trial user may raise as if they were premium. */
|
|
11
|
+
MAX_INCIDENTS: 2,
|
|
12
|
+
/** Days the trial window stays open from enrolment. */
|
|
13
|
+
DURATION_DAYS: 30,
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Header used to carry a caller-supplied idempotency key on entitlement
|
|
17
|
+
* mutations. Kept here so producer and consumer cannot drift.
|
|
18
|
+
*/
|
|
19
|
+
exports.ENTITLEMENT_IDEMPOTENCY_HEADER = 'x-entitlement-idempotency-key';
|
|
20
|
+
//# sourceMappingURL=entitlement-defaults.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-defaults.const.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/constants/entitlement-defaults.const.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,sBAAsB,GAAG;IAClC,6DAA6D;IAC7D,aAAa,EAAE,CAAC;IAChB,uDAAuD;IACvD,aAAa,EAAE,EAAE;CACX,CAAC;AAEX;;;GAGG;AACU,QAAA,8BAA8B,GAAG,+BAA+B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntitlementDecisionReason = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Why an entitlement evaluation produced its tier. Persisted in the incident
|
|
6
|
+
* entitlement snapshot for audit/support and surfaced to the mobile client so it
|
|
7
|
+
* can pick the right subscription banner without a second round trip.
|
|
8
|
+
*/
|
|
9
|
+
var EntitlementDecisionReason;
|
|
10
|
+
(function (EntitlementDecisionReason) {
|
|
11
|
+
/** An active subscription entitlement covers the requested incident type. */
|
|
12
|
+
EntitlementDecisionReason["ACTIVE_SUBSCRIPTION"] = "ACTIVE_SUBSCRIPTION";
|
|
13
|
+
/** No subscription, but an active premium trial with alerts remaining. */
|
|
14
|
+
EntitlementDecisionReason["ACTIVE_TRIAL"] = "ACTIVE_TRIAL";
|
|
15
|
+
/** The user has never held a subscription or trial for this organization. */
|
|
16
|
+
EntitlementDecisionReason["NO_ENTITLEMENT"] = "NO_ENTITLEMENT";
|
|
17
|
+
/** An entitlement exists but its package does not cover this incident type. */
|
|
18
|
+
EntitlementDecisionReason["INCIDENT_TYPE_NOT_COVERED"] = "INCIDENT_TYPE_NOT_COVERED";
|
|
19
|
+
/** The user's subscription lapsed — drives the "renew" banner on mobile. */
|
|
20
|
+
EntitlementDecisionReason["SUBSCRIPTION_EXPIRED"] = "SUBSCRIPTION_EXPIRED";
|
|
21
|
+
/** The trial period is still open but every trial alert has been used. */
|
|
22
|
+
EntitlementDecisionReason["TRIAL_EXHAUSTED"] = "TRIAL_EXHAUSTED";
|
|
23
|
+
/** The trial window elapsed. */
|
|
24
|
+
EntitlementDecisionReason["TRIAL_EXPIRED"] = "TRIAL_EXPIRED";
|
|
25
|
+
/** The trial was revoked by an operator. */
|
|
26
|
+
EntitlementDecisionReason["TRIAL_REVOKED"] = "TRIAL_REVOKED";
|
|
27
|
+
/** Trials are switched off for this organization/deployment. */
|
|
28
|
+
EntitlementDecisionReason["TRIAL_DISABLED"] = "TRIAL_DISABLED";
|
|
29
|
+
/** Entitlement does not gate this record (e.g. grievance class). */
|
|
30
|
+
EntitlementDecisionReason["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
|
31
|
+
/** Billing could not be reached; the configured fail-open/closed default applied. */
|
|
32
|
+
EntitlementDecisionReason["EVALUATION_UNAVAILABLE"] = "EVALUATION_UNAVAILABLE";
|
|
33
|
+
})(EntitlementDecisionReason || (exports.EntitlementDecisionReason = EntitlementDecisionReason = {}));
|
|
34
|
+
//# sourceMappingURL=entitlement-decision-reason.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-decision-reason.enum.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/enums/entitlement-decision-reason.enum.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,IAAY,yBAuBX;AAvBD,WAAY,yBAAyB;IACjC,6EAA6E;IAC7E,wEAA2C,CAAA;IAC3C,0EAA0E;IAC1E,0DAA6B,CAAA;IAC7B,6EAA6E;IAC7E,8DAAiC,CAAA;IACjC,+EAA+E;IAC/E,oFAAuD,CAAA;IACvD,4EAA4E;IAC5E,0EAA6C,CAAA;IAC7C,0EAA0E;IAC1E,gEAAmC,CAAA;IACnC,gCAAgC;IAChC,4DAA+B,CAAA;IAC/B,4CAA4C;IAC5C,4DAA+B,CAAA;IAC/B,gEAAgE;IAChE,8DAAiC,CAAA;IACjC,oEAAoE;IACpE,8DAAiC,CAAA;IACjC,qFAAqF;IACrF,8EAAiD,CAAA;AACrD,CAAC,EAvBW,yBAAyB,yCAAzB,yBAAyB,QAuBpC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncidentEntitlementScope = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* List filter applied to incident queries.
|
|
6
|
+
*
|
|
7
|
+
* ALL — no entitlement filter (default; preserves legacy behaviour).
|
|
8
|
+
* ENTITLED — everything except Free-user incidents. Used by the primary admin
|
|
9
|
+
* incident list, map and kanban views.
|
|
10
|
+
* FREE — only Free-user incidents. Backs the "Incident List - Free Users"
|
|
11
|
+
* admin view.
|
|
12
|
+
*/
|
|
13
|
+
var IncidentEntitlementScope;
|
|
14
|
+
(function (IncidentEntitlementScope) {
|
|
15
|
+
IncidentEntitlementScope["ALL"] = "ALL";
|
|
16
|
+
IncidentEntitlementScope["ENTITLED"] = "ENTITLED";
|
|
17
|
+
IncidentEntitlementScope["FREE"] = "FREE";
|
|
18
|
+
})(IncidentEntitlementScope || (exports.IncidentEntitlementScope = IncidentEntitlementScope = {}));
|
|
19
|
+
//# sourceMappingURL=incident-entitlement-scope.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-entitlement-scope.enum.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/enums/incident-entitlement-scope.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,uCAAW,CAAA;IACX,iDAAqB,CAAA;IACrB,yCAAa,CAAA;AACjB,CAAC,EAJW,wBAAwB,wCAAxB,wBAAwB,QAInC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IncidentEntitlementTier = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Premium entitlement classification stamped on every incident at creation time.
|
|
6
|
+
*
|
|
7
|
+
* The tier is derived server-side by clarion-billing and is NEVER accepted from a
|
|
8
|
+
* client payload. It drives three behaviours across the platform:
|
|
9
|
+
*
|
|
10
|
+
* - `FREE` incidents are not published to the realtime (live-updates) channel,
|
|
11
|
+
* are not auto-assigned to operators, and are hidden from the primary
|
|
12
|
+
* admin incident list / map / kanban views.
|
|
13
|
+
* - `PREMIUM` and `TRIAL` incidents behave exactly as incidents did before
|
|
14
|
+
* entitlement enforcement (full provider routing + live updates).
|
|
15
|
+
* - `NOT_APPLICABLE` covers everything entitlement does not gate: grievances,
|
|
16
|
+
* incidents created before enforcement shipped, and any incident whose
|
|
17
|
+
* entitlement could not be attributed to a user. It is treated as entitled
|
|
18
|
+
* so historical and non-gated data keeps its existing behaviour.
|
|
19
|
+
*/
|
|
20
|
+
var IncidentEntitlementTier;
|
|
21
|
+
(function (IncidentEntitlementTier) {
|
|
22
|
+
IncidentEntitlementTier["PREMIUM"] = "PREMIUM";
|
|
23
|
+
IncidentEntitlementTier["TRIAL"] = "TRIAL";
|
|
24
|
+
IncidentEntitlementTier["FREE"] = "FREE";
|
|
25
|
+
IncidentEntitlementTier["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
|
26
|
+
})(IncidentEntitlementTier || (exports.IncidentEntitlementTier = IncidentEntitlementTier = {}));
|
|
27
|
+
//# sourceMappingURL=incident-entitlement-tier.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incident-entitlement-tier.enum.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/enums/incident-entitlement-tier.enum.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,IAAY,uBAKX;AALD,WAAY,uBAAuB;IAC/B,8CAAmB,CAAA;IACnB,0CAAe,CAAA;IACf,wCAAa,CAAA;IACb,4DAAiC,CAAA;AACrC,CAAC,EALW,uBAAuB,uCAAvB,uBAAuB,QAKlC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PremiumTrialSource = void 0;
|
|
4
|
+
/** How a premium trial came to exist. */
|
|
5
|
+
var PremiumTrialSource;
|
|
6
|
+
(function (PremiumTrialSource) {
|
|
7
|
+
/** Created lazily the first time entitlement was evaluated for the user. */
|
|
8
|
+
PremiumTrialSource["AUTO_ENROLL"] = "AUTO_ENROLL";
|
|
9
|
+
/** Granted explicitly by an operator/admin. */
|
|
10
|
+
PremiumTrialSource["MANUAL_GRANT"] = "MANUAL_GRANT";
|
|
11
|
+
})(PremiumTrialSource || (exports.PremiumTrialSource = PremiumTrialSource = {}));
|
|
12
|
+
//# sourceMappingURL=premium-trial-source.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"premium-trial-source.enum.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/enums/premium-trial-source.enum.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,4EAA4E;IAC5E,iDAA2B,CAAA;IAC3B,+CAA+C;IAC/C,mDAA6B,CAAA;AACjC,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PremiumTrialStatus = void 0;
|
|
4
|
+
/** Lifecycle of a user's premium trial within one organization. */
|
|
5
|
+
var PremiumTrialStatus;
|
|
6
|
+
(function (PremiumTrialStatus) {
|
|
7
|
+
/** Within the trial window with at least one alert remaining. */
|
|
8
|
+
PremiumTrialStatus["ACTIVE"] = "ACTIVE";
|
|
9
|
+
/** Within the trial window but every allotted alert has been used. */
|
|
10
|
+
PremiumTrialStatus["EXHAUSTED"] = "EXHAUSTED";
|
|
11
|
+
/** The trial window elapsed. */
|
|
12
|
+
PremiumTrialStatus["EXPIRED"] = "EXPIRED";
|
|
13
|
+
/** Cancelled by an operator before it ran its course. */
|
|
14
|
+
PremiumTrialStatus["REVOKED"] = "REVOKED";
|
|
15
|
+
/** Superseded because the user took out a paid subscription. */
|
|
16
|
+
PremiumTrialStatus["CONVERTED"] = "CONVERTED";
|
|
17
|
+
})(PremiumTrialStatus || (exports.PremiumTrialStatus = PremiumTrialStatus = {}));
|
|
18
|
+
//# sourceMappingURL=premium-trial-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"premium-trial-status.enum.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/enums/premium-trial-status.enum.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC1B,iEAAiE;IACjE,uCAAiB,CAAA;IACjB,sEAAsE;IACtE,6CAAuB,CAAA;IACvB,gCAAgC;IAChC,yCAAmB,CAAA;IACnB,yDAAyD;IACzD,yCAAmB,CAAA;IACnB,gEAAgE;IAChE,6CAAuB,CAAA;AAC3B,CAAC,EAXW,kBAAkB,kCAAlB,kBAAkB,QAW7B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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-entitlement-tier.enum"), exports);
|
|
19
|
+
__exportStar(require("./enums/incident-entitlement-scope.enum"), exports);
|
|
20
|
+
__exportStar(require("./enums/entitlement-decision-reason.enum"), exports);
|
|
21
|
+
__exportStar(require("./enums/premium-trial-status.enum"), exports);
|
|
22
|
+
__exportStar(require("./enums/premium-trial-source.enum"), exports);
|
|
23
|
+
// Interfaces
|
|
24
|
+
__exportStar(require("./interfaces/entitlement-evaluation"), exports);
|
|
25
|
+
// Constants
|
|
26
|
+
__exportStar(require("./constants/entitlement-defaults.const"), exports);
|
|
27
|
+
// Utilities
|
|
28
|
+
__exportStar(require("./utils/entitlement.util"), exports);
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/entitlement/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,yEAAuD;AACvD,0EAAwD;AACxD,2EAAyD;AACzD,oEAAkD;AAClD,oEAAkD;AAElD,aAAa;AACb,sEAAoD;AAEpD,YAAY;AACZ,yEAAuD;AAEvD,YAAY;AACZ,2DAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-evaluation.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/interfaces/entitlement-evaluation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEntitledTier = isEntitledTier;
|
|
4
|
+
exports.isFreeUserTier = isFreeUserTier;
|
|
5
|
+
exports.isTrialUsable = isTrialUsable;
|
|
6
|
+
exports.parseIncidentEntitlementScope = parseIncidentEntitlementScope;
|
|
7
|
+
exports.trialDaysRemaining = trialDaysRemaining;
|
|
8
|
+
const incident_entitlement_scope_enum_1 = require("../enums/incident-entitlement-scope.enum");
|
|
9
|
+
const incident_entitlement_tier_enum_1 = require("../enums/incident-entitlement-tier.enum");
|
|
10
|
+
const premium_trial_status_enum_1 = require("../enums/premium-trial-status.enum");
|
|
11
|
+
/**
|
|
12
|
+
* Whether a tier reaches the provider control room.
|
|
13
|
+
*
|
|
14
|
+
* Everything except `FREE` counts as entitled: `NOT_APPLICABLE` covers
|
|
15
|
+
* grievances and pre-enforcement incidents, which must keep behaving exactly as
|
|
16
|
+
* they did before entitlement gating existed.
|
|
17
|
+
*/
|
|
18
|
+
function isEntitledTier(tier) {
|
|
19
|
+
return tier !== incident_entitlement_tier_enum_1.IncidentEntitlementTier.FREE;
|
|
20
|
+
}
|
|
21
|
+
/** Whether an incident was raised by a Free user (no subscription, no trial). */
|
|
22
|
+
function isFreeUserTier(tier) {
|
|
23
|
+
return tier === incident_entitlement_tier_enum_1.IncidentEntitlementTier.FREE;
|
|
24
|
+
}
|
|
25
|
+
/** True while the trial still grants premium behaviour. */
|
|
26
|
+
function isTrialUsable(status) {
|
|
27
|
+
return status === premium_trial_status_enum_1.PremiumTrialStatus.ACTIVE;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Parses a client-supplied entitlement scope. Unknown/absent values fall back to
|
|
31
|
+
* `ALL` so an unrecognised query string never silently hides incidents.
|
|
32
|
+
*/
|
|
33
|
+
function parseIncidentEntitlementScope(value) {
|
|
34
|
+
if (!value)
|
|
35
|
+
return incident_entitlement_scope_enum_1.IncidentEntitlementScope.ALL;
|
|
36
|
+
const normalized = value.trim().toUpperCase();
|
|
37
|
+
return Object.values(incident_entitlement_scope_enum_1.IncidentEntitlementScope).includes(normalized)
|
|
38
|
+
? normalized
|
|
39
|
+
: incident_entitlement_scope_enum_1.IncidentEntitlementScope.ALL;
|
|
40
|
+
}
|
|
41
|
+
/** Whole days remaining until `expiresAt`, floored at zero. */
|
|
42
|
+
function trialDaysRemaining(expiresAt, now = new Date()) {
|
|
43
|
+
const end = expiresAt instanceof Date ? expiresAt : new Date(expiresAt);
|
|
44
|
+
const ms = end.getTime() - now.getTime();
|
|
45
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
46
|
+
return 0;
|
|
47
|
+
return Math.ceil(ms / (24 * 60 * 60 * 1000));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=entitlement.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement.util.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/utils/entitlement.util.ts"],"names":[],"mappings":";;AAWA,wCAEC;AAGD,wCAEC;AAGD,sCAEC;AAMD,sEAQC;AAGD,gDAKC;AA7CD,8FAAoF;AACpF,4FAAkF;AAClF,kFAAwE;AAExE;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAA8C;IACzE,OAAO,IAAI,KAAK,wDAAuB,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,iFAAiF;AACjF,SAAgB,cAAc,CAAC,IAA8C;IACzE,OAAO,IAAI,KAAK,wDAAuB,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,2DAA2D;AAC3D,SAAgB,aAAa,CAAC,MAA2C;IACrE,OAAO,MAAM,KAAK,8CAAkB,CAAC,MAAM,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CACzC,KAAqB;IAErB,IAAI,CAAC,KAAK;QAAE,OAAO,0DAAwB,CAAC,GAAG,CAAC;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAQ,MAAM,CAAC,MAAM,CAAC,0DAAwB,CAAc,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7E,CAAC,CAAE,UAAuC;QAC1C,CAAC,CAAC,0DAAwB,CAAC,GAAG,CAAC;AACvC,CAAC;AAED,+DAA+D;AAC/D,SAAgB,kBAAkB,CAAC,SAAwB,EAAE,MAAY,IAAI,IAAI,EAAE;IAC/E,MAAM,GAAG,GAAG,SAAS,YAAY,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -18,6 +18,8 @@ export * from './modules/notification/index';
|
|
|
18
18
|
export * from './modules/chat/index';
|
|
19
19
|
export * from './modules/country/index';
|
|
20
20
|
export * from './modules/tracking/index';
|
|
21
|
+
export * from './modules/entitlement/index';
|
|
22
|
+
export * from './modules/alert-dispatch/index';
|
|
21
23
|
// Interfaces
|
|
22
24
|
export * from './modules/common/interfaces/server-message';
|
|
23
25
|
export * from './modules/common/interfaces/pagination';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -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;
|
|
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 @@
|
|
|
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 @@
|
|
|
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,OAAO,QAAQ,CAAC,qBAAqB,KAAK,KAAK,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AACjG,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,4BAA4B,CAAC,OAA6B;IACtE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,KAAK,KAAK,CAAC;IAE1C,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,OAAO,EAAE,qBAAqB,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC;IAClE,CAAC;IAED,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,KAAK,KAAK,CAAC;IAC1D,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC;QACtD,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,OAAO,CAAC,qBAAqB,KAAK,KAAK,CAAC;IAE9C,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,CAAC;AACtD,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,QAA+B;IACzD,OAAO,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,qBAAqB,MAAK,KAAK,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,eAAe,MAAK,KAAK,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CAAC,KAAqB;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,qBAAqB,CAAC,GAAG,CAAC;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAQ,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAc,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC1E,CAAC,CAAE,UAAoC;QACvC,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform defaults for the premium trial. A deployment overrides these with
|
|
3
|
+
* `BILLING_TRIAL_*` environment variables, and an organization can override them
|
|
4
|
+
* again through its billing config - so these are the last fallback, not policy.
|
|
5
|
+
*/
|
|
6
|
+
export const PREMIUM_TRIAL_DEFAULTS = {
|
|
7
|
+
/** Alerts a trial user may raise as if they were premium. */
|
|
8
|
+
MAX_INCIDENTS: 2,
|
|
9
|
+
/** Days the trial window stays open from enrolment. */
|
|
10
|
+
DURATION_DAYS: 30,
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Header used to carry a caller-supplied idempotency key on entitlement
|
|
14
|
+
* mutations. Kept here so producer and consumer cannot drift.
|
|
15
|
+
*/
|
|
16
|
+
export const ENTITLEMENT_IDEMPOTENCY_HEADER = 'x-entitlement-idempotency-key';
|
|
17
|
+
//# sourceMappingURL=entitlement-defaults.const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-defaults.const.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/constants/entitlement-defaults.const.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAClC,6DAA6D;IAC7D,aAAa,EAAE,CAAC;IAChB,uDAAuD;IACvD,aAAa,EAAE,EAAE;CACX,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,+BAA+B,CAAC"}
|