grm-shared-library 1.1.191 → 1.1.193

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/cjs/index.js +2 -0
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/modules/entitlement/constants/entitlement-defaults.const.js +20 -0
  4. package/dist/cjs/modules/entitlement/constants/entitlement-defaults.const.js.map +1 -0
  5. package/dist/cjs/modules/entitlement/dtos/consume-trial-alert.dto.js +53 -0
  6. package/dist/cjs/modules/entitlement/dtos/consume-trial-alert.dto.js.map +1 -0
  7. package/dist/cjs/modules/entitlement/dtos/evaluate-entitlement.dto.js +55 -0
  8. package/dist/cjs/modules/entitlement/dtos/evaluate-entitlement.dto.js.map +1 -0
  9. package/dist/cjs/modules/entitlement/dtos/grant-premium-trial.dto.js +57 -0
  10. package/dist/cjs/modules/entitlement/dtos/grant-premium-trial.dto.js.map +1 -0
  11. package/dist/cjs/modules/entitlement/dtos/revoke-premium-trial.dto.js +26 -0
  12. package/dist/cjs/modules/entitlement/dtos/revoke-premium-trial.dto.js.map +1 -0
  13. package/dist/cjs/modules/entitlement/enums/entitlement-decision-reason.enum.js +34 -0
  14. package/dist/cjs/modules/entitlement/enums/entitlement-decision-reason.enum.js.map +1 -0
  15. package/dist/cjs/modules/entitlement/enums/incident-entitlement-scope.enum.js +19 -0
  16. package/dist/cjs/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -0
  17. package/dist/cjs/modules/entitlement/enums/incident-entitlement-tier.enum.js +27 -0
  18. package/dist/cjs/modules/entitlement/enums/incident-entitlement-tier.enum.js.map +1 -0
  19. package/dist/cjs/modules/entitlement/enums/premium-trial-source.enum.js +12 -0
  20. package/dist/cjs/modules/entitlement/enums/premium-trial-source.enum.js.map +1 -0
  21. package/dist/cjs/modules/entitlement/enums/premium-trial-status.enum.js +18 -0
  22. package/dist/cjs/modules/entitlement/enums/premium-trial-status.enum.js.map +1 -0
  23. package/dist/cjs/modules/entitlement/index.js +34 -0
  24. package/dist/cjs/modules/entitlement/index.js.map +1 -0
  25. package/dist/cjs/modules/entitlement/interfaces/entitlement-evaluation.js +3 -0
  26. package/dist/cjs/modules/entitlement/interfaces/entitlement-evaluation.js.map +1 -0
  27. package/dist/cjs/modules/entitlement/utils/entitlement.util.js +49 -0
  28. package/dist/cjs/modules/entitlement/utils/entitlement.util.js.map +1 -0
  29. package/dist/cjs/modules/system-user/constants/system-user.const.js +31 -0
  30. package/dist/cjs/modules/system-user/constants/system-user.const.js.map +1 -0
  31. package/dist/cjs/modules/system-user/index.js +27 -0
  32. package/dist/cjs/modules/system-user/index.js.map +1 -0
  33. package/dist/cjs/modules/system-user/interfaces/system-user-env-source.js +3 -0
  34. package/dist/cjs/modules/system-user/interfaces/system-user-env-source.js.map +1 -0
  35. package/dist/cjs/modules/system-user/services/system-user.service.js +60 -0
  36. package/dist/cjs/modules/system-user/services/system-user.service.js.map +1 -0
  37. package/dist/cjs/modules/system-user/system-user.module.js +33 -0
  38. package/dist/cjs/modules/system-user/system-user.module.js.map +1 -0
  39. package/dist/cjs/modules/system-user/utils/system-user.util.js +57 -0
  40. package/dist/cjs/modules/system-user/utils/system-user.util.js.map +1 -0
  41. package/dist/esm/index.js +2 -0
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/modules/entitlement/constants/entitlement-defaults.const.js +17 -0
  44. package/dist/esm/modules/entitlement/constants/entitlement-defaults.const.js.map +1 -0
  45. package/dist/esm/modules/entitlement/dtos/consume-trial-alert.dto.js +49 -0
  46. package/dist/esm/modules/entitlement/dtos/consume-trial-alert.dto.js.map +1 -0
  47. package/dist/esm/modules/entitlement/dtos/evaluate-entitlement.dto.js +51 -0
  48. package/dist/esm/modules/entitlement/dtos/evaluate-entitlement.dto.js.map +1 -0
  49. package/dist/esm/modules/entitlement/dtos/grant-premium-trial.dto.js +53 -0
  50. package/dist/esm/modules/entitlement/dtos/grant-premium-trial.dto.js.map +1 -0
  51. package/dist/esm/modules/entitlement/dtos/revoke-premium-trial.dto.js +22 -0
  52. package/dist/esm/modules/entitlement/dtos/revoke-premium-trial.dto.js.map +1 -0
  53. package/dist/esm/modules/entitlement/enums/entitlement-decision-reason.enum.js +31 -0
  54. package/dist/esm/modules/entitlement/enums/entitlement-decision-reason.enum.js.map +1 -0
  55. package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js +16 -0
  56. package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -0
  57. package/dist/esm/modules/entitlement/enums/incident-entitlement-tier.enum.js +24 -0
  58. package/dist/esm/modules/entitlement/enums/incident-entitlement-tier.enum.js.map +1 -0
  59. package/dist/esm/modules/entitlement/enums/premium-trial-source.enum.js +9 -0
  60. package/dist/esm/modules/entitlement/enums/premium-trial-source.enum.js.map +1 -0
  61. package/dist/esm/modules/entitlement/enums/premium-trial-status.enum.js +15 -0
  62. package/dist/esm/modules/entitlement/enums/premium-trial-status.enum.js.map +1 -0
  63. package/dist/esm/modules/entitlement/index.js +18 -0
  64. package/dist/esm/modules/entitlement/index.js.map +1 -0
  65. package/dist/esm/modules/entitlement/interfaces/entitlement-evaluation.js +2 -0
  66. package/dist/esm/modules/entitlement/interfaces/entitlement-evaluation.js.map +1 -0
  67. package/dist/esm/modules/entitlement/utils/entitlement.util.js +42 -0
  68. package/dist/esm/modules/entitlement/utils/entitlement.util.js.map +1 -0
  69. package/dist/esm/modules/system-user/constants/system-user.const.js +28 -0
  70. package/dist/esm/modules/system-user/constants/system-user.const.js.map +1 -0
  71. package/dist/esm/modules/system-user/index.js +11 -0
  72. package/dist/esm/modules/system-user/index.js.map +1 -0
  73. package/dist/esm/modules/system-user/interfaces/system-user-env-source.js +2 -0
  74. package/dist/esm/modules/system-user/interfaces/system-user-env-source.js.map +1 -0
  75. package/dist/esm/modules/system-user/services/system-user.service.js +57 -0
  76. package/dist/esm/modules/system-user/services/system-user.service.js.map +1 -0
  77. package/dist/esm/modules/system-user/system-user.module.js +30 -0
  78. package/dist/esm/modules/system-user/system-user.module.js.map +1 -0
  79. package/dist/esm/modules/system-user/utils/system-user.util.js +53 -0
  80. package/dist/esm/modules/system-user/utils/system-user.util.js.map +1 -0
  81. package/dist/types/index.d.ts +2 -0
  82. package/dist/types/interfaces/pagination.d.ts +10 -0
  83. package/dist/types/modules/entitlement/constants/entitlement-defaults.const.d.ts +16 -0
  84. package/dist/types/modules/entitlement/dtos/consume-trial-alert.dto.d.ts +11 -0
  85. package/dist/types/modules/entitlement/dtos/evaluate-entitlement.dto.d.ts +11 -0
  86. package/dist/types/modules/entitlement/dtos/grant-premium-trial.dto.d.ts +8 -0
  87. package/dist/types/modules/entitlement/dtos/revoke-premium-trial.dto.d.ts +4 -0
  88. package/dist/types/modules/entitlement/enums/entitlement-decision-reason.enum.d.ts +29 -0
  89. package/dist/types/modules/entitlement/enums/incident-entitlement-scope.enum.d.ts +14 -0
  90. package/dist/types/modules/entitlement/enums/incident-entitlement-tier.enum.d.ts +22 -0
  91. package/dist/types/modules/entitlement/enums/premium-trial-source.enum.d.ts +7 -0
  92. package/dist/types/modules/entitlement/enums/premium-trial-status.enum.d.ts +13 -0
  93. package/dist/types/modules/entitlement/index.d.ts +12 -0
  94. package/dist/types/modules/entitlement/interfaces/entitlement-evaluation.d.ts +91 -0
  95. package/dist/types/modules/entitlement/utils/entitlement.util.d.ts +22 -0
  96. package/dist/types/modules/incident/intefaces/incident.d.ts +11 -0
  97. package/dist/types/modules/system-user/constants/system-user.const.d.ts +24 -0
  98. package/dist/types/modules/system-user/index.d.ts +5 -0
  99. package/dist/types/modules/system-user/interfaces/system-user-env-source.d.ts +10 -0
  100. package/dist/types/modules/system-user/services/system-user.service.d.ts +26 -0
  101. package/dist/types/modules/system-user/system-user.module.d.ts +13 -0
  102. package/dist/types/modules/system-user/utils/system-user.util.d.ts +41 -0
  103. package/package.json +5 -3
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var SystemUserService_1;
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.SystemUserService = void 0;
14
+ const common_1 = require("@nestjs/common");
15
+ const config_1 = require("@nestjs/config");
16
+ const system_user_const_1 = require("../constants/system-user.const");
17
+ const system_user_util_1 = require("../utils/system-user.util");
18
+ /**
19
+ * Single source of truth for the platform system user id inside a service.
20
+ *
21
+ * Resolution happens once, on module init, so a mis-set `SYSTEM_USER_ID`
22
+ * fails the pod's startup probe instead of surfacing later as records stamped
23
+ * with a user id that clarion-authentication cannot resolve.
24
+ *
25
+ * @example
26
+ * constructor(private readonly systemUser: SystemUserService) {}
27
+ * ...
28
+ * const actorId = userContext?.userId ?? this.systemUser.id;
29
+ */
30
+ let SystemUserService = SystemUserService_1 = class SystemUserService {
31
+ constructor(configService) {
32
+ this.configService = configService;
33
+ this.logger = new common_1.Logger(SystemUserService_1.name);
34
+ this.resolvedId = null;
35
+ }
36
+ onModuleInit() {
37
+ this.resolvedId = (0, system_user_util_1.resolveSystemUserId)(this.configService, {
38
+ onLegacyKeyUsed: (key) => this.logger.warn(`Resolved the system user id from deprecated env key "${key}". ` +
39
+ `Set ${system_user_const_1.SYSTEM_USER_ID_ENV_KEY} instead — legacy keys will be removed.`),
40
+ });
41
+ this.logger.log(`System user id resolved to ${this.resolvedId}`);
42
+ }
43
+ /**
44
+ * The system user id. Throws if read before module init completed, which
45
+ * only happens if a provider resolves it inside its own constructor.
46
+ */
47
+ get id() {
48
+ if (this.resolvedId === null) {
49
+ // Resolve on demand so constructor-time reads still work.
50
+ this.resolvedId = (0, system_user_util_1.resolveSystemUserId)(this.configService);
51
+ }
52
+ return this.resolvedId;
53
+ }
54
+ };
55
+ exports.SystemUserService = SystemUserService;
56
+ exports.SystemUserService = SystemUserService = SystemUserService_1 = __decorate([
57
+ (0, common_1.Injectable)(),
58
+ __metadata("design:paramtypes", [config_1.ConfigService])
59
+ ], SystemUserService);
60
+ //# sourceMappingURL=system-user.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-user.service.js","sourceRoot":"","sources":["../../../../../src/modules/system-user/services/system-user.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAkE;AAClE,2CAA+C;AAC/C,sEAAwE;AACxE,gEAAgE;AAEhE;;;;;;;;;;;GAWG;AAEI,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAI1B,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAHxC,WAAM,GAAG,IAAI,eAAM,CAAC,mBAAiB,CAAC,IAAI,CAAC,CAAC;QACrD,eAAU,GAAkB,IAAI,CAAC;IAEoB,CAAC;IAE9D,YAAY;QACR,IAAI,CAAC,UAAU,GAAG,IAAA,sCAAmB,EAAC,IAAI,CAAC,aAAa,EAAE;YACtD,eAAe,EAAE,CAAC,GAAG,EAAE,EAAE,CACrB,IAAI,CAAC,MAAM,CAAC,IAAI,CACZ,wDAAwD,GAAG,KAAK;gBAChE,OAAO,0CAAsB,yCAAyC,CACzE;SACR,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACH,IAAI,EAAE;QACF,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;YAC3B,0DAA0D;YAC1D,IAAI,CAAC,UAAU,GAAG,IAAA,sCAAmB,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ,CAAA;AA5BY,8CAAiB;4BAAjB,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAKmC,sBAAa;GAJhD,iBAAiB,CA4B7B"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.SystemUserModule = void 0;
10
+ const common_1 = require("@nestjs/common");
11
+ const system_user_service_1 = require("./services/system-user.service");
12
+ /**
13
+ * Global module exposing {@link SystemUserService} to every provider in the
14
+ * host application. Import once in the service's root `AppModule`:
15
+ *
16
+ * @example
17
+ * @Module({ imports: [ConfigModule.forRoot({ ... }), SystemUserModule] })
18
+ * export class AppModule {}
19
+ *
20
+ * Requires `ConfigModule` to be global (the convention across clarion
21
+ * services) or otherwise available where this module is imported.
22
+ */
23
+ let SystemUserModule = class SystemUserModule {
24
+ };
25
+ exports.SystemUserModule = SystemUserModule;
26
+ exports.SystemUserModule = SystemUserModule = __decorate([
27
+ (0, common_1.Global)(),
28
+ (0, common_1.Module)({
29
+ providers: [system_user_service_1.SystemUserService],
30
+ exports: [system_user_service_1.SystemUserService],
31
+ })
32
+ ], SystemUserModule);
33
+ //# sourceMappingURL=system-user.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-user.module.js","sourceRoot":"","sources":["../../../../src/modules/system-user/system-user.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAgD;AAChD,wEAAmE;AAEnE;;;;;;;;;;GAUG;AAMI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAI,CAAA;AAApB,4CAAgB;2BAAhB,gBAAgB;IAL5B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACJ,SAAS,EAAE,CAAC,uCAAiB,CAAC;QAC9B,OAAO,EAAE,CAAC,uCAAiB,CAAC;KAC/B,CAAC;GACW,gBAAgB,CAAI"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseSystemUserId = parseSystemUserId;
4
+ exports.resolveSystemUserId = resolveSystemUserId;
5
+ const system_user_const_1 = require("../constants/system-user.const");
6
+ /**
7
+ * Parses a raw environment value into a usable user id.
8
+ *
9
+ * Returns `null` for anything that is not a positive integer — including
10
+ * `'0'`, `'-1'`, `'abc'` and the empty string — so that a typo'd ConfigMap
11
+ * entry surfaces as a clear failure rather than silently stamping user `0`
12
+ * onto production records.
13
+ */
14
+ function parseSystemUserId(raw) {
15
+ if (raw === null || raw === undefined) {
16
+ return null;
17
+ }
18
+ const text = String(raw).trim();
19
+ if (!text || !/^\d+$/.test(text)) {
20
+ return null;
21
+ }
22
+ const parsed = Number(text);
23
+ return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
24
+ }
25
+ /**
26
+ * Resolves the platform system user id from the environment.
27
+ *
28
+ * Precedence: {@link SYSTEM_USER_ID_ENV_KEY} → each legacy key in order →
29
+ * `options.fallback`. Throws when nothing resolves and no fallback is given,
30
+ * which is the intended behaviour at startup: a service that stamps records
31
+ * with the system user should refuse to boot rather than write a wrong id.
32
+ *
33
+ * @example
34
+ * // In a Nest provider that already injects ConfigService:
35
+ * this.systemUserId = resolveSystemUserId(this.configService);
36
+ */
37
+ function resolveSystemUserId(source, options = {}) {
38
+ const { legacyKeys = system_user_const_1.LEGACY_SYSTEM_USER_ID_ENV_KEYS, fallback, onLegacyKeyUsed } = options;
39
+ const canonical = parseSystemUserId(source.get(system_user_const_1.SYSTEM_USER_ID_ENV_KEY));
40
+ if (canonical !== null) {
41
+ return canonical;
42
+ }
43
+ for (const key of legacyKeys) {
44
+ const legacy = parseSystemUserId(source.get(key));
45
+ if (legacy !== null) {
46
+ onLegacyKeyUsed === null || onLegacyKeyUsed === void 0 ? void 0 : onLegacyKeyUsed(key);
47
+ return legacy;
48
+ }
49
+ }
50
+ if (fallback !== undefined) {
51
+ return fallback;
52
+ }
53
+ throw new Error(`${system_user_const_1.SYSTEM_USER_ID_ENV_KEY} is not set to a positive integer. ` +
54
+ `Set it to the id of the platform system user in clarion-authentication ` +
55
+ `(checked legacy keys: ${legacyKeys.length ? legacyKeys.join(', ') : 'none'}).`);
56
+ }
57
+ //# sourceMappingURL=system-user.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-user.util.js","sourceRoot":"","sources":["../../../../../src/modules/system-user/utils/system-user.util.ts"],"names":[],"mappings":";;AA8BA,8CAYC;AAcD,kDA4BC;AAnFD,sEAAwG;AAqBxG;;;;;;;GAOG;AACH,SAAgB,iBAAiB,CAAC,GAAY;IAC1C,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,mBAAmB,CAC/B,MAA2B,EAC3B,UAAsC,EAAE;IAExC,MAAM,EAAE,UAAU,GAAG,kDAA8B,EAAE,QAAQ,EAAE,eAAe,EAAE,GAAG,OAAO,CAAC;IAE3F,MAAM,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,0CAAsB,CAAC,CAAC,CAAC;IACxE,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClB,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAG,GAAG,CAAC,CAAC;YACvB,OAAO,MAAM,CAAC;QAClB,CAAC;IACL,CAAC;IAED,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,MAAM,IAAI,KAAK,CACX,GAAG,0CAAsB,qCAAqC;QAC9D,yEAAyE;QACzE,yBAAyB,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAClF,CAAC;AACN,CAAC"}
package/dist/esm/index.js CHANGED
@@ -20,6 +20,8 @@ export * from './modules/chat/index';
20
20
  export * from './modules/country/index';
21
21
  export * from './modules/phone/index';
22
22
  export * from './modules/tracking/index';
23
+ export * from './modules/entitlement/index';
24
+ export * from './modules/system-user/index';
23
25
  // Interfaces
24
26
  export * from './interfaces/server-message';
25
27
  export * from './interfaces/i-request-with-user';
@@ -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,uBAAuB,CAAC;AACtC,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,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,YAAY;AACZ,cAAc,0BAA0B,CAAC;AAEzC,QAAQ;AACR,cAAc,eAAe,CAAC;AAE9B,YAAY;AACZ,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uDAAuD,CAAC;AAEtE,aAAa;AACb,cAAc,oBAAoB,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,uBAAuB,CAAC;AACtC,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,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAE5C,aAAa;AACb,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AAExC,YAAY;AACZ,cAAc,0BAA0B,CAAC;AAEzC,QAAQ;AACR,cAAc,eAAe,CAAC;AAE9B,YAAY;AACZ,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uDAAuD,CAAC;AAEtE,aAAa;AACb,cAAc,oBAAoB,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,49 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
11
+ import { IsInt, IsOptional, IsPositive } from 'class-validator';
12
+ import { Type } from 'class-transformer';
13
+ /**
14
+ * Records that one trial alert was spent. `incidentId` is the idempotency key:
15
+ * replaying the same incident never double-counts, so the caller can retry
16
+ * freely after a transient failure.
17
+ */
18
+ export class ConsumeTrialAlertDto {
19
+ }
20
+ __decorate([
21
+ ApiProperty({ description: 'User the trial belongs to', example: 42 }),
22
+ Type(() => Number),
23
+ IsInt(),
24
+ IsPositive(),
25
+ __metadata("design:type", Number)
26
+ ], ConsumeTrialAlertDto.prototype, "userId", void 0);
27
+ __decorate([
28
+ ApiProperty({ description: 'Organization the trial is scoped to', example: 2 }),
29
+ Type(() => Number),
30
+ IsInt(),
31
+ IsPositive(),
32
+ __metadata("design:type", Number)
33
+ ], ConsumeTrialAlertDto.prototype, "organizationId", void 0);
34
+ __decorate([
35
+ ApiProperty({ description: 'Incident that consumed the alert - the idempotency key', example: 9931 }),
36
+ Type(() => Number),
37
+ IsInt(),
38
+ IsPositive(),
39
+ __metadata("design:type", Number)
40
+ ], ConsumeTrialAlertDto.prototype, "incidentId", void 0);
41
+ __decorate([
42
+ ApiPropertyOptional({ description: 'Incident type of the consuming incident', example: 7 }),
43
+ Type(() => Number),
44
+ IsInt(),
45
+ IsPositive(),
46
+ IsOptional(),
47
+ __metadata("design:type", Number)
48
+ ], ConsumeTrialAlertDto.prototype, "incidentTypeId", void 0);
49
+ //# sourceMappingURL=consume-trial-alert.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consume-trial-alert.dto.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/dtos/consume-trial-alert.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;CAyBhC;AApBG;IAJC,WAAW,CAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACtE,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;oDACG;AAMhB;IAJC,WAAW,CAAC,EAAE,WAAW,EAAE,qCAAqC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC/E,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;4DACW;AAMxB;IAJC,WAAW,CAAC,EAAE,WAAW,EAAE,wDAAwD,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;wDACO;AAOpB;IALC,mBAAmB,CAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3F,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;IACZ,UAAU,EAAE;;4DACW"}
@@ -0,0 +1,51 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
11
+ import { IsBoolean, IsInt, IsOptional, IsPositive } from 'class-validator';
12
+ import { Type } from 'class-transformer';
13
+ /**
14
+ * Service-to-service entitlement question. Sent by clarion-incident before an
15
+ * incident of class `Incident` is created, and by any other service that needs
16
+ * to know whether a user may reach the provider control room.
17
+ */
18
+ export class EvaluateEntitlementDto {
19
+ }
20
+ __decorate([
21
+ ApiProperty({ description: 'User whose premium standing is being evaluated', example: 42 }),
22
+ Type(() => Number),
23
+ IsInt(),
24
+ IsPositive(),
25
+ __metadata("design:type", Number)
26
+ ], EvaluateEntitlementDto.prototype, "userId", void 0);
27
+ __decorate([
28
+ ApiProperty({ description: 'Organization (service provider) the entitlement is scoped to', example: 2 }),
29
+ Type(() => Number),
30
+ IsInt(),
31
+ IsPositive(),
32
+ __metadata("design:type", Number)
33
+ ], EvaluateEntitlementDto.prototype, "organizationId", void 0);
34
+ __decorate([
35
+ ApiPropertyOptional({ description: 'Incident type the alert is for. Omit to ask about premium standing in general.', example: 7 }),
36
+ Type(() => Number),
37
+ IsInt(),
38
+ IsPositive(),
39
+ IsOptional(),
40
+ __metadata("design:type", Number)
41
+ ], EvaluateEntitlementDto.prototype, "incidentTypeId", void 0);
42
+ __decorate([
43
+ ApiPropertyOptional({
44
+ description: 'Whether a first-time user with no subscription may be lazily enrolled into the premium trial. Defaults to true.',
45
+ example: true,
46
+ }),
47
+ IsBoolean(),
48
+ IsOptional(),
49
+ __metadata("design:type", Boolean)
50
+ ], EvaluateEntitlementDto.prototype, "autoEnrollTrial", void 0);
51
+ //# sourceMappingURL=evaluate-entitlement.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluate-entitlement.dto.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/dtos/evaluate-entitlement.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;CA2BlC;AAtBG;IAJC,WAAW,CAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC3F,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;sDACG;AAMhB;IAJC,WAAW,CAAC,EAAE,WAAW,EAAE,8DAA8D,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACxG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;8DACW;AAOxB;IALC,mBAAmB,CAAC,EAAE,WAAW,EAAE,gFAAgF,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAClI,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;IACZ,UAAU,EAAE;;8DACW;AAQxB;IANC,mBAAmB,CAAC;QACjB,WAAW,EAAE,iHAAiH;QAC9H,OAAO,EAAE,IAAI;KAChB,CAAC;IACD,SAAS,EAAE;IACX,UAAU,EAAE;;+DACa"}
@@ -0,0 +1,53 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
11
+ import { IsInt, IsOptional, IsPositive, IsString, MaxLength, Min } from 'class-validator';
12
+ import { Type } from 'class-transformer';
13
+ /** Operator-initiated trial grant (or extension of an existing trial). */
14
+ export class GrantPremiumTrialDto {
15
+ }
16
+ __decorate([
17
+ ApiProperty({ example: 42 }),
18
+ Type(() => Number),
19
+ IsInt(),
20
+ IsPositive(),
21
+ __metadata("design:type", Number)
22
+ ], GrantPremiumTrialDto.prototype, "userId", void 0);
23
+ __decorate([
24
+ ApiProperty({ example: 2 }),
25
+ Type(() => Number),
26
+ IsInt(),
27
+ IsPositive(),
28
+ __metadata("design:type", Number)
29
+ ], GrantPremiumTrialDto.prototype, "organizationId", void 0);
30
+ __decorate([
31
+ ApiPropertyOptional({ description: 'Alerts the trial grants. Falls back to the configured default (2).', example: 2 }),
32
+ Type(() => Number),
33
+ IsInt(),
34
+ Min(1),
35
+ IsOptional(),
36
+ __metadata("design:type", Number)
37
+ ], GrantPremiumTrialDto.prototype, "maxIncidents", void 0);
38
+ __decorate([
39
+ ApiPropertyOptional({ description: 'Trial length in days. Falls back to the configured default (30).', example: 30 }),
40
+ Type(() => Number),
41
+ IsInt(),
42
+ Min(1),
43
+ IsOptional(),
44
+ __metadata("design:type", Number)
45
+ ], GrantPremiumTrialDto.prototype, "durationDays", void 0);
46
+ __decorate([
47
+ ApiPropertyOptional({ description: 'Free-text audit note', example: 'Goodwill extension after failed payment' }),
48
+ IsString(),
49
+ MaxLength(500),
50
+ IsOptional(),
51
+ __metadata("design:type", String)
52
+ ], GrantPremiumTrialDto.prototype, "reason", void 0);
53
+ //# sourceMappingURL=grant-premium-trial.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grant-premium-trial.dto.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/dtos/grant-premium-trial.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,0EAA0E;AAC1E,MAAM,OAAO,oBAAoB;CAgChC;AA3BG;IAJC,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC5B,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;oDACG;AAMhB;IAJC,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3B,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,UAAU,EAAE;;4DACW;AAOxB;IALC,mBAAmB,CAAC,EAAE,WAAW,EAAE,oEAAoE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtH,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,GAAG,CAAC,CAAC,CAAC;IACN,UAAU,EAAE;;0DACS;AAOtB;IALC,mBAAmB,CAAC,EAAE,WAAW,EAAE,kEAAkE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACrH,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,GAAG,CAAC,CAAC,CAAC;IACN,UAAU,EAAE;;0DACS;AAMtB;IAJC,mBAAmB,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;IAChH,QAAQ,EAAE;IACV,SAAS,CAAC,GAAG,CAAC;IACd,UAAU,EAAE;;oDACG"}
@@ -0,0 +1,22 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { ApiPropertyOptional } from '@nestjs/swagger';
11
+ import { IsOptional, IsString, MaxLength } from 'class-validator';
12
+ /** Operator-initiated trial revocation. */
13
+ export class RevokePremiumTrialDto {
14
+ }
15
+ __decorate([
16
+ ApiPropertyOptional({ description: 'Free-text audit note', example: 'Repeated test alerts' }),
17
+ IsString(),
18
+ MaxLength(500),
19
+ IsOptional(),
20
+ __metadata("design:type", String)
21
+ ], RevokePremiumTrialDto.prototype, "reason", void 0);
22
+ //# sourceMappingURL=revoke-premium-trial.dto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revoke-premium-trial.dto.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/dtos/revoke-premium-trial.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAElE,2CAA2C;AAC3C,MAAM,OAAO,qBAAqB;CAMjC;AADG;IAJC,mBAAmB,CAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAC7F,QAAQ,EAAE;IACV,SAAS,CAAC,GAAG,CAAC;IACd,UAAU,EAAE;;qDACG"}
@@ -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,18 @@
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
+ // DTOs
12
+ export * from './dtos/evaluate-entitlement.dto';
13
+ export * from './dtos/consume-trial-alert.dto';
14
+ export * from './dtos/grant-premium-trial.dto';
15
+ export * from './dtos/revoke-premium-trial.dto';
16
+ // Utilities
17
+ export * from './utils/entitlement.util';
18
+ //# 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,OAAO;AACP,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAEhD,YAAY;AACZ,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=entitlement-evaluation.js.map
@@ -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"}