grm-shared-library 1.1.190 → 1.1.192

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 (73) hide show
  1. package/dist/cjs/index.js +1 -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/esm/index.js +1 -0
  30. package/dist/esm/index.js.map +1 -1
  31. package/dist/esm/modules/entitlement/constants/entitlement-defaults.const.js +17 -0
  32. package/dist/esm/modules/entitlement/constants/entitlement-defaults.const.js.map +1 -0
  33. package/dist/esm/modules/entitlement/dtos/consume-trial-alert.dto.js +49 -0
  34. package/dist/esm/modules/entitlement/dtos/consume-trial-alert.dto.js.map +1 -0
  35. package/dist/esm/modules/entitlement/dtos/evaluate-entitlement.dto.js +51 -0
  36. package/dist/esm/modules/entitlement/dtos/evaluate-entitlement.dto.js.map +1 -0
  37. package/dist/esm/modules/entitlement/dtos/grant-premium-trial.dto.js +53 -0
  38. package/dist/esm/modules/entitlement/dtos/grant-premium-trial.dto.js.map +1 -0
  39. package/dist/esm/modules/entitlement/dtos/revoke-premium-trial.dto.js +22 -0
  40. package/dist/esm/modules/entitlement/dtos/revoke-premium-trial.dto.js.map +1 -0
  41. package/dist/esm/modules/entitlement/enums/entitlement-decision-reason.enum.js +31 -0
  42. package/dist/esm/modules/entitlement/enums/entitlement-decision-reason.enum.js.map +1 -0
  43. package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js +16 -0
  44. package/dist/esm/modules/entitlement/enums/incident-entitlement-scope.enum.js.map +1 -0
  45. package/dist/esm/modules/entitlement/enums/incident-entitlement-tier.enum.js +24 -0
  46. package/dist/esm/modules/entitlement/enums/incident-entitlement-tier.enum.js.map +1 -0
  47. package/dist/esm/modules/entitlement/enums/premium-trial-source.enum.js +9 -0
  48. package/dist/esm/modules/entitlement/enums/premium-trial-source.enum.js.map +1 -0
  49. package/dist/esm/modules/entitlement/enums/premium-trial-status.enum.js +15 -0
  50. package/dist/esm/modules/entitlement/enums/premium-trial-status.enum.js.map +1 -0
  51. package/dist/esm/modules/entitlement/index.js +18 -0
  52. package/dist/esm/modules/entitlement/index.js.map +1 -0
  53. package/dist/esm/modules/entitlement/interfaces/entitlement-evaluation.js +2 -0
  54. package/dist/esm/modules/entitlement/interfaces/entitlement-evaluation.js.map +1 -0
  55. package/dist/esm/modules/entitlement/utils/entitlement.util.js +42 -0
  56. package/dist/esm/modules/entitlement/utils/entitlement.util.js.map +1 -0
  57. package/dist/types/index.d.ts +1 -0
  58. package/dist/types/interfaces/pagination.d.ts +10 -0
  59. package/dist/types/modules/entitlement/constants/entitlement-defaults.const.d.ts +16 -0
  60. package/dist/types/modules/entitlement/dtos/consume-trial-alert.dto.d.ts +11 -0
  61. package/dist/types/modules/entitlement/dtos/evaluate-entitlement.dto.d.ts +11 -0
  62. package/dist/types/modules/entitlement/dtos/grant-premium-trial.dto.d.ts +8 -0
  63. package/dist/types/modules/entitlement/dtos/revoke-premium-trial.dto.d.ts +4 -0
  64. package/dist/types/modules/entitlement/enums/entitlement-decision-reason.enum.d.ts +29 -0
  65. package/dist/types/modules/entitlement/enums/incident-entitlement-scope.enum.d.ts +14 -0
  66. package/dist/types/modules/entitlement/enums/incident-entitlement-tier.enum.d.ts +22 -0
  67. package/dist/types/modules/entitlement/enums/premium-trial-source.enum.d.ts +7 -0
  68. package/dist/types/modules/entitlement/enums/premium-trial-status.enum.d.ts +13 -0
  69. package/dist/types/modules/entitlement/index.d.ts +12 -0
  70. package/dist/types/modules/entitlement/interfaces/entitlement-evaluation.d.ts +91 -0
  71. package/dist/types/modules/entitlement/utils/entitlement.util.d.ts +22 -0
  72. package/dist/types/modules/incident/intefaces/incident.d.ts +11 -0
  73. package/package.json +1 -1
package/dist/cjs/index.js CHANGED
@@ -36,6 +36,7 @@ __exportStar(require("./modules/chat/index"), exports);
36
36
  __exportStar(require("./modules/country/index"), exports);
37
37
  __exportStar(require("./modules/phone/index"), exports);
38
38
  __exportStar(require("./modules/tracking/index"), exports);
39
+ __exportStar(require("./modules/entitlement/index"), exports);
39
40
  // Interfaces
40
41
  __exportStar(require("./interfaces/server-message"), exports);
41
42
  __exportStar(require("./interfaces/i-request-with-user"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,UAAU;AACV,uDAAqC;AACrC,+DAA6C;AAC7C,yDAAuC;AACvC,6DAA2C;AAC3C,uDAAqC;AACrC,uDAAqC;AACrC,iEAA+C;AAC/C,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,wDAAsC;AACtC,2DAAyC;AAEzC,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,wFAAsE;AAEtE,aAAa;AACb,qDAAmC"}
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,wDAAsC;AACtC,gEAA8C;AAC9C,2DAAyC;AACzC,2DAAyC;AACzC,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,yDAAuC;AACvC,mEAAiD;AACjD,+DAA6C;AAC7C,uDAAqC;AACrC,0DAAwC;AACxC,wDAAsC;AACtC,2DAAyC;AACzC,8DAA4C;AAE5C,aAAa;AACb,8DAA4C;AAC5C,mEAAiD;AACjD,8DAA4C;AAC5C,2DAAyC;AACzC,0DAAwC;AAExC,YAAY;AACZ,2DAAyC;AAEzC,QAAQ;AACR,gDAA8B;AAE9B,YAAY;AACZ,+DAA6C;AAC7C,wFAAsE;AAEtE,aAAa;AACb,qDAAmC"}
@@ -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,53 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ConsumeTrialAlertDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ /**
17
+ * Records that one trial alert was spent. `incidentId` is the idempotency key:
18
+ * replaying the same incident never double-counts, so the caller can retry
19
+ * freely after a transient failure.
20
+ */
21
+ class ConsumeTrialAlertDto {
22
+ }
23
+ exports.ConsumeTrialAlertDto = ConsumeTrialAlertDto;
24
+ __decorate([
25
+ (0, swagger_1.ApiProperty)({ description: 'User the trial belongs to', example: 42 }),
26
+ (0, class_transformer_1.Type)(() => Number),
27
+ (0, class_validator_1.IsInt)(),
28
+ (0, class_validator_1.IsPositive)(),
29
+ __metadata("design:type", Number)
30
+ ], ConsumeTrialAlertDto.prototype, "userId", void 0);
31
+ __decorate([
32
+ (0, swagger_1.ApiProperty)({ description: 'Organization the trial is scoped to', example: 2 }),
33
+ (0, class_transformer_1.Type)(() => Number),
34
+ (0, class_validator_1.IsInt)(),
35
+ (0, class_validator_1.IsPositive)(),
36
+ __metadata("design:type", Number)
37
+ ], ConsumeTrialAlertDto.prototype, "organizationId", void 0);
38
+ __decorate([
39
+ (0, swagger_1.ApiProperty)({ description: 'Incident that consumed the alert - the idempotency key', example: 9931 }),
40
+ (0, class_transformer_1.Type)(() => Number),
41
+ (0, class_validator_1.IsInt)(),
42
+ (0, class_validator_1.IsPositive)(),
43
+ __metadata("design:type", Number)
44
+ ], ConsumeTrialAlertDto.prototype, "incidentId", void 0);
45
+ __decorate([
46
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Incident type of the consuming incident', example: 7 }),
47
+ (0, class_transformer_1.Type)(() => Number),
48
+ (0, class_validator_1.IsInt)(),
49
+ (0, class_validator_1.IsPositive)(),
50
+ (0, class_validator_1.IsOptional)(),
51
+ __metadata("design:type", Number)
52
+ ], ConsumeTrialAlertDto.prototype, "incidentTypeId", void 0);
53
+ //# 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,6CAAmE;AACnE,qDAAgE;AAChE,yDAAyC;AAEzC;;;;GAIG;AACH,MAAa,oBAAoB;CAyBhC;AAzBD,oDAyBC;AApBG;IAJC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACtE,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;oDACG;AAMhB;IAJC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,qCAAqC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC/E,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;4DACW;AAMxB;IAJC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,wDAAwD,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrG,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;wDACO;AAOpB;IALC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,yCAAyC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3F,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;IACZ,IAAA,4BAAU,GAAE;;4DACW"}
@@ -0,0 +1,55 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.EvaluateEntitlementDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ /**
17
+ * Service-to-service entitlement question. Sent by clarion-incident before an
18
+ * incident of class `Incident` is created, and by any other service that needs
19
+ * to know whether a user may reach the provider control room.
20
+ */
21
+ class EvaluateEntitlementDto {
22
+ }
23
+ exports.EvaluateEntitlementDto = EvaluateEntitlementDto;
24
+ __decorate([
25
+ (0, swagger_1.ApiProperty)({ description: 'User whose premium standing is being evaluated', example: 42 }),
26
+ (0, class_transformer_1.Type)(() => Number),
27
+ (0, class_validator_1.IsInt)(),
28
+ (0, class_validator_1.IsPositive)(),
29
+ __metadata("design:type", Number)
30
+ ], EvaluateEntitlementDto.prototype, "userId", void 0);
31
+ __decorate([
32
+ (0, swagger_1.ApiProperty)({ description: 'Organization (service provider) the entitlement is scoped to', example: 2 }),
33
+ (0, class_transformer_1.Type)(() => Number),
34
+ (0, class_validator_1.IsInt)(),
35
+ (0, class_validator_1.IsPositive)(),
36
+ __metadata("design:type", Number)
37
+ ], EvaluateEntitlementDto.prototype, "organizationId", void 0);
38
+ __decorate([
39
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Incident type the alert is for. Omit to ask about premium standing in general.', example: 7 }),
40
+ (0, class_transformer_1.Type)(() => Number),
41
+ (0, class_validator_1.IsInt)(),
42
+ (0, class_validator_1.IsPositive)(),
43
+ (0, class_validator_1.IsOptional)(),
44
+ __metadata("design:type", Number)
45
+ ], EvaluateEntitlementDto.prototype, "incidentTypeId", void 0);
46
+ __decorate([
47
+ (0, swagger_1.ApiPropertyOptional)({
48
+ description: 'Whether a first-time user with no subscription may be lazily enrolled into the premium trial. Defaults to true.',
49
+ example: true,
50
+ }),
51
+ (0, class_validator_1.IsBoolean)(),
52
+ (0, class_validator_1.IsOptional)(),
53
+ __metadata("design:type", Boolean)
54
+ ], EvaluateEntitlementDto.prototype, "autoEnrollTrial", void 0);
55
+ //# 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,6CAAmE;AACnE,qDAA2E;AAC3E,yDAAyC;AAEzC;;;;GAIG;AACH,MAAa,sBAAsB;CA2BlC;AA3BD,wDA2BC;AAtBG;IAJC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,gDAAgD,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC3F,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;sDACG;AAMhB;IAJC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,8DAA8D,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACxG,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;8DACW;AAOxB;IALC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,gFAAgF,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAClI,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;IACZ,IAAA,4BAAU,GAAE;;8DACW;AAQxB;IANC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EAAE,iHAAiH;QAC9H,OAAO,EAAE,IAAI;KAChB,CAAC;IACD,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;+DACa"}
@@ -0,0 +1,57 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GrantPremiumTrialDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ const class_transformer_1 = require("class-transformer");
16
+ /** Operator-initiated trial grant (or extension of an existing trial). */
17
+ class GrantPremiumTrialDto {
18
+ }
19
+ exports.GrantPremiumTrialDto = GrantPremiumTrialDto;
20
+ __decorate([
21
+ (0, swagger_1.ApiProperty)({ example: 42 }),
22
+ (0, class_transformer_1.Type)(() => Number),
23
+ (0, class_validator_1.IsInt)(),
24
+ (0, class_validator_1.IsPositive)(),
25
+ __metadata("design:type", Number)
26
+ ], GrantPremiumTrialDto.prototype, "userId", void 0);
27
+ __decorate([
28
+ (0, swagger_1.ApiProperty)({ example: 2 }),
29
+ (0, class_transformer_1.Type)(() => Number),
30
+ (0, class_validator_1.IsInt)(),
31
+ (0, class_validator_1.IsPositive)(),
32
+ __metadata("design:type", Number)
33
+ ], GrantPremiumTrialDto.prototype, "organizationId", void 0);
34
+ __decorate([
35
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Alerts the trial grants. Falls back to the configured default (2).', example: 2 }),
36
+ (0, class_transformer_1.Type)(() => Number),
37
+ (0, class_validator_1.IsInt)(),
38
+ (0, class_validator_1.Min)(1),
39
+ (0, class_validator_1.IsOptional)(),
40
+ __metadata("design:type", Number)
41
+ ], GrantPremiumTrialDto.prototype, "maxIncidents", void 0);
42
+ __decorate([
43
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Trial length in days. Falls back to the configured default (30).', example: 30 }),
44
+ (0, class_transformer_1.Type)(() => Number),
45
+ (0, class_validator_1.IsInt)(),
46
+ (0, class_validator_1.Min)(1),
47
+ (0, class_validator_1.IsOptional)(),
48
+ __metadata("design:type", Number)
49
+ ], GrantPremiumTrialDto.prototype, "durationDays", void 0);
50
+ __decorate([
51
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Free-text audit note', example: 'Goodwill extension after failed payment' }),
52
+ (0, class_validator_1.IsString)(),
53
+ (0, class_validator_1.MaxLength)(500),
54
+ (0, class_validator_1.IsOptional)(),
55
+ __metadata("design:type", String)
56
+ ], GrantPremiumTrialDto.prototype, "reason", void 0);
57
+ //# 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,6CAAmE;AACnE,qDAA0F;AAC1F,yDAAyC;AAEzC,0EAA0E;AAC1E,MAAa,oBAAoB;CAgChC;AAhCD,oDAgCC;AA3BG;IAJC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAC5B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;oDACG;AAMhB;IAJC,IAAA,qBAAW,EAAC,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IAC3B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,4BAAU,GAAE;;4DACW;AAOxB;IALC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,oEAAoE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtH,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,4BAAU,GAAE;;0DACS;AAOtB;IALC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,kEAAkE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACrH,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,IAAA,uBAAK,GAAE;IACP,IAAA,qBAAG,EAAC,CAAC,CAAC;IACN,IAAA,4BAAU,GAAE;;0DACS;AAMtB;IAJC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;IAChH,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,GAAG,CAAC;IACd,IAAA,4BAAU,GAAE;;oDACG"}
@@ -0,0 +1,26 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.RevokePremiumTrialDto = void 0;
13
+ const swagger_1 = require("@nestjs/swagger");
14
+ const class_validator_1 = require("class-validator");
15
+ /** Operator-initiated trial revocation. */
16
+ class RevokePremiumTrialDto {
17
+ }
18
+ exports.RevokePremiumTrialDto = RevokePremiumTrialDto;
19
+ __decorate([
20
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Free-text audit note', example: 'Repeated test alerts' }),
21
+ (0, class_validator_1.IsString)(),
22
+ (0, class_validator_1.MaxLength)(500),
23
+ (0, class_validator_1.IsOptional)(),
24
+ __metadata("design:type", String)
25
+ ], RevokePremiumTrialDto.prototype, "reason", void 0);
26
+ //# 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,6CAAsD;AACtD,qDAAkE;AAElE,2CAA2C;AAC3C,MAAa,qBAAqB;CAMjC;AAND,sDAMC;AADG;IAJC,IAAA,6BAAmB,EAAC,EAAE,WAAW,EAAE,sBAAsB,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;IAC7F,IAAA,0BAAQ,GAAE;IACV,IAAA,2BAAS,EAAC,GAAG,CAAC;IACd,IAAA,4BAAU,GAAE;;qDACG"}
@@ -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,34 @@
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
+ // DTOs
28
+ __exportStar(require("./dtos/evaluate-entitlement.dto"), exports);
29
+ __exportStar(require("./dtos/consume-trial-alert.dto"), exports);
30
+ __exportStar(require("./dtos/grant-premium-trial.dto"), exports);
31
+ __exportStar(require("./dtos/revoke-premium-trial.dto"), exports);
32
+ // Utilities
33
+ __exportStar(require("./utils/entitlement.util"), exports);
34
+ //# 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,OAAO;AACP,kEAAgD;AAChD,iEAA+C;AAC/C,iEAA+C;AAC/C,kEAAgD;AAEhD,YAAY;AACZ,2DAAyC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# 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,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEntitledTier = isEntitledTier;
4
+ exports.isFreeUserTier = isFreeUserTier;
5
+ exports.isTrialUsable = isTrialUsable;
6
+ exports.parseIncidentEntitlementScope = parseIncidentEntitlementScope;
7
+ exports.trialDaysRemaining = trialDaysRemaining;
8
+ const incident_entitlement_scope_enum_1 = require("../enums/incident-entitlement-scope.enum");
9
+ const incident_entitlement_tier_enum_1 = require("../enums/incident-entitlement-tier.enum");
10
+ const premium_trial_status_enum_1 = require("../enums/premium-trial-status.enum");
11
+ /**
12
+ * Whether a tier reaches the provider control room.
13
+ *
14
+ * Everything except `FREE` counts as entitled: `NOT_APPLICABLE` covers
15
+ * grievances and pre-enforcement incidents, which must keep behaving exactly as
16
+ * they did before entitlement gating existed.
17
+ */
18
+ function isEntitledTier(tier) {
19
+ return tier !== incident_entitlement_tier_enum_1.IncidentEntitlementTier.FREE;
20
+ }
21
+ /** Whether an incident was raised by a Free user (no subscription, no trial). */
22
+ function isFreeUserTier(tier) {
23
+ return tier === incident_entitlement_tier_enum_1.IncidentEntitlementTier.FREE;
24
+ }
25
+ /** True while the trial still grants premium behaviour. */
26
+ function isTrialUsable(status) {
27
+ return status === premium_trial_status_enum_1.PremiumTrialStatus.ACTIVE;
28
+ }
29
+ /**
30
+ * Parses a client-supplied entitlement scope. Unknown/absent values fall back to
31
+ * `ALL` so an unrecognised query string never silently hides incidents.
32
+ */
33
+ function parseIncidentEntitlementScope(value) {
34
+ if (!value)
35
+ return incident_entitlement_scope_enum_1.IncidentEntitlementScope.ALL;
36
+ const normalized = value.trim().toUpperCase();
37
+ return Object.values(incident_entitlement_scope_enum_1.IncidentEntitlementScope).includes(normalized)
38
+ ? normalized
39
+ : incident_entitlement_scope_enum_1.IncidentEntitlementScope.ALL;
40
+ }
41
+ /** Whole days remaining until `expiresAt`, floored at zero. */
42
+ function trialDaysRemaining(expiresAt, now = new Date()) {
43
+ const end = expiresAt instanceof Date ? expiresAt : new Date(expiresAt);
44
+ const ms = end.getTime() - now.getTime();
45
+ if (!Number.isFinite(ms) || ms <= 0)
46
+ return 0;
47
+ return Math.ceil(ms / (24 * 60 * 60 * 1000));
48
+ }
49
+ //# sourceMappingURL=entitlement.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entitlement.util.js","sourceRoot":"","sources":["../../../../../src/modules/entitlement/utils/entitlement.util.ts"],"names":[],"mappings":";;AAWA,wCAEC;AAGD,wCAEC;AAGD,sCAEC;AAMD,sEAQC;AAGD,gDAKC;AA7CD,8FAAoF;AACpF,4FAAkF;AAClF,kFAAwE;AAExE;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,IAA8C;IACzE,OAAO,IAAI,KAAK,wDAAuB,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,iFAAiF;AACjF,SAAgB,cAAc,CAAC,IAA8C;IACzE,OAAO,IAAI,KAAK,wDAAuB,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,2DAA2D;AAC3D,SAAgB,aAAa,CAAC,MAA2C;IACrE,OAAO,MAAM,KAAK,8CAAkB,CAAC,MAAM,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,SAAgB,6BAA6B,CACzC,KAAqB;IAErB,IAAI,CAAC,KAAK;QAAE,OAAO,0DAAwB,CAAC,GAAG,CAAC;IAChD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9C,OAAQ,MAAM,CAAC,MAAM,CAAC,0DAAwB,CAAc,CAAC,QAAQ,CAAC,UAAU,CAAC;QAC7E,CAAC,CAAE,UAAuC;QAC1C,CAAC,CAAC,0DAAwB,CAAC,GAAG,CAAC;AACvC,CAAC;AAED,+DAA+D;AAC/D,SAAgB,kBAAkB,CAAC,SAAwB,EAAE,MAAY,IAAI,IAAI,EAAE;IAC/E,MAAM,GAAG,GAAG,SAAS,YAAY,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IACxE,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AACjD,CAAC"}
package/dist/esm/index.js CHANGED
@@ -20,6 +20,7 @@ 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';
23
24
  // Interfaces
24
25
  export * from './interfaces/server-message';
25
26
  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;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"}