@carlonicora/nestjs-neo4jsonapi 7.1.0 → 8.1.0

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 (130) hide show
  1. package/dist/bootstrap/app.module.factory.d.ts.map +1 -1
  2. package/dist/bootstrap/app.module.factory.js +1 -0
  3. package/dist/bootstrap/app.module.factory.js.map +1 -1
  4. package/dist/bootstrap/bootstrap.options.d.ts +23 -0
  5. package/dist/bootstrap/bootstrap.options.d.ts.map +1 -1
  6. package/dist/core/email/templates/en/cardExpiring.hbs +28 -0
  7. package/dist/core/email/templates/en/paymentFailure.hbs +4 -0
  8. package/dist/foundations/analytics/controllers/analytics.controller.d.ts +1 -0
  9. package/dist/foundations/analytics/controllers/analytics.controller.d.ts.map +1 -1
  10. package/dist/foundations/analytics/controllers/analytics.controller.js +1 -1
  11. package/dist/foundations/analytics/controllers/analytics.controller.js.map +1 -1
  12. package/dist/foundations/analytics/interfaces/analytics.config.interface.d.ts +19 -0
  13. package/dist/foundations/analytics/interfaces/analytics.config.interface.d.ts.map +1 -1
  14. package/dist/foundations/analytics/interfaces/analytics.config.interface.js +2 -0
  15. package/dist/foundations/analytics/interfaces/analytics.config.interface.js.map +1 -1
  16. package/dist/foundations/analytics/services/analytics.service.d.ts +10 -1
  17. package/dist/foundations/analytics/services/analytics.service.d.ts.map +1 -1
  18. package/dist/foundations/analytics/services/analytics.service.js +17 -1
  19. package/dist/foundations/analytics/services/analytics.service.js.map +1 -1
  20. package/dist/foundations/billing/billing.module.d.ts +26 -0
  21. package/dist/foundations/billing/billing.module.d.ts.map +1 -0
  22. package/dist/foundations/billing/billing.module.js +74 -0
  23. package/dist/foundations/billing/billing.module.js.map +1 -0
  24. package/dist/foundations/billing/cron/billing-lifecycle.cron.d.ts +16 -0
  25. package/dist/foundations/billing/cron/billing-lifecycle.cron.d.ts.map +1 -0
  26. package/dist/foundations/billing/cron/billing-lifecycle.cron.js +52 -0
  27. package/dist/foundations/billing/cron/billing-lifecycle.cron.js.map +1 -0
  28. package/dist/foundations/billing/index.d.ts +7 -0
  29. package/dist/foundations/billing/index.d.ts.map +1 -0
  30. package/dist/foundations/billing/index.js +28 -0
  31. package/dist/foundations/billing/index.js.map +1 -0
  32. package/dist/foundations/billing/interfaces/billing.config.interface.d.ts +71 -0
  33. package/dist/foundations/billing/interfaces/billing.config.interface.d.ts.map +1 -0
  34. package/dist/foundations/billing/interfaces/billing.config.interface.js +41 -0
  35. package/dist/foundations/billing/interfaces/billing.config.interface.js.map +1 -0
  36. package/dist/foundations/billing/processors/billing-email.jobs.d.ts +127 -0
  37. package/dist/foundations/billing/processors/billing-email.jobs.d.ts.map +1 -0
  38. package/dist/foundations/billing/processors/billing-email.jobs.js +196 -0
  39. package/dist/foundations/billing/processors/billing-email.jobs.js.map +1 -0
  40. package/dist/foundations/billing/processors/billing-email.processor.d.ts +33 -0
  41. package/dist/foundations/billing/processors/billing-email.processor.d.ts.map +1 -0
  42. package/dist/foundations/billing/processors/billing-email.processor.js +95 -0
  43. package/dist/foundations/billing/processors/billing-email.processor.js.map +1 -0
  44. package/dist/foundations/billing/services/card-expiry-warning.service.d.ts +58 -0
  45. package/dist/foundations/billing/services/card-expiry-warning.service.d.ts.map +1 -0
  46. package/dist/foundations/billing/services/card-expiry-warning.service.js +90 -0
  47. package/dist/foundations/billing/services/card-expiry-warning.service.js.map +1 -0
  48. package/dist/foundations/company/repositories/company.repository.d.ts +2 -0
  49. package/dist/foundations/company/repositories/company.repository.d.ts.map +1 -1
  50. package/dist/foundations/company/repositories/company.repository.js +2 -2
  51. package/dist/foundations/company/repositories/company.repository.js.map +1 -1
  52. package/dist/foundations/foundations.modules.d.ts +3 -0
  53. package/dist/foundations/foundations.modules.d.ts.map +1 -1
  54. package/dist/foundations/foundations.modules.js +3 -1
  55. package/dist/foundations/foundations.modules.js.map +1 -1
  56. package/dist/foundations/index.d.ts +1 -0
  57. package/dist/foundations/index.d.ts.map +1 -1
  58. package/dist/foundations/index.js +1 -0
  59. package/dist/foundations/index.js.map +1 -1
  60. package/dist/foundations/stripe-customer/services/stripe-customer-api.service.d.ts +17 -0
  61. package/dist/foundations/stripe-customer/services/stripe-customer-api.service.d.ts.map +1 -1
  62. package/dist/foundations/stripe-customer/services/stripe-customer-api.service.js +40 -0
  63. package/dist/foundations/stripe-customer/services/stripe-customer-api.service.js.map +1 -1
  64. package/dist/foundations/stripe-invoice/entities/stripe-invoice.entity.d.ts +1 -1
  65. package/dist/foundations/stripe-invoice/entities/stripe-invoice.entity.d.ts.map +1 -1
  66. package/dist/foundations/stripe-invoice/serialisers/stripe-invoice.serialiser.js +2 -2
  67. package/dist/foundations/stripe-invoice/serialisers/stripe-invoice.serialiser.js.map +1 -1
  68. package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.d.ts +13 -0
  69. package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.d.ts.map +1 -1
  70. package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.js +21 -0
  71. package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.js.map +1 -1
  72. package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts +1 -3
  73. package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts.map +1 -1
  74. package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js +5 -38
  75. package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js.map +1 -1
  76. package/dist/foundations/stripe-subscription/entities/stripe-subscription.d.ts +60 -0
  77. package/dist/foundations/stripe-subscription/entities/stripe-subscription.d.ts.map +1 -0
  78. package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.d.ts +1 -1
  79. package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.d.ts.map +1 -1
  80. package/dist/foundations/stripe-subscription/entities/stripe-subscription.js +61 -0
  81. package/dist/foundations/stripe-subscription/entities/stripe-subscription.js.map +1 -0
  82. package/dist/foundations/stripe-subscription/index.d.ts +1 -4
  83. package/dist/foundations/stripe-subscription/index.d.ts.map +1 -1
  84. package/dist/foundations/stripe-subscription/index.js +4 -8
  85. package/dist/foundations/stripe-subscription/index.js.map +1 -1
  86. package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.d.ts +93 -165
  87. package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.d.ts.map +1 -1
  88. package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.js +206 -274
  89. package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.js.map +1 -1
  90. package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts +34 -36
  91. package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts.map +1 -1
  92. package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js +20 -72
  93. package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js.map +1 -1
  94. package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts +1 -29
  95. package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts.map +1 -1
  96. package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js +1 -53
  97. package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js.map +1 -1
  98. package/dist/foundations/stripe-subscription/stripe-subscription.module.d.ts +3 -3
  99. package/dist/foundations/stripe-subscription/stripe-subscription.module.d.ts.map +1 -1
  100. package/dist/foundations/stripe-subscription/stripe-subscription.module.js +8 -7
  101. package/dist/foundations/stripe-subscription/stripe-subscription.module.js.map +1 -1
  102. package/dist/foundations/stripe-usage/entities/stripe-usage-record.entity.d.ts +1 -1
  103. package/dist/foundations/stripe-usage/entities/stripe-usage-record.entity.d.ts.map +1 -1
  104. package/dist/foundations/stripe-usage/serialisers/stripe-usage-record.serialiser.js +2 -2
  105. package/dist/foundations/stripe-usage/serialisers/stripe-usage-record.serialiser.js.map +1 -1
  106. package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.d.ts +6 -1
  107. package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.d.ts.map +1 -1
  108. package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.js +73 -15
  109. package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.js.map +1 -1
  110. package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.d.ts +24 -2
  111. package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.d.ts.map +1 -1
  112. package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.js +88 -20
  113. package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.js.map +1 -1
  114. package/package.json +1 -1
  115. package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.d.ts +0 -27
  116. package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.d.ts.map +0 -1
  117. package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.js +0 -3
  118. package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.js.map +0 -1
  119. package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.d.ts +0 -8
  120. package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.d.ts.map +0 -1
  121. package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.js +0 -30
  122. package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.js.map +0 -1
  123. package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.d.ts +0 -4
  124. package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.d.ts.map +0 -1
  125. package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.js +0 -17
  126. package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.js.map +0 -1
  127. package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.d.ts +0 -9
  128. package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.d.ts.map +0 -1
  129. package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.js +0 -59
  130. package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.js.map +0 -1
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The three billing emails an app can switch off one by one.
3
+ */
4
+ export type BillingEmailKey = "paymentFailed" | "cardExpiring" | "subscriptionEnded";
5
+ /**
6
+ * App-relative paths the billing emails link to. The sender prefixes each with
7
+ * the app URL (`app.url`, trailing slash removed).
8
+ */
9
+ export type BillingLinks = {
10
+ billing: string;
11
+ paymentMethod: string;
12
+ subscribe: string;
13
+ resubscribe: string;
14
+ };
15
+ /**
16
+ * One email job the library sender handles: the template id and the mapping from
17
+ * the queued payload to the template data.
18
+ */
19
+ export interface BillingEmailJobDefinition {
20
+ template: string;
21
+ toTemplateData: (payload: Record<string, unknown>, ctx: {
22
+ appUrl: string;
23
+ locale: string;
24
+ links: BillingLinks;
25
+ }) => Record<string, unknown>;
26
+ }
27
+ /**
28
+ * Configuration for the BillingModule. Every key is optional; omitted keys keep
29
+ * the value in `DEFAULT_BILLING_CONFIG`.
30
+ */
31
+ export interface BillingModuleConfig {
32
+ /**
33
+ * The library billing email sender (a BullMQ worker on `QueueId.EMAIL`).
34
+ * OFF by default: apps that consume the email queue with their own processor
35
+ * keep doing so. `extraJobs` adds or overrides job types for the app.
36
+ */
37
+ emailSender?: {
38
+ enabled?: boolean;
39
+ extraJobs?: Record<string, BillingEmailJobDefinition>;
40
+ };
41
+ /** Per-email switches. Default: every email on. */
42
+ emails?: Partial<Record<BillingEmailKey, boolean>>;
43
+ /** Keep full access while Stripe retries a failed renewal, for GMs who have paid before. Default on. */
44
+ failedCardGrace?: boolean;
45
+ /** Days between a subscription ending and the company's deletion date. Default 30. */
46
+ deletion?: {
47
+ afterSubscriptionEndedDays?: number;
48
+ };
49
+ /** App-relative paths used in billing emails. */
50
+ links?: Partial<BillingLinks>;
51
+ }
52
+ export type ResolvedBillingConfig = {
53
+ emailSender: {
54
+ enabled: boolean;
55
+ extraJobs: Record<string, BillingEmailJobDefinition>;
56
+ };
57
+ emails: Record<BillingEmailKey, boolean>;
58
+ failedCardGrace: boolean;
59
+ deletion: {
60
+ afterSubscriptionEndedDays: number;
61
+ };
62
+ links: BillingLinks;
63
+ };
64
+ export declare const DEFAULT_BILLING_CONFIG: ResolvedBillingConfig;
65
+ export declare const BILLING_CONFIG: unique symbol;
66
+ /**
67
+ * Merges an app's billing config over the defaults, key by key: a partial
68
+ * `emails` or `links` object keeps every key it does not name.
69
+ */
70
+ export declare function resolveBillingConfig(config?: BillingModuleConfig): ResolvedBillingConfig;
71
+ //# sourceMappingURL=billing.config.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.config.interface.d.ts","sourceRoot":"","sources":["../../../../src/foundations/billing/interfaces/billing.config.interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG,cAAc,GAAG,mBAAmB,CAAC;AAErF;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9G;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,GAAG,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,YAAY,CAAA;KAAE,KACzD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,WAAW,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;KAAE,CAAC;IAC3F,mDAAmD;IACnD,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,wGAAwG;IACxG,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,sFAAsF;IACtF,QAAQ,CAAC,EAAE;QAAE,0BAA0B,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAC/B;AAED,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAA;KAAE,CAAC;IACxF,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;IACzC,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE;QAAE,0BAA0B,EAAE,MAAM,CAAA;KAAE,CAAC;IACjD,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,qBAWpC,CAAC;AAEF,eAAO,MAAM,cAAc,eAA2B,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,mBAAmB,GAAG,qBAAqB,CAcxF"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BILLING_CONFIG = exports.DEFAULT_BILLING_CONFIG = void 0;
4
+ exports.resolveBillingConfig = resolveBillingConfig;
5
+ exports.DEFAULT_BILLING_CONFIG = {
6
+ emailSender: { enabled: false, extraJobs: {} },
7
+ emails: { paymentFailed: true, cardExpiring: true, subscriptionEnded: true },
8
+ failedCardGrace: true,
9
+ deletion: { afterSubscriptionEndedDays: 30 },
10
+ links: {
11
+ billing: "/settings/billing",
12
+ paymentMethod: "/settings/billing",
13
+ subscribe: "/settings/billing?action=subscribe",
14
+ resubscribe: "/settings/billing",
15
+ },
16
+ };
17
+ exports.BILLING_CONFIG = Symbol("BILLING_CONFIG");
18
+ /**
19
+ * Merges an app's billing config over the defaults, key by key: a partial
20
+ * `emails` or `links` object keeps every key it does not name.
21
+ */
22
+ function resolveBillingConfig(config) {
23
+ return {
24
+ emailSender: {
25
+ enabled: config?.emailSender?.enabled ?? exports.DEFAULT_BILLING_CONFIG.emailSender.enabled,
26
+ extraJobs: { ...exports.DEFAULT_BILLING_CONFIG.emailSender.extraJobs, ...(config?.emailSender?.extraJobs ?? {}) },
27
+ },
28
+ emails: { ...exports.DEFAULT_BILLING_CONFIG.emails, ...stripUndefined(config?.emails) },
29
+ failedCardGrace: config?.failedCardGrace ?? exports.DEFAULT_BILLING_CONFIG.failedCardGrace,
30
+ deletion: {
31
+ afterSubscriptionEndedDays: config?.deletion?.afterSubscriptionEndedDays ?? exports.DEFAULT_BILLING_CONFIG.deletion.afterSubscriptionEndedDays,
32
+ },
33
+ links: { ...exports.DEFAULT_BILLING_CONFIG.links, ...stripUndefined(config?.links) },
34
+ };
35
+ }
36
+ function stripUndefined(value) {
37
+ if (!value)
38
+ return {};
39
+ return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined));
40
+ }
41
+ //# sourceMappingURL=billing.config.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing.config.interface.js","sourceRoot":"","sources":["../../../../src/foundations/billing/interfaces/billing.config.interface.ts"],"names":[],"mappings":";;;AAuEA,oDAcC;AAjCY,QAAA,sBAAsB,GAA0B;IAC3D,WAAW,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE;IAC9C,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAC5E,eAAe,EAAE,IAAI;IACrB,QAAQ,EAAE,EAAE,0BAA0B,EAAE,EAAE,EAAE;IAC5C,KAAK,EAAE;QACL,OAAO,EAAE,mBAAmB;QAC5B,aAAa,EAAE,mBAAmB;QAClC,SAAS,EAAE,oCAAoC;QAC/C,WAAW,EAAE,mBAAmB;KACjC;CACF,CAAC;AAEW,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAEvD;;;GAGG;AACH,SAAgB,oBAAoB,CAAC,MAA4B;IAC/D,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,IAAI,8BAAsB,CAAC,WAAW,CAAC,OAAO;YACnF,SAAS,EAAE,EAAE,GAAG,8BAAsB,CAAC,WAAW,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,IAAI,EAAE,CAAC,EAAE;SAC1G;QACD,MAAM,EAAE,EAAE,GAAG,8BAAsB,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;QAC/E,eAAe,EAAE,MAAM,EAAE,eAAe,IAAI,8BAAsB,CAAC,eAAe;QAClF,QAAQ,EAAE;YACR,0BAA0B,EACxB,MAAM,EAAE,QAAQ,EAAE,0BAA0B,IAAI,8BAAsB,CAAC,QAAQ,CAAC,0BAA0B;SAC7G;QACD,KAAK,EAAE,EAAE,GAAG,8BAAsB,CAAC,KAAK,EAAE,GAAG,cAAc,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE;KAC7E,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAmB,KAAS;IACjD,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAe,CAAC;AACpG,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { BillingEmailJobDefinition } from "../interfaces/billing.config.interface";
2
+ /**
3
+ * Job types the library billing email sender handles out of the box.
4
+ *
5
+ * The mapping below is copied from only35's `apps/api/src/processors/email.processor.ts`
6
+ * (every job type except the app-specific `cull-completed`), with the hard-coded
7
+ * paths turned into the configurable `links`. `card-expiring` is new.
8
+ */
9
+ export type LibraryBillingJobType = "payment-failure" | "subscription-status-change" | "payment-success-customer" | "payment-success-admin" | "trial-ending-reminder" | "trial-ended" | "deletion-warning" | "subscription-cancelled" | "company-deleted" | "referral-invite" | "referral-reward" | "card-expiring";
10
+ export interface BillingEmailJobData {
11
+ jobType: string;
12
+ payload: Record<string, unknown> & {
13
+ to: string;
14
+ locale?: string;
15
+ };
16
+ }
17
+ export interface PaymentFailureEmailParams {
18
+ to: string;
19
+ customerName: string;
20
+ stripeCustomerId: string;
21
+ stripeInvoiceId?: string;
22
+ stripePaymentIntentId?: string;
23
+ amount?: number;
24
+ currency?: string;
25
+ errorMessage?: string;
26
+ invoiceUrl?: string;
27
+ invoiceNumber?: string;
28
+ keepsAccess?: boolean;
29
+ locale?: string;
30
+ }
31
+ export interface SubscriptionStatusEmailParams {
32
+ to: string;
33
+ customerName: string;
34
+ stripeCustomerId: string;
35
+ subscriptionId: string;
36
+ status: string;
37
+ locale?: string;
38
+ }
39
+ export interface PaymentSuccessCustomerEmailParams {
40
+ to: string;
41
+ customerName: string;
42
+ stripeCustomerId: string;
43
+ stripeInvoiceId?: string;
44
+ stripePaymentIntentId?: string;
45
+ amount: number;
46
+ currency: string;
47
+ invoiceUrl?: string;
48
+ invoiceNumber?: string;
49
+ isOneTimePurchase: boolean;
50
+ locale?: string;
51
+ }
52
+ export interface PaymentSuccessAdminEmailParams {
53
+ to: string;
54
+ adminName: string;
55
+ companyName: string;
56
+ amount: number;
57
+ currency: string;
58
+ isOneTimePurchase: boolean;
59
+ locale?: string;
60
+ }
61
+ export interface TrialEndingReminderEmailParams {
62
+ to: string;
63
+ customerName: string;
64
+ stripeCustomerId: string;
65
+ stripeSubscriptionId: string;
66
+ trialEndDate: string;
67
+ locale?: string;
68
+ }
69
+ export interface TrialEndedEmailParams {
70
+ to: string;
71
+ customerName: string;
72
+ companyName: string;
73
+ stripeCustomerId: string;
74
+ stripeSubscriptionId: string;
75
+ trialEndDate: string;
76
+ dataRemovalDate: string;
77
+ locale?: string;
78
+ }
79
+ export interface DeletionWarningEmailParams {
80
+ to: string;
81
+ companyName: string;
82
+ daysRemaining: number;
83
+ deletionDate: string;
84
+ reason: "trial_expired" | "subscription_cancelled";
85
+ isTrialExpired: boolean;
86
+ isSubscriptionCancelled: boolean;
87
+ locale?: string;
88
+ }
89
+ export interface SubscriptionCancelledEmailParams {
90
+ to: string;
91
+ companyName: string;
92
+ dataRemovalDate: string;
93
+ locale?: string;
94
+ }
95
+ export interface CompanyDeletedEmailParams {
96
+ to: string;
97
+ companyName: string;
98
+ reason: "trial_expired" | "subscription_cancelled" | "immediate_deletion";
99
+ deletionDate: string;
100
+ locale?: string;
101
+ }
102
+ export interface ReferralInviteEmailParams {
103
+ to: string;
104
+ referralCode: string;
105
+ companyName: string;
106
+ inviterName: string;
107
+ inviterEmail: string;
108
+ referralUrl: string;
109
+ locale?: string;
110
+ }
111
+ export interface ReferralRewardEmailParams {
112
+ to: string;
113
+ userName: string;
114
+ tokensAwarded: number;
115
+ locale?: string;
116
+ }
117
+ export interface CardExpiringEmailParams {
118
+ to: string;
119
+ customerName: string;
120
+ stripeCustomerId: string;
121
+ renewalDate: string;
122
+ cardBrand: string;
123
+ cardLast4: string;
124
+ locale?: string;
125
+ }
126
+ export declare const LIBRARY_BILLING_EMAIL_JOBS: Record<LibraryBillingJobType, BillingEmailJobDefinition>;
127
+ //# sourceMappingURL=billing-email.jobs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-email.jobs.d.ts","sourceRoot":"","sources":["../../../../src/foundations/billing/processors/billing-email.jobs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAC7B,iBAAiB,GACjB,4BAA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
+ const email_helpers_1 = require("../../../core/email/email.helpers");
5
+ /** Narrows the queued payload to the shape a job expects. */
6
+ function asParams(payload) {
7
+ return payload;
8
+ }
9
+ exports.LIBRARY_BILLING_EMAIL_JOBS = {
10
+ "payment-failure": {
11
+ template: "paymentFailure",
12
+ toTemplateData: (payload, { appUrl, locale, links }) => {
13
+ const params = asParams(payload);
14
+ return {
15
+ to: params.to,
16
+ customerName: params.customerName,
17
+ stripeInvoiceId: params.stripeInvoiceId,
18
+ stripePaymentIntentId: params.stripePaymentIntentId,
19
+ amount: params.amount,
20
+ currency: params.currency,
21
+ errorMessage: params.errorMessage,
22
+ invoiceUrl: params.invoiceUrl,
23
+ invoiceNumber: params.invoiceNumber,
24
+ updatePaymentUrl: `${appUrl}${links.paymentMethod}`,
25
+ keepsAccess: params.keepsAccess ?? false,
26
+ locale,
27
+ };
28
+ },
29
+ },
30
+ "subscription-status-change": {
31
+ template: "subscriptionStatusChange",
32
+ toTemplateData: (payload, { appUrl, locale, links }) => {
33
+ const params = asParams(payload);
34
+ return {
35
+ to: params.to,
36
+ customerName: params.customerName,
37
+ subscriptionId: params.subscriptionId,
38
+ status: params.status,
39
+ dashboardUrl: `${appUrl}${links.billing}`,
40
+ locale,
41
+ };
42
+ },
43
+ },
44
+ "payment-success-customer": {
45
+ template: "paymentSuccessCustomer",
46
+ toTemplateData: (payload, { appUrl, locale, links }) => {
47
+ const params = asParams(payload);
48
+ return {
49
+ to: params.to,
50
+ customerName: params.customerName,
51
+ amount: params.amount,
52
+ currency: params.currency?.toUpperCase() || "USD",
53
+ invoiceUrl: params.invoiceUrl,
54
+ invoiceNumber: params.invoiceNumber,
55
+ isOneTimePurchase: params.isOneTimePurchase,
56
+ billingDashboardUrl: `${appUrl}${links.billing}`,
57
+ locale,
58
+ };
59
+ },
60
+ },
61
+ "payment-success-admin": {
62
+ template: "paymentSuccessAdmin",
63
+ toTemplateData: (payload, { locale }) => {
64
+ const params = asParams(payload);
65
+ return {
66
+ to: params.to,
67
+ adminName: params.adminName,
68
+ companyName: params.companyName,
69
+ amount: params.amount,
70
+ currency: params.currency?.toUpperCase() || "USD",
71
+ isOneTimePurchase: params.isOneTimePurchase,
72
+ locale,
73
+ };
74
+ },
75
+ },
76
+ "trial-ending-reminder": {
77
+ template: "trialEndingReminder",
78
+ toTemplateData: (payload, { appUrl, locale, links }) => {
79
+ const params = asParams(payload);
80
+ return {
81
+ to: params.to,
82
+ customerName: params.customerName,
83
+ trialEndDate: (0, email_helpers_1.formatEmailDate)(params.trialEndDate, locale),
84
+ upgradeUrl: `${appUrl}${links.subscribe}`,
85
+ locale,
86
+ };
87
+ },
88
+ },
89
+ "trial-ended": {
90
+ template: "trialEndedWithoutPayment",
91
+ toTemplateData: (payload, { appUrl, locale, links }) => {
92
+ const params = asParams(payload);
93
+ return {
94
+ to: params.to,
95
+ customerName: params.customerName,
96
+ companyName: params.companyName,
97
+ trialEndDate: (0, email_helpers_1.formatEmailDate)(params.trialEndDate, locale),
98
+ dataRemovalDate: (0, email_helpers_1.formatEmailDate)(params.dataRemovalDate, locale),
99
+ upgradeUrl: `${appUrl}${links.resubscribe}`,
100
+ locale,
101
+ };
102
+ },
103
+ },
104
+ "deletion-warning": {
105
+ template: "deletionWarning",
106
+ toTemplateData: (payload, { appUrl, locale, links }) => {
107
+ const params = asParams(payload);
108
+ const subject = params.daysRemaining === 1
109
+ ? `Final Warning: Your ${params.companyName} data will be deleted tomorrow`
110
+ : `Warning: Your ${params.companyName} data will be deleted in ${params.daysRemaining} days`;
111
+ return {
112
+ to: params.to,
113
+ subject,
114
+ companyName: params.companyName,
115
+ daysRemaining: params.daysRemaining,
116
+ deletionDate: (0, email_helpers_1.formatEmailDate)(params.deletionDate, locale),
117
+ isTrialExpired: params.isTrialExpired,
118
+ isSubscriptionCancelled: params.isSubscriptionCancelled,
119
+ isFinalWarning: params.daysRemaining === 1,
120
+ resubscribeUrl: `${appUrl}${links.resubscribe}`,
121
+ locale,
122
+ };
123
+ },
124
+ },
125
+ "subscription-cancelled": {
126
+ template: "subscriptionCancelled",
127
+ toTemplateData: (payload, { appUrl, locale, links }) => {
128
+ const params = asParams(payload);
129
+ return {
130
+ to: params.to,
131
+ companyName: params.companyName,
132
+ dataRemovalDate: (0, email_helpers_1.formatEmailDate)(params.dataRemovalDate, locale),
133
+ resubscribeUrl: `${appUrl}${links.resubscribe}`,
134
+ locale,
135
+ };
136
+ },
137
+ },
138
+ "company-deleted": {
139
+ template: "companyDeleted",
140
+ toTemplateData: (payload, { locale }) => {
141
+ const params = asParams(payload);
142
+ return {
143
+ to: params.to,
144
+ companyName: params.companyName,
145
+ deletionDate: (0, email_helpers_1.formatEmailDate)(params.deletionDate, locale),
146
+ isTrialExpired: params.reason === "trial_expired",
147
+ isSubscriptionCancelled: params.reason === "subscription_cancelled",
148
+ isImmediateDeletion: params.reason === "immediate_deletion",
149
+ locale,
150
+ };
151
+ },
152
+ },
153
+ "referral-invite": {
154
+ template: "referralInvite",
155
+ toTemplateData: (payload, { locale }) => {
156
+ const params = asParams(payload);
157
+ return {
158
+ to: params.to,
159
+ referralCode: params.referralCode,
160
+ companyName: params.companyName,
161
+ inviterName: params.inviterName,
162
+ inviterEmail: params.inviterEmail,
163
+ referralUrl: params.referralUrl,
164
+ locale,
165
+ };
166
+ },
167
+ },
168
+ "referral-reward": {
169
+ template: "referralReward",
170
+ toTemplateData: (payload, { locale }) => {
171
+ const params = asParams(payload);
172
+ return {
173
+ to: params.to,
174
+ userName: params.userName,
175
+ tokensAwarded: params.tokensAwarded,
176
+ locale,
177
+ };
178
+ },
179
+ },
180
+ "card-expiring": {
181
+ template: "cardExpiring",
182
+ toTemplateData: (payload, { appUrl, locale, links }) => {
183
+ const params = asParams(payload);
184
+ return {
185
+ to: params.to,
186
+ customerName: params.customerName,
187
+ renewalDate: (0, email_helpers_1.formatEmailDate)(params.renewalDate, locale),
188
+ cardBrand: params.cardBrand,
189
+ cardLast4: params.cardLast4,
190
+ updatePaymentUrl: `${appUrl}${links.paymentMethod}`,
191
+ locale,
192
+ };
193
+ },
194
+ },
195
+ };
196
+ //# sourceMappingURL=billing-email.jobs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-email.jobs.js","sourceRoot":"","sources":["../../../../src/foundations/billing/processors/billing-email.jobs.ts"],"names":[],"mappings":";;;AAAA,qEAAoE;AAsJpE,6DAA6D;AAC7D,SAAS,QAAQ,CAAI,OAAgC;IACnD,OAAO,OAAuB,CAAC;AACjC,CAAC;AAEY,QAAA,0BAA0B,GAA6D;IAClG,iBAAiB,EAAE;QACjB,QAAQ,EAAE,gBAAgB;QAC1B,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;YACrD,MAAM,MAAM,GAAG,QAAQ,CAA4B,OAAO,CAAC,CAAC;YAC5D,OAAO;gBACL,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,eAAe,EAAE,MAAM,CAAC,eAAe;gBACvC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;gBACnD,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,aAAa,EAAE,MAAM,CAAC,aAAa;gBACnC,gBAAgB,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,aAAa,EAAE;gBACnD,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,KAAK;gBACxC,MAAM;aACP,CAAC;QACJ,CAAC;KACF;IAED,4BAA4B,EAAE;QAC5B,QAAQ,EAAE,0BAA0B;QACpC,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;YACrD,MAAM,MAAM,GAAG,QAAQ,CAAgC,OAAO,CAAC,CAAC;YAChE,O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AM,CAAC,aAAa;gBACnC,MAAM;aACP,CAAC;QACJ,CAAC;KACF;IAED,eAAe,EAAE;QACf,QAAQ,EAAE,cAAc;QACxB,cAAc,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;YACrD,MAAM,MAAM,GAAG,QAAQ,CAA0B,OAAO,CAAC,CAAC;YAC1D,OAAO;gBACL,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,WAAW,EAAE,IAAA,+BAAe,EAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC;gBACxD,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,SAAS,EAAE,MAAM,CAAC,SAAS;gBAC3B,gBAAgB,EAAE,GAAG,MAAM,GAAG,KAAK,CAAC,aAAa,EAAE;gBACnD,MAAM;aACP,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { WorkerHost } from "@nestjs/bullmq";
2
+ import { ConfigService } from "@nestjs/config";
3
+ import { Job } from "bullmq";
4
+ import { EmailService } from "../../../core/email/services/email.service";
5
+ import { AppLoggingService } from "../../../core/logging/services/logging.service";
6
+ import { ResolvedBillingConfig } from "../interfaces/billing.config.interface";
7
+ import { BillingEmailJobData } from "./billing-email.jobs";
8
+ /**
9
+ * BillingEmailProcessor — the library billing email sender, lifted from only35's
10
+ * `EmailProcessor`. Consumes `QueueId.EMAIL` and renders the job's template.
11
+ *
12
+ * Registered by `BillingModule` on worker instances only, and only when
13
+ * `billing.emailSender.enabled` is true: apps that consume the email queue with
14
+ * their own processor keep it off.
15
+ */
16
+ export declare class BillingEmailProcessor extends WorkerHost {
17
+ private readonly emailService;
18
+ private readonly logger;
19
+ private readonly configService;
20
+ /**
21
+ * App base URL for the links embedded in outgoing emails, without a trailing
22
+ * slash so `${appUrl}${links.billing}` cannot produce a doubled separator.
23
+ */
24
+ private readonly appUrl;
25
+ private readonly jobs;
26
+ private readonly config;
27
+ constructor(emailService: EmailService, logger: AppLoggingService, configService: ConfigService, billingConfig?: ResolvedBillingConfig);
28
+ onActive(job: Job<BillingEmailJobData>): void;
29
+ onError(job: Job<BillingEmailJobData>): void;
30
+ onCompleted(job: Job<BillingEmailJobData>): void;
31
+ process(job: Job<BillingEmailJobData>): Promise<void>;
32
+ }
33
+ //# sourceMappingURL=billing-email.processor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-email.processor.d.ts","sourceRoot":"","sources":["../../../../src/foundations/billing/processors/billing-email.processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAIL,qBAAqB,EACtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAA8B,MAAM,sBAAsB,CAAC;AAEvF;;;;;;;GAOG;AACH,qBAIa,qBAAsB,SAAQ,UAAU;IAUjD,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAXhC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4C;IACjE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;gBAG5B,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,iBAAiB,EACzB,aAAa,EAAE,aAAa,EACT,aAAa,CAAC,EAAE,qBAAqB;IAS3E,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC;IAKtC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC;IAKrC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC;IAInC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAgB5D"}
@@ -0,0 +1,95 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.BillingEmailProcessor = void 0;
16
+ const bullmq_1 = require("@nestjs/bullmq");
17
+ const common_1 = require("@nestjs/common");
18
+ const config_1 = require("@nestjs/config");
19
+ const bullmq_2 = require("bullmq");
20
+ const queue_id_1 = require("../../../config/enums/queue.id");
21
+ const email_service_1 = require("../../../core/email/services/email.service");
22
+ const logging_service_1 = require("../../../core/logging/services/logging.service");
23
+ const billing_config_interface_1 = require("../interfaces/billing.config.interface");
24
+ const billing_email_jobs_1 = require("./billing-email.jobs");
25
+ /**
26
+ * BillingEmailProcessor — the library billing email sender, lifted from only35's
27
+ * `EmailProcessor`. Consumes `QueueId.EMAIL` and renders the job's template.
28
+ *
29
+ * Registered by `BillingModule` on worker instances only, and only when
30
+ * `billing.emailSender.enabled` is true: apps that consume the email queue with
31
+ * their own processor keep it off.
32
+ */
33
+ let BillingEmailProcessor = class BillingEmailProcessor extends bullmq_1.WorkerHost {
34
+ constructor(emailService, logger, configService, billingConfig) {
35
+ super();
36
+ this.emailService = emailService;
37
+ this.logger = logger;
38
+ this.configService = configService;
39
+ this.config = billingConfig ?? billing_config_interface_1.DEFAULT_BILLING_CONFIG;
40
+ this.appUrl = (this.configService.get("app")?.url ?? "").replace(/\/$/, "");
41
+ this.jobs = { ...billing_email_jobs_1.LIBRARY_BILLING_EMAIL_JOBS, ...this.config.emailSender.extraJobs };
42
+ }
43
+ onActive(job) {
44
+ this.logger.debug(`Processing email job ${job.data.jobType} (ID: ${job.id})`);
45
+ }
46
+ onError(job) {
47
+ this.logger.error(`Failed to send email ${job.data.jobType} (ID: ${job.id}). Reason: ${job.failedReason}`);
48
+ }
49
+ onCompleted(job) {
50
+ this.logger.debug(`Email ${job.data.jobType} sent successfully (ID: ${job.id})`);
51
+ }
52
+ async process(job) {
53
+ const { jobType, payload } = job.data;
54
+ const definition = this.jobs[jobType];
55
+ if (!definition) {
56
+ this.logger.warn(`Unknown email job type: ${jobType}`);
57
+ return;
58
+ }
59
+ const locale = payload.locale || "en";
60
+ const data = definition.toTemplateData(payload, { appUrl: this.appUrl, locale, links: this.config.links });
61
+ await this.emailService.sendEmail(definition.template, { to: payload.to, ...data }, locale);
62
+ this.logger.log(`Sent ${jobType} email to ${payload.to}`);
63
+ }
64
+ };
65
+ exports.BillingEmailProcessor = BillingEmailProcessor;
66
+ __decorate([
67
+ (0, bullmq_1.OnWorkerEvent)("active"),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [bullmq_2.Job]),
70
+ __metadata("design:returntype", void 0)
71
+ ], BillingEmailProcessor.prototype, "onActive", null);
72
+ __decorate([
73
+ (0, bullmq_1.OnWorkerEvent)("failed"),
74
+ __metadata("design:type", Function),
75
+ __metadata("design:paramtypes", [bullmq_2.Job]),
76
+ __metadata("design:returntype", void 0)
77
+ ], BillingEmailProcessor.prototype, "onError", null);
78
+ __decorate([
79
+ (0, bullmq_1.OnWorkerEvent)("completed"),
80
+ __metadata("design:type", Function),
81
+ __metadata("design:paramtypes", [bullmq_2.Job]),
82
+ __metadata("design:returntype", void 0)
83
+ ], BillingEmailProcessor.prototype, "onCompleted", null);
84
+ exports.BillingEmailProcessor = BillingEmailProcessor = __decorate([
85
+ (0, bullmq_1.Processor)(queue_id_1.QueueId.EMAIL, {
86
+ concurrency: 5,
87
+ lockDuration: 30000,
88
+ }),
89
+ __param(3, (0, common_1.Optional)()),
90
+ __param(3, (0, common_1.Inject)(billing_config_interface_1.BILLING_CONFIG)),
91
+ __metadata("design:paramtypes", [email_service_1.EmailService,
92
+ logging_service_1.AppLoggingService,
93
+ config_1.ConfigService, Object])
94
+ ], BillingEmailProcessor);
95
+ //# sourceMappingURL=billing-email.processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billing-email.processor.js","sourceRoot":"","sources":["../../../../src/foundations/billing/processors/billing-email.processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsE;AACtE,2CAAkD;AAClD,2CAA+C;AAC/C,mCAA6B;AAC7B,6DAAyD;AACzD,8EAA0E;AAC1E,oFAAmF;AACnF,qFAKgD;AAChD,6DAAuF;AAEvF;;;;;;;GAOG;AAKI,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,mBAAU;IASnD,YACmB,YAA0B,EAC1B,MAAyB,EACzB,aAA4B,EACT,aAAqC;QAEzE,KAAK,EAAE,CAAC;QALS,iBAAY,GAAZ,YAAY,CAAc;QAC1B,WAAM,GAAN,MAAM,CAAmB;QACzB,kBAAa,GAAb,aAAa,CAAe;QAI7C,IAAI,CAAC,MAAM,GAAG,aAAa,IAAI,iDAAsB,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAkB,KAA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