clarion-shared-types 1.0.80 → 1.0.82
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 +1 -0
- package/dist/cjs/index.js.map +1 -1
- 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/cjs/modules/tracking/index.js +2 -0
- package/dist/cjs/modules/tracking/index.js.map +1 -1
- package/dist/cjs/modules/tracking/interfaces/tracking-operations.dto.js +3 -0
- package/dist/cjs/modules/tracking/interfaces/tracking-operations.dto.js.map +1 -0
- package/dist/cjs/modules/tracking/interfaces/tracking-playback.dto.js +3 -0
- package/dist/cjs/modules/tracking/interfaces/tracking-playback.dto.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- 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/esm/modules/tracking/index.js +2 -0
- package/dist/esm/modules/tracking/index.js.map +1 -1
- package/dist/esm/modules/tracking/interfaces/tracking-operations.dto.js +2 -0
- package/dist/esm/modules/tracking/interfaces/tracking-operations.dto.js.map +1 -0
- package/dist/esm/modules/tracking/interfaces/tracking-playback.dto.js +2 -0
- package/dist/esm/modules/tracking/interfaces/tracking-playback.dto.js.map +1 -0
- package/dist/types/index.d.ts +1 -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 +11 -0
- package/dist/types/modules/tracking/index.d.ts +2 -0
- package/dist/types/modules/tracking/interfaces/tracking-operations.dto.d.ts +124 -0
- package/dist/types/modules/tracking/interfaces/tracking-playback.dto.d.ts +46 -0
- package/package.json +45 -45
package/dist/cjs/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __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);
|
|
37
38
|
// Interfaces
|
|
38
39
|
__exportStar(require("./modules/common/interfaces/server-message"), exports);
|
|
39
40
|
__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;AAE5C,aAAa;AACb,6EAA2D;AAC3D,yEAAuD"}
|
|
@@ -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"}
|
|
@@ -24,4 +24,6 @@ __exportStar(require("./interfaces/tracking-provider-connection.dto"), exports);
|
|
|
24
24
|
__exportStar(require("./interfaces/tracking-device-binding.dto"), exports);
|
|
25
25
|
__exportStar(require("./interfaces/tracking-position.dto"), exports);
|
|
26
26
|
__exportStar(require("./interfaces/tracking-socket-events"), exports);
|
|
27
|
+
__exportStar(require("./interfaces/tracking-operations.dto"), exports);
|
|
28
|
+
__exportStar(require("./interfaces/tracking-playback.dto"), exports);
|
|
27
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/tracking/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,sEAAoD;AACpD,uEAAqD;AACrD,0EAAwD;AACxD,2EAAyD;AAEzD,oBAAoB;AACpB,gFAA8D;AAC9D,2EAAyD;AACzD,qEAAmD;AACnD,sEAAoD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/tracking/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,QAAQ;AACR,sEAAoD;AACpD,uEAAqD;AACrD,0EAAwD;AACxD,2EAAyD;AAEzD,oBAAoB;AACpB,gFAA8D;AAC9D,2EAAyD;AACzD,qEAAmD;AACnD,sEAAoD;AACpD,uEAAqD;AACrD,qEAAmD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking-operations.dto.js","sourceRoot":"","sources":["../../../../../src/modules/tracking/interfaces/tracking-operations.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking-playback.dto.js","sourceRoot":"","sources":["../../../../../src/modules/tracking/interfaces/tracking-playback.dto.ts"],"names":[],"mappings":""}
|
package/dist/esm/index.js
CHANGED
|
@@ -18,6 +18,7 @@ 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';
|
|
21
22
|
// Interfaces
|
|
22
23
|
export * from './modules/common/interfaces/server-message';
|
|
23
24
|
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;AAE5C,aAAa;AACb,cAAc,4CAA4C,CAAC;AAC3D,cAAc,wCAAwC,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"}
|
|
@@ -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"}
|
|
@@ -8,4 +8,6 @@ export * from './interfaces/tracking-provider-connection.dto';
|
|
|
8
8
|
export * from './interfaces/tracking-device-binding.dto';
|
|
9
9
|
export * from './interfaces/tracking-position.dto';
|
|
10
10
|
export * from './interfaces/tracking-socket-events';
|
|
11
|
+
export * from './interfaces/tracking-operations.dto';
|
|
12
|
+
export * from './interfaces/tracking-playback.dto';
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/tracking/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AAEzD,oBAAoB;AACpB,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/tracking/index.ts"],"names":[],"mappings":"AAAA,QAAQ;AACR,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AAEzD,oBAAoB;AACpB,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking-operations.dto.js","sourceRoot":"","sources":["../../../../../src/modules/tracking/interfaces/tracking-operations.dto.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tracking-playback.dto.js","sourceRoot":"","sources":["../../../../../src/modules/tracking/interfaces/tracking-playback.dto.ts"],"names":[],"mappings":""}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -17,5 +17,6 @@ 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';
|
|
20
21
|
export * from './modules/common/interfaces/server-message';
|
|
21
22
|
export * from './modules/common/interfaces/pagination';
|
|
@@ -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,15 @@ 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;
|
|
44
55
|
createdAt?: string;
|
|
45
56
|
updatedAt?: string;
|
|
46
57
|
category?: IncidentCategory;
|
|
@@ -6,3 +6,5 @@ export * from './interfaces/tracking-provider-connection.dto';
|
|
|
6
6
|
export * from './interfaces/tracking-device-binding.dto';
|
|
7
7
|
export * from './interfaces/tracking-position.dto';
|
|
8
8
|
export * from './interfaces/tracking-socket-events';
|
|
9
|
+
export * from './interfaces/tracking-operations.dto';
|
|
10
|
+
export * from './interfaces/tracking-playback.dto';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { TrackingConnectionStatus } from '../enums/tracking-connection-status.enum';
|
|
2
|
+
import { TrackingProviderCode } from '../enums/tracking-provider-code.enum';
|
|
3
|
+
/**
|
|
4
|
+
* Frontend contracts for the tracking operations dashboard + reconciliation.
|
|
5
|
+
* Browser-safe: no secrets, no auth frames, no Node-only types. Shapes mirror
|
|
6
|
+
* clarion-response-tracking's OperationsService / ReconciliationService responses.
|
|
7
|
+
*/
|
|
8
|
+
export interface TrackingConnectionCountsDto {
|
|
9
|
+
total: number;
|
|
10
|
+
connected: number;
|
|
11
|
+
degraded: number;
|
|
12
|
+
authenticationFailed: number;
|
|
13
|
+
error: number;
|
|
14
|
+
disabled: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TrackingUnitCountsDto {
|
|
17
|
+
mappedUnits: number;
|
|
18
|
+
unmappedUnits: number;
|
|
19
|
+
online: number;
|
|
20
|
+
stale: number;
|
|
21
|
+
offline: number;
|
|
22
|
+
}
|
|
23
|
+
export interface TrackingIngestionSummaryDto {
|
|
24
|
+
messagesReceived: number;
|
|
25
|
+
locationsReceived: number;
|
|
26
|
+
locationsNormalized: number;
|
|
27
|
+
locationsRejected: number;
|
|
28
|
+
duplicates: number;
|
|
29
|
+
outOfOrder: number;
|
|
30
|
+
unmappedSeen: number;
|
|
31
|
+
historyWriteFailures: number;
|
|
32
|
+
redisUpdateFailures: number;
|
|
33
|
+
kafkaPublishFailures: number;
|
|
34
|
+
leaseAcquireFailures: number;
|
|
35
|
+
leaseOwnershipChanges: number;
|
|
36
|
+
reconciliationDiscrepancies: number;
|
|
37
|
+
}
|
|
38
|
+
export interface TrackingOperationsSummaryDto {
|
|
39
|
+
connections: TrackingConnectionCountsDto;
|
|
40
|
+
units: TrackingUnitCountsDto;
|
|
41
|
+
ingestion: TrackingIngestionSummaryDto;
|
|
42
|
+
}
|
|
43
|
+
export interface TrackingProviderSummaryDto {
|
|
44
|
+
id: number;
|
|
45
|
+
name: string;
|
|
46
|
+
organizationId: number;
|
|
47
|
+
controlCentreId: number | null;
|
|
48
|
+
providerCode: TrackingProviderCode;
|
|
49
|
+
connectionStatus: TrackingConnectionStatus;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
lastConnectedAt: string | null;
|
|
52
|
+
lastEventAt: string | null;
|
|
53
|
+
lastErrorAt: string | null;
|
|
54
|
+
lastErrorCode: string | null;
|
|
55
|
+
/** Sanitized upstream — never contains credentials. */
|
|
56
|
+
lastErrorMessage: string | null;
|
|
57
|
+
/** Optional counts when the API augments provider rows. */
|
|
58
|
+
mappedUnits?: number;
|
|
59
|
+
unmappedUnits?: number;
|
|
60
|
+
reconnectCount?: number;
|
|
61
|
+
}
|
|
62
|
+
export interface TrackingUnitSummaryDto {
|
|
63
|
+
total: number;
|
|
64
|
+
online: number;
|
|
65
|
+
stale: number;
|
|
66
|
+
offline: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Per-connection readiness indicators, computed on the frontend from a provider
|
|
70
|
+
* connection + its health (or a future backend readiness endpoint).
|
|
71
|
+
*/
|
|
72
|
+
export interface TrackingConfigReadinessDto {
|
|
73
|
+
connectionId: number;
|
|
74
|
+
endpointConfigured: boolean;
|
|
75
|
+
secretReferenceConfigured: boolean;
|
|
76
|
+
normalizationValid: boolean;
|
|
77
|
+
thresholdsValid: boolean;
|
|
78
|
+
enabled: boolean;
|
|
79
|
+
hasSuccessfulConnection: boolean;
|
|
80
|
+
hasRecentEvent: boolean;
|
|
81
|
+
}
|
|
82
|
+
/** Optional per-connection metrics (future endpoint; shape reserved). */
|
|
83
|
+
export interface TrackingProviderMetricsDto {
|
|
84
|
+
connectionId: number;
|
|
85
|
+
connectAttempts?: number;
|
|
86
|
+
successfulConnections?: number;
|
|
87
|
+
authenticationFailures?: number;
|
|
88
|
+
reconnects?: number;
|
|
89
|
+
lastEventAt?: string | null;
|
|
90
|
+
locationsReceived?: number;
|
|
91
|
+
locationsRejected?: number;
|
|
92
|
+
duplicates?: number;
|
|
93
|
+
outOfOrder?: number;
|
|
94
|
+
}
|
|
95
|
+
export type ReconciliationDiscrepancyType = 'missing-in-projection' | 'missing-in-source' | 'control-centre-mismatch' | 'invalid-binding';
|
|
96
|
+
export interface ResponseUnitReconciliationDiscrepancyDto {
|
|
97
|
+
responseUnitId: number;
|
|
98
|
+
type: ReconciliationDiscrepancyType;
|
|
99
|
+
detail?: string;
|
|
100
|
+
}
|
|
101
|
+
export interface ResponseUnitReconciliationResultDto {
|
|
102
|
+
dryRun: boolean;
|
|
103
|
+
organizationId?: number;
|
|
104
|
+
scanned: number;
|
|
105
|
+
created: number;
|
|
106
|
+
updated: number;
|
|
107
|
+
moved: number;
|
|
108
|
+
unchanged: number;
|
|
109
|
+
orphansDetected: number;
|
|
110
|
+
orphansMarkedDeleted: number;
|
|
111
|
+
invalidBindingsSurfaced: number;
|
|
112
|
+
pages: number;
|
|
113
|
+
errors: string[];
|
|
114
|
+
discrepancies?: ResponseUnitReconciliationDiscrepancyDto[];
|
|
115
|
+
}
|
|
116
|
+
export interface ReconcileRequestDto {
|
|
117
|
+
organizationId?: number;
|
|
118
|
+
}
|
|
119
|
+
export interface UnmappedUnitResolutionDto {
|
|
120
|
+
resolved: true;
|
|
121
|
+
}
|
|
122
|
+
export interface ReopenUnmappedUnitDto {
|
|
123
|
+
reopened: true;
|
|
124
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TrackingProviderCode } from '../enums/tracking-provider-code.enum';
|
|
2
|
+
import { TrackingUnitOnlineStatus } from '../enums/tracking-unit-online-status.enum';
|
|
3
|
+
/**
|
|
4
|
+
* Frontend playback contracts for tracking history. A "route" is the processed,
|
|
5
|
+
* client-side representation used by the playback UI — actual provider points
|
|
6
|
+
* plus detected long gaps. Interpolation is visual-only and NEVER sent back to
|
|
7
|
+
* the server / Kafka / Socket.IO.
|
|
8
|
+
*/
|
|
9
|
+
export interface TrackingPlaybackPointDto {
|
|
10
|
+
eventId: string;
|
|
11
|
+
responseUnitId: number;
|
|
12
|
+
/** ISO 8601 UTC (actual provider event time — playback is time-driven). */
|
|
13
|
+
eventTime: string;
|
|
14
|
+
receivedAt?: string;
|
|
15
|
+
latitude: number;
|
|
16
|
+
longitude: number;
|
|
17
|
+
speedKph?: number | null;
|
|
18
|
+
/** Degrees clockwise from north, [0,360); null/undefined ⇒ do not rotate. */
|
|
19
|
+
courseDegrees?: number | null;
|
|
20
|
+
moving?: boolean | null;
|
|
21
|
+
accuracyMetres?: number | null;
|
|
22
|
+
status?: TrackingUnitOnlineStatus;
|
|
23
|
+
providerCode?: TrackingProviderCode;
|
|
24
|
+
/** True when the segment leading INTO this point exceeds the gap threshold. */
|
|
25
|
+
gapBefore?: boolean;
|
|
26
|
+
/** Seconds since the previous point (undefined for the first point). */
|
|
27
|
+
secondsSincePrevious?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TrackingHistoryGapDto {
|
|
30
|
+
/** Index (in the points array) of the point BEFORE the gap. */
|
|
31
|
+
fromIndex: number;
|
|
32
|
+
/** Index of the point AFTER the gap. */
|
|
33
|
+
toIndex: number;
|
|
34
|
+
fromEventTime: string;
|
|
35
|
+
toEventTime: string;
|
|
36
|
+
gapSeconds: number;
|
|
37
|
+
}
|
|
38
|
+
export interface TrackingPlaybackRouteDto {
|
|
39
|
+
responseUnitId: number;
|
|
40
|
+
points: TrackingPlaybackPointDto[];
|
|
41
|
+
gaps: TrackingHistoryGapDto[];
|
|
42
|
+
startEventTime: string | null;
|
|
43
|
+
endEventTime: string | null;
|
|
44
|
+
/** Total actual points (before any downsampling). */
|
|
45
|
+
totalPoints: number;
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "clarion-shared-types",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"main": "dist/cjs/index.js",
|
|
5
|
-
"module": "dist/esm/index.js",
|
|
6
|
-
"types": "dist/types/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./dist/types/index.d.ts",
|
|
10
|
-
"import": "./dist/esm/index.js",
|
|
11
|
-
"require": "./dist/cjs/index.js"
|
|
12
|
-
},
|
|
13
|
-
"./dist/modules/*": {
|
|
14
|
-
"types": "./dist/types/modules/*.d.ts",
|
|
15
|
-
"import": "./dist/esm/modules/*.js",
|
|
16
|
-
"require": "./dist/cjs/modules/*.js"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"files": [
|
|
20
|
-
"dist/**/*"
|
|
21
|
-
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"clean": "rimraf dist dist-test",
|
|
24
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
25
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
26
|
-
"build:types": "tsc -p tsconfig.types.json",
|
|
27
|
-
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm",
|
|
28
|
-
"prepublishOnly": "npm run build",
|
|
29
|
-
"pretest": "rimraf dist-test",
|
|
30
|
-
"test": "tsc -p tsconfig.spec.json && node --test \"dist-test/**/*.spec.js\""
|
|
31
|
-
},
|
|
32
|
-
"keywords": [],
|
|
33
|
-
"author": "vince_lawino",
|
|
34
|
-
"license": "ISC",
|
|
35
|
-
"description": "",
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@types/geojson": "^7946.0.16",
|
|
41
|
-
"@types/node": "^20.11.2",
|
|
42
|
-
"rimraf": "^5.0.5",
|
|
43
|
-
"typescript": "^5.7.3"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "clarion-shared-types",
|
|
3
|
+
"version": "1.0.82",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"import": "./dist/esm/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./dist/modules/*": {
|
|
14
|
+
"types": "./dist/types/modules/*.d.ts",
|
|
15
|
+
"import": "./dist/esm/modules/*.js",
|
|
16
|
+
"require": "./dist/cjs/modules/*.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/**/*"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "rimraf dist dist-test",
|
|
24
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
25
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
26
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
27
|
+
"build": "npm run clean && npm run build:types && npm run build:cjs && npm run build:esm",
|
|
28
|
+
"prepublishOnly": "npm run build",
|
|
29
|
+
"pretest": "rimraf dist-test",
|
|
30
|
+
"test": "tsc -p tsconfig.spec.json && node --test \"dist-test/**/*.spec.js\""
|
|
31
|
+
},
|
|
32
|
+
"keywords": [],
|
|
33
|
+
"author": "vince_lawino",
|
|
34
|
+
"license": "ISC",
|
|
35
|
+
"description": "",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/geojson": "^7946.0.16",
|
|
41
|
+
"@types/node": "^20.11.2",
|
|
42
|
+
"rimraf": "^5.0.5",
|
|
43
|
+
"typescript": "^5.7.3"
|
|
44
|
+
}
|
|
45
|
+
}
|