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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why an entitlement evaluation produced its tier. Persisted in the incident
|
|
3
|
+
* entitlement snapshot for audit/support and surfaced to the mobile client so it
|
|
4
|
+
* can pick the right subscription banner without a second round trip.
|
|
5
|
+
*/
|
|
6
|
+
export var EntitlementDecisionReason;
|
|
7
|
+
(function (EntitlementDecisionReason) {
|
|
8
|
+
/** An active subscription entitlement covers the requested incident type. */
|
|
9
|
+
EntitlementDecisionReason["ACTIVE_SUBSCRIPTION"] = "ACTIVE_SUBSCRIPTION";
|
|
10
|
+
/** No subscription, but an active premium trial with alerts remaining. */
|
|
11
|
+
EntitlementDecisionReason["ACTIVE_TRIAL"] = "ACTIVE_TRIAL";
|
|
12
|
+
/** The user has never held a subscription or trial for this organization. */
|
|
13
|
+
EntitlementDecisionReason["NO_ENTITLEMENT"] = "NO_ENTITLEMENT";
|
|
14
|
+
/** An entitlement exists but its package does not cover this incident type. */
|
|
15
|
+
EntitlementDecisionReason["INCIDENT_TYPE_NOT_COVERED"] = "INCIDENT_TYPE_NOT_COVERED";
|
|
16
|
+
/** The user's subscription lapsed — drives the "renew" banner on mobile. */
|
|
17
|
+
EntitlementDecisionReason["SUBSCRIPTION_EXPIRED"] = "SUBSCRIPTION_EXPIRED";
|
|
18
|
+
/** The trial period is still open but every trial alert has been used. */
|
|
19
|
+
EntitlementDecisionReason["TRIAL_EXHAUSTED"] = "TRIAL_EXHAUSTED";
|
|
20
|
+
/** The trial window elapsed. */
|
|
21
|
+
EntitlementDecisionReason["TRIAL_EXPIRED"] = "TRIAL_EXPIRED";
|
|
22
|
+
/** The trial was revoked by an operator. */
|
|
23
|
+
EntitlementDecisionReason["TRIAL_REVOKED"] = "TRIAL_REVOKED";
|
|
24
|
+
/** Trials are switched off for this organization/deployment. */
|
|
25
|
+
EntitlementDecisionReason["TRIAL_DISABLED"] = "TRIAL_DISABLED";
|
|
26
|
+
/** Entitlement does not gate this record (e.g. grievance class). */
|
|
27
|
+
EntitlementDecisionReason["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
|
28
|
+
/** Billing could not be reached; the configured fail-open/closed default applied. */
|
|
29
|
+
EntitlementDecisionReason["EVALUATION_UNAVAILABLE"] = "EVALUATION_UNAVAILABLE";
|
|
30
|
+
})(EntitlementDecisionReason || (EntitlementDecisionReason = {}));
|
|
31
|
+
//# 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,MAAM,CAAN,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,KAAzB,yBAAyB,QAuBpC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List filter applied to incident queries.
|
|
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.
|
|
9
|
+
*/
|
|
10
|
+
export var IncidentEntitlementScope;
|
|
11
|
+
(function (IncidentEntitlementScope) {
|
|
12
|
+
IncidentEntitlementScope["ALL"] = "ALL";
|
|
13
|
+
IncidentEntitlementScope["ENTITLED"] = "ENTITLED";
|
|
14
|
+
IncidentEntitlementScope["FREE"] = "FREE";
|
|
15
|
+
})(IncidentEntitlementScope || (IncidentEntitlementScope = {}));
|
|
16
|
+
//# 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,MAAM,CAAN,IAAY,wBAIX;AAJD,WAAY,wBAAwB;IAChC,uCAAW,CAAA;IACX,iDAAqB,CAAA;IACrB,yCAAa,CAAA;AACjB,CAAC,EAJW,wBAAwB,KAAxB,wBAAwB,QAInC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Premium entitlement classification stamped on every incident at creation time.
|
|
3
|
+
*
|
|
4
|
+
* The tier is derived server-side by clarion-billing and is NEVER accepted from a
|
|
5
|
+
* client payload. It drives three behaviours across the platform:
|
|
6
|
+
*
|
|
7
|
+
* - `FREE` incidents are not published to the realtime (live-updates) channel,
|
|
8
|
+
* are not auto-assigned to operators, and are hidden from the primary
|
|
9
|
+
* admin incident list / map / kanban views.
|
|
10
|
+
* - `PREMIUM` and `TRIAL` incidents behave exactly as incidents did before
|
|
11
|
+
* entitlement enforcement (full provider routing + live updates).
|
|
12
|
+
* - `NOT_APPLICABLE` covers everything entitlement does not gate: grievances,
|
|
13
|
+
* incidents created before enforcement shipped, and any incident whose
|
|
14
|
+
* entitlement could not be attributed to a user. It is treated as entitled
|
|
15
|
+
* so historical and non-gated data keeps its existing behaviour.
|
|
16
|
+
*/
|
|
17
|
+
export var IncidentEntitlementTier;
|
|
18
|
+
(function (IncidentEntitlementTier) {
|
|
19
|
+
IncidentEntitlementTier["PREMIUM"] = "PREMIUM";
|
|
20
|
+
IncidentEntitlementTier["TRIAL"] = "TRIAL";
|
|
21
|
+
IncidentEntitlementTier["FREE"] = "FREE";
|
|
22
|
+
IncidentEntitlementTier["NOT_APPLICABLE"] = "NOT_APPLICABLE";
|
|
23
|
+
})(IncidentEntitlementTier || (IncidentEntitlementTier = {}));
|
|
24
|
+
//# 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,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IAC/B,8CAAmB,CAAA;IACnB,0CAAe,CAAA;IACf,wCAAa,CAAA;IACb,4DAAiC,CAAA;AACrC,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** How a premium trial came to exist. */
|
|
2
|
+
export var PremiumTrialSource;
|
|
3
|
+
(function (PremiumTrialSource) {
|
|
4
|
+
/** Created lazily the first time entitlement was evaluated for the user. */
|
|
5
|
+
PremiumTrialSource["AUTO_ENROLL"] = "AUTO_ENROLL";
|
|
6
|
+
/** Granted explicitly by an operator/admin. */
|
|
7
|
+
PremiumTrialSource["MANUAL_GRANT"] = "MANUAL_GRANT";
|
|
8
|
+
})(PremiumTrialSource || (PremiumTrialSource = {}));
|
|
9
|
+
//# 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,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC1B,4EAA4E;IAC5E,iDAA2B,CAAA;IAC3B,+CAA+C;IAC/C,mDAA6B,CAAA;AACjC,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Lifecycle of a user's premium trial within one organization. */
|
|
2
|
+
export var PremiumTrialStatus;
|
|
3
|
+
(function (PremiumTrialStatus) {
|
|
4
|
+
/** Within the trial window with at least one alert remaining. */
|
|
5
|
+
PremiumTrialStatus["ACTIVE"] = "ACTIVE";
|
|
6
|
+
/** Within the trial window but every allotted alert has been used. */
|
|
7
|
+
PremiumTrialStatus["EXHAUSTED"] = "EXHAUSTED";
|
|
8
|
+
/** The trial window elapsed. */
|
|
9
|
+
PremiumTrialStatus["EXPIRED"] = "EXPIRED";
|
|
10
|
+
/** Cancelled by an operator before it ran its course. */
|
|
11
|
+
PremiumTrialStatus["REVOKED"] = "REVOKED";
|
|
12
|
+
/** Superseded because the user took out a paid subscription. */
|
|
13
|
+
PremiumTrialStatus["CONVERTED"] = "CONVERTED";
|
|
14
|
+
})(PremiumTrialStatus || (PremiumTrialStatus = {}));
|
|
15
|
+
//# 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,MAAM,CAAN,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,KAAlB,kBAAkB,QAW7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Enums
|
|
2
|
+
export * from './enums/incident-entitlement-tier.enum';
|
|
3
|
+
export * from './enums/incident-entitlement-scope.enum';
|
|
4
|
+
export * from './enums/entitlement-decision-reason.enum';
|
|
5
|
+
export * from './enums/premium-trial-status.enum';
|
|
6
|
+
export * from './enums/premium-trial-source.enum';
|
|
7
|
+
// Interfaces
|
|
8
|
+
export * from './interfaces/entitlement-evaluation';
|
|
9
|
+
// Constants
|
|
10
|
+
export * from './constants/entitlement-defaults.const';
|
|
11
|
+
// Utilities
|
|
12
|
+
export * from './utils/entitlement.util';
|
|
13
|
+
//# 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,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAElD,aAAa;AACb,cAAc,qCAAqC,CAAC;AAEpD,YAAY;AACZ,cAAc,wCAAwC,CAAC;AAEvD,YAAY;AACZ,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entitlement-evaluation.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/interfaces/entitlement-evaluation.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IncidentEntitlementScope } from '../enums/incident-entitlement-scope.enum';
|
|
2
|
+
import { IncidentEntitlementTier } from '../enums/incident-entitlement-tier.enum';
|
|
3
|
+
import { PremiumTrialStatus } from '../enums/premium-trial-status.enum';
|
|
4
|
+
/**
|
|
5
|
+
* Whether a tier reaches the provider control room.
|
|
6
|
+
*
|
|
7
|
+
* Everything except `FREE` counts as entitled: `NOT_APPLICABLE` covers
|
|
8
|
+
* grievances and pre-enforcement incidents, which must keep behaving exactly as
|
|
9
|
+
* they did before entitlement gating existed.
|
|
10
|
+
*/
|
|
11
|
+
export function isEntitledTier(tier) {
|
|
12
|
+
return tier !== IncidentEntitlementTier.FREE;
|
|
13
|
+
}
|
|
14
|
+
/** Whether an incident was raised by a Free user (no subscription, no trial). */
|
|
15
|
+
export function isFreeUserTier(tier) {
|
|
16
|
+
return tier === IncidentEntitlementTier.FREE;
|
|
17
|
+
}
|
|
18
|
+
/** True while the trial still grants premium behaviour. */
|
|
19
|
+
export function isTrialUsable(status) {
|
|
20
|
+
return status === PremiumTrialStatus.ACTIVE;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parses a client-supplied entitlement scope. Unknown/absent values fall back to
|
|
24
|
+
* `ALL` so an unrecognised query string never silently hides incidents.
|
|
25
|
+
*/
|
|
26
|
+
export function parseIncidentEntitlementScope(value) {
|
|
27
|
+
if (!value)
|
|
28
|
+
return IncidentEntitlementScope.ALL;
|
|
29
|
+
const normalized = value.trim().toUpperCase();
|
|
30
|
+
return Object.values(IncidentEntitlementScope).includes(normalized)
|
|
31
|
+
? normalized
|
|
32
|
+
: IncidentEntitlementScope.ALL;
|
|
33
|
+
}
|
|
34
|
+
/** Whole days remaining until `expiresAt`, floored at zero. */
|
|
35
|
+
export function trialDaysRemaining(expiresAt, now = new Date()) {
|
|
36
|
+
const end = expiresAt instanceof Date ? expiresAt : new Date(expiresAt);
|
|
37
|
+
const ms = end.getTime() - now.getTime();
|
|
38
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
39
|
+
return 0;
|
|
40
|
+
return Math.ceil(ms / (24 * 60 * 60 * 1000));
|
|
41
|
+
}
|
|
42
|
+
//# 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":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAA8C;IACzE,OAAO,IAAI,KAAK,uBAAuB,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,cAAc,CAAC,IAA8C;IACzE,OAAO,IAAI,KAAK,uBAAuB,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,MAA2C;IACrE,OAAO,MAAM,KAAK,kBAAkB,CAAC,MAAM,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CACzC,KAAqB;IAErB,IAAI,CAAC,KAAK;QAAE,OAAO,wBAAwB,CAAC,GAAG,CAAC;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAQ,MAAM,CAAC,MAAM,CAAC,wBAAwB,CAAc,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7E,CAAC,CAAE,UAAuC;QAC1C,CAAC,CAAC,wBAAwB,CAAC,GAAG,CAAC;AACvC,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,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/types/index.d.ts
CHANGED
|
@@ -17,5 +17,7 @@ export * from './modules/notification/index';
|
|
|
17
17
|
export * from './modules/chat/index';
|
|
18
18
|
export * from './modules/country/index';
|
|
19
19
|
export * from './modules/tracking/index';
|
|
20
|
+
export * from './modules/entitlement/index';
|
|
21
|
+
export * from './modules/alert-dispatch/index';
|
|
20
22
|
export * from './modules/common/interfaces/server-message';
|
|
21
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,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;
|
|
@@ -5,6 +5,7 @@ import { Organization } from "../../organization";
|
|
|
5
5
|
import { ResponseUnit } from "../../response-unit";
|
|
6
6
|
import { User } from "../../user";
|
|
7
7
|
import { WebNotification } from "../../web-notification";
|
|
8
|
+
import { IncidentEntitlementScope } from "../../entitlement/enums/incident-entitlement-scope.enum";
|
|
8
9
|
export interface PaginationParams {
|
|
9
10
|
page?: number;
|
|
10
11
|
limit?: number;
|
|
@@ -12,6 +13,15 @@ export interface PaginationParams {
|
|
|
12
13
|
sortBy?: string;
|
|
13
14
|
sortOrder?: 'ASC' | 'DESC';
|
|
14
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Incident list query. Extends the generic pagination contract with the premium
|
|
18
|
+
* entitlement filter: the primary admin views ask for `ENTITLED` so Free-user
|
|
19
|
+
* incidents stay hidden, and the dedicated "Incident List - Free Users" view
|
|
20
|
+
* asks for `FREE`. Omitting it returns everything.
|
|
21
|
+
*/
|
|
22
|
+
export interface IncidentQueryParams extends PaginationParams {
|
|
23
|
+
entitlementScope?: IncidentEntitlementScope;
|
|
24
|
+
}
|
|
15
25
|
export interface PaginatedResponse<T> {
|
|
16
26
|
data: T[];
|
|
17
27
|
meta: {
|
|
@@ -0,0 +1,16 @@
|
|
|
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 declare const PREMIUM_TRIAL_DEFAULTS: {
|
|
7
|
+
/** Alerts a trial user may raise as if they were premium. */
|
|
8
|
+
readonly MAX_INCIDENTS: 2;
|
|
9
|
+
/** Days the trial window stays open from enrolment. */
|
|
10
|
+
readonly 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 declare const ENTITLEMENT_IDEMPOTENCY_HEADER = "x-entitlement-idempotency-key";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why an entitlement evaluation produced its tier. Persisted in the incident
|
|
3
|
+
* entitlement snapshot for audit/support and surfaced to the mobile client so it
|
|
4
|
+
* can pick the right subscription banner without a second round trip.
|
|
5
|
+
*/
|
|
6
|
+
export declare enum EntitlementDecisionReason {
|
|
7
|
+
/** An active subscription entitlement covers the requested incident type. */
|
|
8
|
+
ACTIVE_SUBSCRIPTION = "ACTIVE_SUBSCRIPTION",
|
|
9
|
+
/** No subscription, but an active premium trial with alerts remaining. */
|
|
10
|
+
ACTIVE_TRIAL = "ACTIVE_TRIAL",
|
|
11
|
+
/** The user has never held a subscription or trial for this organization. */
|
|
12
|
+
NO_ENTITLEMENT = "NO_ENTITLEMENT",
|
|
13
|
+
/** An entitlement exists but its package does not cover this incident type. */
|
|
14
|
+
INCIDENT_TYPE_NOT_COVERED = "INCIDENT_TYPE_NOT_COVERED",
|
|
15
|
+
/** The user's subscription lapsed — drives the "renew" banner on mobile. */
|
|
16
|
+
SUBSCRIPTION_EXPIRED = "SUBSCRIPTION_EXPIRED",
|
|
17
|
+
/** The trial period is still open but every trial alert has been used. */
|
|
18
|
+
TRIAL_EXHAUSTED = "TRIAL_EXHAUSTED",
|
|
19
|
+
/** The trial window elapsed. */
|
|
20
|
+
TRIAL_EXPIRED = "TRIAL_EXPIRED",
|
|
21
|
+
/** The trial was revoked by an operator. */
|
|
22
|
+
TRIAL_REVOKED = "TRIAL_REVOKED",
|
|
23
|
+
/** Trials are switched off for this organization/deployment. */
|
|
24
|
+
TRIAL_DISABLED = "TRIAL_DISABLED",
|
|
25
|
+
/** Entitlement does not gate this record (e.g. grievance class). */
|
|
26
|
+
NOT_APPLICABLE = "NOT_APPLICABLE",
|
|
27
|
+
/** Billing could not be reached; the configured fail-open/closed default applied. */
|
|
28
|
+
EVALUATION_UNAVAILABLE = "EVALUATION_UNAVAILABLE"
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List filter applied to incident queries.
|
|
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.
|
|
9
|
+
*/
|
|
10
|
+
export declare enum IncidentEntitlementScope {
|
|
11
|
+
ALL = "ALL",
|
|
12
|
+
ENTITLED = "ENTITLED",
|
|
13
|
+
FREE = "FREE"
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Premium entitlement classification stamped on every incident at creation time.
|
|
3
|
+
*
|
|
4
|
+
* The tier is derived server-side by clarion-billing and is NEVER accepted from a
|
|
5
|
+
* client payload. It drives three behaviours across the platform:
|
|
6
|
+
*
|
|
7
|
+
* - `FREE` incidents are not published to the realtime (live-updates) channel,
|
|
8
|
+
* are not auto-assigned to operators, and are hidden from the primary
|
|
9
|
+
* admin incident list / map / kanban views.
|
|
10
|
+
* - `PREMIUM` and `TRIAL` incidents behave exactly as incidents did before
|
|
11
|
+
* entitlement enforcement (full provider routing + live updates).
|
|
12
|
+
* - `NOT_APPLICABLE` covers everything entitlement does not gate: grievances,
|
|
13
|
+
* incidents created before enforcement shipped, and any incident whose
|
|
14
|
+
* entitlement could not be attributed to a user. It is treated as entitled
|
|
15
|
+
* so historical and non-gated data keeps its existing behaviour.
|
|
16
|
+
*/
|
|
17
|
+
export declare enum IncidentEntitlementTier {
|
|
18
|
+
PREMIUM = "PREMIUM",
|
|
19
|
+
TRIAL = "TRIAL",
|
|
20
|
+
FREE = "FREE",
|
|
21
|
+
NOT_APPLICABLE = "NOT_APPLICABLE"
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** How a premium trial came to exist. */
|
|
2
|
+
export declare enum PremiumTrialSource {
|
|
3
|
+
/** Created lazily the first time entitlement was evaluated for the user. */
|
|
4
|
+
AUTO_ENROLL = "AUTO_ENROLL",
|
|
5
|
+
/** Granted explicitly by an operator/admin. */
|
|
6
|
+
MANUAL_GRANT = "MANUAL_GRANT"
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Lifecycle of a user's premium trial within one organization. */
|
|
2
|
+
export declare enum PremiumTrialStatus {
|
|
3
|
+
/** Within the trial window with at least one alert remaining. */
|
|
4
|
+
ACTIVE = "ACTIVE",
|
|
5
|
+
/** Within the trial window but every allotted alert has been used. */
|
|
6
|
+
EXHAUSTED = "EXHAUSTED",
|
|
7
|
+
/** The trial window elapsed. */
|
|
8
|
+
EXPIRED = "EXPIRED",
|
|
9
|
+
/** Cancelled by an operator before it ran its course. */
|
|
10
|
+
REVOKED = "REVOKED",
|
|
11
|
+
/** Superseded because the user took out a paid subscription. */
|
|
12
|
+
CONVERTED = "CONVERTED"
|
|
13
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './enums/incident-entitlement-tier.enum';
|
|
2
|
+
export * from './enums/incident-entitlement-scope.enum';
|
|
3
|
+
export * from './enums/entitlement-decision-reason.enum';
|
|
4
|
+
export * from './enums/premium-trial-status.enum';
|
|
5
|
+
export * from './enums/premium-trial-source.enum';
|
|
6
|
+
export * from './interfaces/entitlement-evaluation';
|
|
7
|
+
export * from './constants/entitlement-defaults.const';
|
|
8
|
+
export * from './utils/entitlement.util';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { EntitlementDecisionReason } from '../enums/entitlement-decision-reason.enum';
|
|
2
|
+
import { IncidentEntitlementTier } from '../enums/incident-entitlement-tier.enum';
|
|
3
|
+
import { PremiumTrialSource } from '../enums/premium-trial-source.enum';
|
|
4
|
+
import { PremiumTrialStatus } from '../enums/premium-trial-status.enum';
|
|
5
|
+
/** Compact view of the subscription entitlement backing a premium decision. */
|
|
6
|
+
export interface EntitlementSubscriptionSummary {
|
|
7
|
+
subscriptionId?: number | null;
|
|
8
|
+
packageId?: number | null;
|
|
9
|
+
packageName?: string | null;
|
|
10
|
+
/** `EntitlementSourceType` from clarion-billing (primary / member / beneficiary). */
|
|
11
|
+
sourceType?: string | null;
|
|
12
|
+
startsAt?: string | null;
|
|
13
|
+
expiresAt?: string | null;
|
|
14
|
+
/** Incident type ids the package covers. An empty array means "every type". */
|
|
15
|
+
incidentTypeIds?: number[];
|
|
16
|
+
}
|
|
17
|
+
/** Compact view of a user's premium trial within one organization. */
|
|
18
|
+
export interface EntitlementTrialSummary {
|
|
19
|
+
trialId: number;
|
|
20
|
+
status: PremiumTrialStatus;
|
|
21
|
+
source: PremiumTrialSource;
|
|
22
|
+
/** Alerts the trial grants in total (default 2). */
|
|
23
|
+
maxIncidents: number;
|
|
24
|
+
incidentsUsed: number;
|
|
25
|
+
/** Never negative - clamped at zero once the allotment is spent. */
|
|
26
|
+
incidentsRemaining: number;
|
|
27
|
+
startsAt: string;
|
|
28
|
+
expiresAt: string;
|
|
29
|
+
/** Whole days left in the trial window; zero once elapsed. */
|
|
30
|
+
daysRemaining: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The single answer every caller needs about a user's premium standing.
|
|
34
|
+
*
|
|
35
|
+
* Produced by clarion-billing (`POST /billing/entitlements/evaluate` for
|
|
36
|
+
* service-to-service calls, `GET /billing/entitlements/me` for the mobile app)
|
|
37
|
+
* and consumed by clarion-incident to stamp the incident, and by the mobile app
|
|
38
|
+
* to pick its subscription banner.
|
|
39
|
+
*/
|
|
40
|
+
export interface EntitlementEvaluation {
|
|
41
|
+
userId: number;
|
|
42
|
+
organizationId: number;
|
|
43
|
+
tier: IncidentEntitlementTier;
|
|
44
|
+
/** True for PREMIUM/TRIAL/NOT_APPLICABLE - i.e. the alert reaches the provider. */
|
|
45
|
+
canAlertProvider: boolean;
|
|
46
|
+
reason: EntitlementDecisionReason;
|
|
47
|
+
evaluatedAt: string;
|
|
48
|
+
/** Echoes the incident type the decision was scoped to, when one was supplied. */
|
|
49
|
+
incidentTypeId?: number | null;
|
|
50
|
+
/**
|
|
51
|
+
* True when the answer was produced without a live billing decision (the
|
|
52
|
+
* caller's configured fail-open/fail-closed default applied). Never set by
|
|
53
|
+
* billing itself - only by clients that had to degrade.
|
|
54
|
+
*/
|
|
55
|
+
degraded?: boolean;
|
|
56
|
+
/** Present when an ACTIVE subscription entitlement backs the decision. */
|
|
57
|
+
subscription?: EntitlementSubscriptionSummary | null;
|
|
58
|
+
/** Present whenever the user has a trial record, whatever its status. */
|
|
59
|
+
trial?: EntitlementTrialSummary | null;
|
|
60
|
+
/**
|
|
61
|
+
* Present when the user holds no active entitlement but previously had one
|
|
62
|
+
* that lapsed. Drives the mobile "your subscription expired - renew" banner,
|
|
63
|
+
* which must be distinguishable from a never-subscribed free user.
|
|
64
|
+
*/
|
|
65
|
+
expiredSubscription?: EntitlementSubscriptionSummary | null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Audit trail persisted alongside every incident (jsonb). Deliberately a
|
|
69
|
+
* point-in-time copy: re-evaluating later can produce a different answer, and
|
|
70
|
+
* incident history must reflect what was true when the alert was raised.
|
|
71
|
+
*/
|
|
72
|
+
export interface IncidentEntitlementSnapshot {
|
|
73
|
+
tier: IncidentEntitlementTier;
|
|
74
|
+
reason: EntitlementDecisionReason;
|
|
75
|
+
evaluatedAt: string;
|
|
76
|
+
/** The user the decision was made for (creator, or the reporter's system user). */
|
|
77
|
+
evaluatedUserId?: number | null;
|
|
78
|
+
degraded?: boolean;
|
|
79
|
+
subscriptionId?: number | null;
|
|
80
|
+
packageId?: number | null;
|
|
81
|
+
sourceType?: string | null;
|
|
82
|
+
trialId?: number | null;
|
|
83
|
+
/** Alerts left on the trial AFTER this incident consumed one, when applicable. */
|
|
84
|
+
trialIncidentsRemaining?: number | null;
|
|
85
|
+
}
|
|
86
|
+
/** Result of consuming one trial alert; idempotent per (trial, incident). */
|
|
87
|
+
export interface TrialConsumptionResult {
|
|
88
|
+
/** False when the incident had already been counted against the trial. */
|
|
89
|
+
consumed: boolean;
|
|
90
|
+
trial: EntitlementTrialSummary | null;
|
|
91
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IncidentEntitlementScope } from '../enums/incident-entitlement-scope.enum';
|
|
2
|
+
import { IncidentEntitlementTier } from '../enums/incident-entitlement-tier.enum';
|
|
3
|
+
import { PremiumTrialStatus } from '../enums/premium-trial-status.enum';
|
|
4
|
+
/**
|
|
5
|
+
* Whether a tier reaches the provider control room.
|
|
6
|
+
*
|
|
7
|
+
* Everything except `FREE` counts as entitled: `NOT_APPLICABLE` covers
|
|
8
|
+
* grievances and pre-enforcement incidents, which must keep behaving exactly as
|
|
9
|
+
* they did before entitlement gating existed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isEntitledTier(tier?: IncidentEntitlementTier | string | null): boolean;
|
|
12
|
+
/** Whether an incident was raised by a Free user (no subscription, no trial). */
|
|
13
|
+
export declare function isFreeUserTier(tier?: IncidentEntitlementTier | string | null): boolean;
|
|
14
|
+
/** True while the trial still grants premium behaviour. */
|
|
15
|
+
export declare function isTrialUsable(status?: PremiumTrialStatus | string | null): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Parses a client-supplied entitlement scope. Unknown/absent values fall back to
|
|
18
|
+
* `ALL` so an unrecognised query string never silently hides incidents.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseIncidentEntitlementScope(value?: string | null): IncidentEntitlementScope;
|
|
21
|
+
/** Whole days remaining until `expiresAt`, floored at zero. */
|
|
22
|
+
export declare function trialDaysRemaining(expiresAt: Date | string, now?: Date): number;
|
|
@@ -14,6 +14,8 @@ import { IncidentResponseUnitAssignment } from "./incident-response-unit-assignm
|
|
|
14
14
|
import { IncidentType } from "./incident-type";
|
|
15
15
|
import { IncidentReport } from "./incident-report";
|
|
16
16
|
import { IncidentEmergencyType } from "../enums/incident-emergency-type.enum";
|
|
17
|
+
import { IncidentEntitlementSnapshot } from "../../entitlement/interfaces/entitlement-evaluation";
|
|
18
|
+
import { IncidentEntitlementTier } from "../../entitlement/enums/incident-entitlement-tier.enum";
|
|
17
19
|
export interface Incident {
|
|
18
20
|
id?: number;
|
|
19
21
|
appId: IncidentAppId;
|
|
@@ -41,6 +43,25 @@ export interface Incident {
|
|
|
41
43
|
workflowTaskQueueName: IncidentWorkflowTaskQueueName;
|
|
42
44
|
controlCentreId: number;
|
|
43
45
|
organizationId: number;
|
|
46
|
+
/**
|
|
47
|
+
* Premium standing of the reporting user when the alert was raised, decided
|
|
48
|
+
* server-side by clarion-billing. The primary incident list, map and kanban
|
|
49
|
+
* views exclude FREE incidents; the dedicated "Incident List - Free Users"
|
|
50
|
+
* view shows only those.
|
|
51
|
+
*/
|
|
52
|
+
entitlementTier?: IncidentEntitlementTier;
|
|
53
|
+
/** Point-in-time audit of how `entitlementTier` was decided. */
|
|
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;
|
|
44
65
|
createdAt?: string;
|
|
45
66
|
updatedAt?: string;
|
|
46
67
|
category?: IncidentCategory;
|