@carlonicora/nestjs-neo4jsonapi 7.1.0 → 8.0.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.
- package/dist/bootstrap/app.module.factory.d.ts.map +1 -1
- package/dist/bootstrap/app.module.factory.js +1 -0
- package/dist/bootstrap/app.module.factory.js.map +1 -1
- package/dist/bootstrap/bootstrap.options.d.ts +20 -0
- package/dist/bootstrap/bootstrap.options.d.ts.map +1 -1
- package/dist/core/email/templates/en/cardExpiring.hbs +28 -0
- package/dist/core/email/templates/en/paymentFailure.hbs +4 -0
- package/dist/foundations/billing/billing.module.d.ts +26 -0
- package/dist/foundations/billing/billing.module.d.ts.map +1 -0
- package/dist/foundations/billing/billing.module.js +74 -0
- package/dist/foundations/billing/billing.module.js.map +1 -0
- package/dist/foundations/billing/cron/billing-lifecycle.cron.d.ts +16 -0
- package/dist/foundations/billing/cron/billing-lifecycle.cron.d.ts.map +1 -0
- package/dist/foundations/billing/cron/billing-lifecycle.cron.js +52 -0
- package/dist/foundations/billing/cron/billing-lifecycle.cron.js.map +1 -0
- package/dist/foundations/billing/index.d.ts +7 -0
- package/dist/foundations/billing/index.d.ts.map +1 -0
- package/dist/foundations/billing/index.js +28 -0
- package/dist/foundations/billing/index.js.map +1 -0
- package/dist/foundations/billing/interfaces/billing.config.interface.d.ts +71 -0
- package/dist/foundations/billing/interfaces/billing.config.interface.d.ts.map +1 -0
- package/dist/foundations/billing/interfaces/billing.config.interface.js +41 -0
- package/dist/foundations/billing/interfaces/billing.config.interface.js.map +1 -0
- package/dist/foundations/billing/processors/billing-email.jobs.d.ts +127 -0
- package/dist/foundations/billing/processors/billing-email.jobs.d.ts.map +1 -0
- package/dist/foundations/billing/processors/billing-email.jobs.js +196 -0
- package/dist/foundations/billing/processors/billing-email.jobs.js.map +1 -0
- package/dist/foundations/billing/processors/billing-email.processor.d.ts +33 -0
- package/dist/foundations/billing/processors/billing-email.processor.d.ts.map +1 -0
- package/dist/foundations/billing/processors/billing-email.processor.js +95 -0
- package/dist/foundations/billing/processors/billing-email.processor.js.map +1 -0
- package/dist/foundations/billing/services/card-expiry-warning.service.d.ts +58 -0
- package/dist/foundations/billing/services/card-expiry-warning.service.d.ts.map +1 -0
- package/dist/foundations/billing/services/card-expiry-warning.service.js +90 -0
- package/dist/foundations/billing/services/card-expiry-warning.service.js.map +1 -0
- package/dist/foundations/company/repositories/company.repository.d.ts +2 -0
- package/dist/foundations/company/repositories/company.repository.d.ts.map +1 -1
- package/dist/foundations/company/repositories/company.repository.js +2 -2
- package/dist/foundations/company/repositories/company.repository.js.map +1 -1
- package/dist/foundations/foundations.modules.d.ts +3 -0
- package/dist/foundations/foundations.modules.d.ts.map +1 -1
- package/dist/foundations/foundations.modules.js +3 -1
- package/dist/foundations/foundations.modules.js.map +1 -1
- package/dist/foundations/index.d.ts +1 -0
- package/dist/foundations/index.d.ts.map +1 -1
- package/dist/foundations/index.js +1 -0
- package/dist/foundations/index.js.map +1 -1
- package/dist/foundations/stripe-customer/services/stripe-customer-api.service.d.ts +17 -0
- package/dist/foundations/stripe-customer/services/stripe-customer-api.service.d.ts.map +1 -1
- package/dist/foundations/stripe-customer/services/stripe-customer-api.service.js +40 -0
- package/dist/foundations/stripe-customer/services/stripe-customer-api.service.js.map +1 -1
- package/dist/foundations/stripe-invoice/entities/stripe-invoice.entity.d.ts +1 -1
- package/dist/foundations/stripe-invoice/entities/stripe-invoice.entity.d.ts.map +1 -1
- package/dist/foundations/stripe-invoice/serialisers/stripe-invoice.serialiser.js +2 -2
- package/dist/foundations/stripe-invoice/serialisers/stripe-invoice.serialiser.js.map +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.d.ts +13 -0
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.d.ts.map +1 -1
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.js +21 -0
- package/dist/foundations/stripe-invoice/services/stripe-invoice-api.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts +1 -3
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js +5 -38
- package/dist/foundations/stripe-subscription/controllers/stripe-subscription.controller.js.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.d.ts +60 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.d.ts.map +1 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.d.ts +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.discount.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.js +61 -0
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.js.map +1 -0
- package/dist/foundations/stripe-subscription/index.d.ts +1 -4
- package/dist/foundations/stripe-subscription/index.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/index.js +4 -8
- package/dist/foundations/stripe-subscription/index.js.map +1 -1
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.d.ts +93 -165
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.js +206 -274
- package/dist/foundations/stripe-subscription/repositories/stripe-subscription.repository.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts +34 -36
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js +20 -72
- package/dist/foundations/stripe-subscription/services/stripe-subscription-admin.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts +1 -29
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js +1 -53
- package/dist/foundations/stripe-subscription/services/stripe-subscription-api.service.js.map +1 -1
- package/dist/foundations/stripe-subscription/stripe-subscription.module.d.ts +3 -3
- package/dist/foundations/stripe-subscription/stripe-subscription.module.d.ts.map +1 -1
- package/dist/foundations/stripe-subscription/stripe-subscription.module.js +8 -7
- package/dist/foundations/stripe-subscription/stripe-subscription.module.js.map +1 -1
- package/dist/foundations/stripe-usage/entities/stripe-usage-record.entity.d.ts +1 -1
- package/dist/foundations/stripe-usage/entities/stripe-usage-record.entity.d.ts.map +1 -1
- package/dist/foundations/stripe-usage/serialisers/stripe-usage-record.serialiser.js +2 -2
- package/dist/foundations/stripe-usage/serialisers/stripe-usage-record.serialiser.js.map +1 -1
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.d.ts +6 -1
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.d.ts.map +1 -1
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.js +73 -15
- package/dist/foundations/stripe-webhook/processors/stripe-webhook.processor.js.map +1 -1
- package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.d.ts +24 -2
- package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.d.ts.map +1 -1
- package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.js +88 -20
- package/dist/foundations/stripe-webhook/services/stripe-webhook-notification.service.js.map +1 -1
- package/package.json +1 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.d.ts +0 -27
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.d.ts.map +0 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.js +0 -3
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.entity.js.map +0 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.d.ts +0 -8
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.d.ts.map +0 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.js +0 -30
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.map.js.map +0 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.d.ts +0 -4
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.d.ts.map +0 -1
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.js +0 -17
- package/dist/foundations/stripe-subscription/entities/stripe-subscription.model.js.map +0 -1
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.d.ts +0 -9
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.d.ts.map +0 -1
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.js +0 -59
- package/dist/foundations/stripe-subscription/serialisers/stripe-subscription.serialiser.js.map +0 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LIBRARY_BILLING_EMAIL_JOBS = void 0;
|
|
4
|
+
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;gB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a,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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AoDjC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
2
|
+
import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service";
|
|
3
|
+
import { AbstractService } from "../../../core/neo4j/abstracts/abstract.service";
|
|
4
|
+
import { StripeCustomerApiService } from "../../stripe-customer/services/stripe-customer-api.service";
|
|
5
|
+
import { StripeSubscription, StripeSubscriptionDescriptor } from "../../stripe-subscription/entities/stripe-subscription";
|
|
6
|
+
import { StripeSubscriptionRepository } from "../../stripe-subscription/repositories/stripe-subscription.repository";
|
|
7
|
+
import { StripeWebhookNotificationService } from "../../stripe-webhook/services/stripe-webhook-notification.service";
|
|
8
|
+
/**
|
|
9
|
+
* Warns a GM about a week before renewal when the card on file expires before the renewal date.
|
|
10
|
+
*
|
|
11
|
+
* Worker cron only: the repository finder reads across every company. Each subscription is
|
|
12
|
+
* checked once per renewal (`cardExpiryCheckedFor` stores the `currentPeriodEnd` it ran for).
|
|
13
|
+
* A Stripe error leaves the subscription unmarked, so the next hourly run tries again.
|
|
14
|
+
*/
|
|
15
|
+
export declare class CardExpiryWarningService extends AbstractService<StripeSubscription, typeof StripeSubscriptionDescriptor.relationships> {
|
|
16
|
+
private readonly stripeSubscriptionRepository;
|
|
17
|
+
private readonly stripeCustomerApiService;
|
|
18
|
+
private readonly notificationService;
|
|
19
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<StripeSubscription, {
|
|
20
|
+
stripeCustomer: {
|
|
21
|
+
model: import("../../..").DataMeta;
|
|
22
|
+
direction: "out";
|
|
23
|
+
relationship: string;
|
|
24
|
+
cardinality: "one";
|
|
25
|
+
required: true;
|
|
26
|
+
dtoKey: string;
|
|
27
|
+
};
|
|
28
|
+
stripePrice: {
|
|
29
|
+
model: import("../../..").DataMeta;
|
|
30
|
+
direction: "out";
|
|
31
|
+
relationship: string;
|
|
32
|
+
cardinality: "one";
|
|
33
|
+
required: true;
|
|
34
|
+
dtoKey: string;
|
|
35
|
+
};
|
|
36
|
+
createdBy: {
|
|
37
|
+
model: import("../../..").DataMeta;
|
|
38
|
+
direction: "out";
|
|
39
|
+
relationship: string;
|
|
40
|
+
cardinality: "one";
|
|
41
|
+
required: false;
|
|
42
|
+
contextKey: string;
|
|
43
|
+
immutable: true;
|
|
44
|
+
dtoKey: string;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
private readonly logger;
|
|
48
|
+
constructor(jsonApiService: JsonApiService, stripeSubscriptionRepository: StripeSubscriptionRepository, clsService: ClsService, stripeCustomerApiService: StripeCustomerApiService, notificationService: StripeWebhookNotificationService);
|
|
49
|
+
processDue(params: {
|
|
50
|
+
now: Date;
|
|
51
|
+
}): Promise<{
|
|
52
|
+
checked: number;
|
|
53
|
+
warned: number;
|
|
54
|
+
}>;
|
|
55
|
+
/** A card is valid through the last day of its expiry month (UTC): this is the first instant after it. */
|
|
56
|
+
private firstMomentAfterExpiry;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=card-expiry-warning.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-expiry-warning.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/billing/services/card-expiry-warning.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,4DAA4D,CAAC;AACtG,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uEAAuE,CAAC;AACrH,OAAO,EAAE,gCAAgC,EAAE,MAAM,mEAAmE,CAAC;AAIrH;;;;;;GAMG;AACH,qBACa,wBAAyB,SAAQ,eAAe,CAC3D,kBAAkB,EAClB,OAAO,4BAA4B,CAAC,aAAa,CAClD;IAMG,OAAO,CAAC,QAAQ,CAAC,4BAA4B;IAE7C,OAAO,CAAC,QAAQ,CAAC,wBAAwB;IACzC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IARtC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAgC;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqD;gBAG1E,cAAc,EAAE,cAAc,EACb,4BAA4B,EAAE,4BAA4B,EAC3E,UAAU,EAAE,UAAU,EACL,wBAAwB,EAAE,wBAAwB,EAClD,mBAAmB,EAAE,gCAAgC;IAKlE,UAAU,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,IAAI,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA8CrF,0GAA0G;IAC1G,OAAO,CAAC,sBAAsB;CAI/B"}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 CardExpiryWarningService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CardExpiryWarningService = void 0;
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
16
|
+
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
17
|
+
const abstract_service_1 = require("../../../core/neo4j/abstracts/abstract.service");
|
|
18
|
+
const stripe_customer_api_service_1 = require("../../stripe-customer/services/stripe-customer-api.service");
|
|
19
|
+
const stripe_subscription_1 = require("../../stripe-subscription/entities/stripe-subscription");
|
|
20
|
+
const stripe_subscription_repository_1 = require("../../stripe-subscription/repositories/stripe-subscription.repository");
|
|
21
|
+
const stripe_webhook_notification_service_1 = require("../../stripe-webhook/services/stripe-webhook-notification.service");
|
|
22
|
+
const WARNING_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;
|
|
23
|
+
/**
|
|
24
|
+
* Warns a GM about a week before renewal when the card on file expires before the renewal date.
|
|
25
|
+
*
|
|
26
|
+
* Worker cron only: the repository finder reads across every company. Each subscription is
|
|
27
|
+
* checked once per renewal (`cardExpiryCheckedFor` stores the `currentPeriodEnd` it ran for).
|
|
28
|
+
* A Stripe error leaves the subscription unmarked, so the next hourly run tries again.
|
|
29
|
+
*/
|
|
30
|
+
let CardExpiryWarningService = CardExpiryWarningService_1 = class CardExpiryWarningService extends abstract_service_1.AbstractService {
|
|
31
|
+
constructor(jsonApiService, stripeSubscriptionRepository, clsService, stripeCustomerApiService, notificationService) {
|
|
32
|
+
super(jsonApiService, stripeSubscriptionRepository, clsService, stripe_subscription_1.StripeSubscriptionDescriptor.model);
|
|
33
|
+
this.stripeSubscriptionRepository = stripeSubscriptionRepository;
|
|
34
|
+
this.stripeCustomerApiService = stripeCustomerApiService;
|
|
35
|
+
this.notificationService = notificationService;
|
|
36
|
+
this.descriptor = stripe_subscription_1.StripeSubscriptionDescriptor;
|
|
37
|
+
this.logger = new common_1.Logger(CardExpiryWarningService_1.name);
|
|
38
|
+
}
|
|
39
|
+
async processDue(params) {
|
|
40
|
+
const subscriptions = await this.stripeSubscriptionRepository.findRenewalsForCardCheck({
|
|
41
|
+
now: params.now,
|
|
42
|
+
before: new Date(params.now.getTime() + WARNING_WINDOW_MS),
|
|
43
|
+
});
|
|
44
|
+
let checked = 0;
|
|
45
|
+
let warned = 0;
|
|
46
|
+
for (const subscription of subscriptions) {
|
|
47
|
+
try {
|
|
48
|
+
const renewalDate = new Date(subscription.currentPeriodEnd);
|
|
49
|
+
const stripeCustomerId = subscription.stripeCustomer.stripeCustomerId;
|
|
50
|
+
const card = await this.stripeCustomerApiService.getDefaultCard({
|
|
51
|
+
stripeCustomerId,
|
|
52
|
+
stripeSubscriptionId: subscription.stripeSubscriptionId,
|
|
53
|
+
});
|
|
54
|
+
if (card && renewalDate.getTime() >= this.firstMomentAfterExpiry(card).getTime()) {
|
|
55
|
+
await this.notificationService.sendCardExpiringEmail({
|
|
56
|
+
stripeCustomerId,
|
|
57
|
+
renewalDate: subscription.currentPeriodEnd,
|
|
58
|
+
cardBrand: card.brand,
|
|
59
|
+
cardLast4: card.last4,
|
|
60
|
+
});
|
|
61
|
+
warned++;
|
|
62
|
+
}
|
|
63
|
+
await this.stripeSubscriptionRepository.update({
|
|
64
|
+
id: subscription.id,
|
|
65
|
+
cardExpiryCheckedFor: subscription.currentPeriodEnd,
|
|
66
|
+
});
|
|
67
|
+
checked++;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
this.logger.error(`Card expiry check failed for subscription ${subscription.id}; retrying next run: ${error instanceof Error ? error.message : String(error)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return { checked, warned };
|
|
74
|
+
}
|
|
75
|
+
/** A card is valid through the last day of its expiry month (UTC): this is the first instant after it. */
|
|
76
|
+
firstMomentAfterExpiry(card) {
|
|
77
|
+
// Date.UTC months are 0-based, so `expMonth` (1-based) is already the following month.
|
|
78
|
+
return new Date(Date.UTC(card.expYear, card.expMonth, 1));
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
exports.CardExpiryWarningService = CardExpiryWarningService;
|
|
82
|
+
exports.CardExpiryWarningService = CardExpiryWarningService = CardExpiryWarningService_1 = __decorate([
|
|
83
|
+
(0, common_1.Injectable)(),
|
|
84
|
+
__metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
|
|
85
|
+
stripe_subscription_repository_1.StripeSubscriptionRepository,
|
|
86
|
+
nestjs_cls_1.ClsService,
|
|
87
|
+
stripe_customer_api_service_1.StripeCustomerApiService,
|
|
88
|
+
stripe_webhook_notification_service_1.StripeWebhookNotificationService])
|
|
89
|
+
], CardExpiryWarningService);
|
|
90
|
+
//# sourceMappingURL=card-expiry-warning.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"card-expiry-warning.service.js","sourceRoot":"","sources":["../../../../src/foundations/billing/services/card-expiry-warning.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAAwC;AACxC,oFAAgF;AAChF,qFAAiF;AACjF,4GAAsG;AACtG,gGAGgE;AAChE,0HAAqH;AACrH,2HAAqH;AAErH,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAElD;;;;;;GAMG;AAEI,IAAM,wBAAwB,gCAA9B,MAAM,wBAAyB,SAAQ,kCAG7C;IAIC,YACE,cAA8B,EACb,4BAA0D,EAC3E,UAAsB,EACL,wBAAkD,EAClD,mBAAqD;QAEtE,KAAK,CAAC,cAAc,EAAE,4BAA4B,EAAE,UAAU,EAAE,kDAA4B,CAAC,KAAK,CAAC,CAAC;QALnF,iCAA4B,GAA5B,4BAA4B,CAA8B;QAE1D,6BAAwB,GAAxB,wBAAwB,CAA0B;QAClD,wBAAmB,GAAnB,mBAAmB,CAAkC;QARrD,eAAU,GAAG,kDAA4B,CAAC;QAC5C,WAAM,GAAW,IAAI,eAAM,CAAC,0BAAwB,CAAC,IAAI,CAAC,CAAC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AAC;YACZ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,6CAA6C,YAAY,CAAC,EAAE,wBAC1D,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CACvD,EAAE,CACH,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAC7B,CAAC;IAED,0GAA0G;IAClG,sBAAsB,CAAC,IAA2C;QACxE,uFAAuF;QACvF,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF,CAAA;AApEY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,mBAAU,GAAE;qCASO,gCAAc;QACiB,6DAA4B;QAC/D,uBAAU;QACqB,sDAAwB;QAC7B,sEAAgC;GAZ7D,wBAAwB,CAoEpC"}
|
|
@@ -209,6 +209,8 @@ export declare class CompanyRepository extends AbstractRepository<Company, typeo
|
|
|
209
209
|
companyId: string;
|
|
210
210
|
endDate: Date;
|
|
211
211
|
reason: "trial_expired" | "subscription_cancelled";
|
|
212
|
+
/** Days between the end date and the deletion date. Defaults to 30. */
|
|
213
|
+
delayDays?: number;
|
|
212
214
|
}): Promise<void>;
|
|
213
215
|
clearDeletionSchedule(params: {
|
|
214
216
|
companyId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"company.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/company/repositories/company.repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC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C,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAuBtF,iBAAiB,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBjE,uBAAuB,CAAC,MAAM,EAAE;QACpC,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,IAAI,CAAC;QACd,MAAM,EAAE,eAAe,GAAG,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"company.repository.d.ts","sourceRoot":"","sources":["../../../../src/foundations/company/repositories/company.repository.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAK5E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBACa,iBAAkB,SAAQ,kBAAkB,CAAC,OAAO,EAAE,OAAO,iBAAiB,CAAC,aAAa,CAAC;IACxG,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;;OAAqB;gBAEtC,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU;IAQnF,QAAQ,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAW9B,eAAe,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBhE,WAAW,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAajD,UAAU,IAAI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;;;;OAMG;IACG,kBAAkB,CAAC,MAAM,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAenF;;;;;;OAMG;IACG,eAAe,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBzF;;;;;;OAMG;IACG,eAAe,CAAC,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBrF"}
|
|
@@ -577,9 +577,9 @@ let CompanyRepository = class CompanyRepository extends abstract_repository_1.Ab
|
|
|
577
577
|
return result?.userCount || 0;
|
|
578
578
|
}
|
|
579
579
|
async scheduleCompanyDeletion(params) {
|
|
580
|
-
const { companyId, endDate, reason } = params;
|
|
580
|
+
const { companyId, endDate, reason, delayDays = 30 } = params;
|
|
581
581
|
const scheduledDeletionAt = new Date(endDate);
|
|
582
|
-
scheduledDeletionAt.setDate(scheduledDeletionAt.getDate() +
|
|
582
|
+
scheduledDeletionAt.setDate(scheduledDeletionAt.getDate() + delayDays);
|
|
583
583
|
const query = this.neo4j.initQuery();
|
|
584
584
|
query.queryParams = {
|
|
585
585
|
companyId,
|