@agentforge-io/nest 2.0.21 → 2.0.23
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/modules/public-chat/public-chat.controller.js +0 -12
- package/dist/modules/public-chat/public-chat.controller.js.map +1 -1
- package/dist/providers/services.providers.js +16 -3
- package/dist/providers/services.providers.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/dist/database/entities/auth-identity.entity.d.ts +0 -1
- package/dist/database/entities/auth-identity.entity.js +0 -6
- package/dist/database/entities/auth-identity.entity.js.map +0 -1
- package/dist/database/entities/conversation.entity.d.ts +0 -1
- package/dist/database/entities/conversation.entity.js +0 -6
- package/dist/database/entities/conversation.entity.js.map +0 -1
- package/dist/database/entities/email-token.entity.d.ts +0 -1
- package/dist/database/entities/email-token.entity.js +0 -6
- package/dist/database/entities/email-token.entity.js.map +0 -1
- package/dist/database/entities/index.d.ts +0 -7
- package/dist/database/entities/index.js +0 -16
- package/dist/database/entities/index.js.map +0 -1
- package/dist/database/entities/message.entity.d.ts +0 -1
- package/dist/database/entities/message.entity.js +0 -6
- package/dist/database/entities/message.entity.js.map +0 -1
- package/dist/database/entities/refresh-token.entity.d.ts +0 -1
- package/dist/database/entities/refresh-token.entity.js +0 -6
- package/dist/database/entities/refresh-token.entity.js.map +0 -1
- package/dist/database/entities/subscription.entity.d.ts +0 -1
- package/dist/database/entities/subscription.entity.js +0 -6
- package/dist/database/entities/subscription.entity.js.map +0 -1
- package/dist/database/entities/usage-record.entity.d.ts +0 -1
- package/dist/database/entities/usage-record.entity.js +0 -6
- package/dist/database/entities/usage-record.entity.js.map +0 -1
- package/dist/database/entities/user.entity.d.ts +0 -1
- package/dist/database/entities/user.entity.js +0 -6
- package/dist/database/entities/user.entity.js.map +0 -1
- package/dist/decorators/require-plan.decorator.d.ts +0 -2
- package/dist/decorators/require-plan.decorator.js +0 -8
- package/dist/decorators/require-plan.decorator.js.map +0 -1
- package/dist/guards/usage-limit.guard.d.ts +0 -11
- package/dist/guards/usage-limit.guard.js +0 -57
- package/dist/guards/usage-limit.guard.js.map +0 -1
- package/dist/modules/admin/admin-plans.controller.d.ts +0 -11
- package/dist/modules/admin/admin-plans.controller.js +0 -97
- package/dist/modules/admin/admin-plans.controller.js.map +0 -1
- package/dist/modules/admin/admin-tenant-agents.controller.d.ts +0 -61
- package/dist/modules/admin/admin-tenant-agents.controller.js +0 -424
- package/dist/modules/admin/admin-tenant-agents.controller.js.map +0 -1
- package/dist/modules/admin/admin-tenant-billing.controller.d.ts +0 -51
- package/dist/modules/admin/admin-tenant-billing.controller.js +0 -119
- package/dist/modules/admin/admin-tenant-billing.controller.js.map +0 -1
- package/dist/modules/admin/admin-tenants.controller.d.ts +0 -43
- package/dist/modules/admin/admin-tenants.controller.js +0 -178
- package/dist/modules/admin/admin-tenants.controller.js.map +0 -1
- package/dist/modules/admin/admin-users.controller.d.ts +0 -41
- package/dist/modules/admin/admin-users.controller.js +0 -121
- package/dist/modules/admin/admin-users.controller.js.map +0 -1
- package/dist/modules/admin/admin.module.d.ts +0 -2
- package/dist/modules/admin/admin.module.js +0 -26
- package/dist/modules/admin/admin.module.js.map +0 -1
- package/dist/modules/admin/platform-admin.guard.d.ts +0 -7
- package/dist/modules/admin/platform-admin.guard.js +0 -52
- package/dist/modules/admin/platform-admin.guard.js.map +0 -1
- package/dist/modules/auth/auth.controller.d.ts +0 -63
- package/dist/modules/auth/auth.controller.js +0 -255
- package/dist/modules/auth/auth.controller.js.map +0 -1
- package/dist/modules/auth/auth.module.d.ts +0 -4
- package/dist/modules/auth/auth.module.js +0 -71
- package/dist/modules/auth/auth.module.js.map +0 -1
- package/dist/modules/auth/auth.service.d.ts +0 -2
- package/dist/modules/auth/auth.service.js +0 -7
- package/dist/modules/auth/auth.service.js.map +0 -1
- package/dist/modules/auth/decorators/current-user.decorator.d.ts +0 -8
- package/dist/modules/auth/decorators/current-user.decorator.js +0 -12
- package/dist/modules/auth/decorators/current-user.decorator.js.map +0 -1
- package/dist/modules/auth/decorators/public.decorator.d.ts +0 -2
- package/dist/modules/auth/decorators/public.decorator.js +0 -8
- package/dist/modules/auth/decorators/public.decorator.js.map +0 -1
- package/dist/modules/auth/dto/login.dto.d.ts +0 -4
- package/dist/modules/auth/dto/login.dto.js +0 -29
- package/dist/modules/auth/dto/login.dto.js.map +0 -1
- package/dist/modules/auth/dto/register.dto.d.ts +0 -5
- package/dist/modules/auth/dto/register.dto.js +0 -36
- package/dist/modules/auth/dto/register.dto.js.map +0 -1
- package/dist/modules/auth/guards/jwt-auth.guard.d.ts +0 -9
- package/dist/modules/auth/guards/jwt-auth.guard.js +0 -37
- package/dist/modules/auth/guards/jwt-auth.guard.js.map +0 -1
- package/dist/modules/auth/guards/local-auth.guard.d.ts +0 -4
- package/dist/modules/auth/guards/local-auth.guard.js +0 -18
- package/dist/modules/auth/guards/local-auth.guard.js.map +0 -1
- package/dist/modules/auth/guards/oauth-configured.guard.d.ts +0 -11
- package/dist/modules/auth/guards/oauth-configured.guard.js +0 -51
- package/dist/modules/auth/guards/oauth-configured.guard.js.map +0 -1
- package/dist/modules/auth/oauth.controller.d.ts +0 -20
- package/dist/modules/auth/oauth.controller.js +0 -208
- package/dist/modules/auth/oauth.controller.js.map +0 -1
- package/dist/modules/auth/refresh-token.service.d.ts +0 -2
- package/dist/modules/auth/refresh-token.service.js +0 -7
- package/dist/modules/auth/refresh-token.service.js.map +0 -1
- package/dist/modules/auth/strategies/github.strategy.d.ts +0 -12
- package/dist/modules/auth/strategies/github.strategy.js +0 -57
- package/dist/modules/auth/strategies/github.strategy.js.map +0 -1
- package/dist/modules/auth/strategies/google.strategy.d.ts +0 -19
- package/dist/modules/auth/strategies/google.strategy.js +0 -56
- package/dist/modules/auth/strategies/google.strategy.js.map +0 -1
- package/dist/modules/auth/strategies/jwt.strategy.d.ts +0 -18
- package/dist/modules/auth/strategies/jwt.strategy.js +0 -49
- package/dist/modules/auth/strategies/jwt.strategy.js.map +0 -1
- package/dist/modules/auth/strategies/local.strategy.d.ts +0 -11
- package/dist/modules/auth/strategies/local.strategy.js +0 -31
- package/dist/modules/auth/strategies/local.strategy.js.map +0 -1
- package/dist/modules/billing/adapters/billing-adapter.interface.d.ts +0 -1
- package/dist/modules/billing/adapters/billing-adapter.interface.js +0 -6
- package/dist/modules/billing/adapters/billing-adapter.interface.js.map +0 -1
- package/dist/modules/billing/adapters/stripe/stripe.adapter.d.ts +0 -19
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js +0 -118
- package/dist/modules/billing/adapters/stripe/stripe.adapter.js.map +0 -1
- package/dist/modules/billing/billing.controller.d.ts +0 -54
- package/dist/modules/billing/billing.controller.js +0 -180
- package/dist/modules/billing/billing.controller.js.map +0 -1
- package/dist/modules/billing/billing.module.d.ts +0 -2
- package/dist/modules/billing/billing.module.js +0 -57
- package/dist/modules/billing/billing.module.js.map +0 -1
- package/dist/modules/billing/billing.service.d.ts +0 -2
- package/dist/modules/billing/billing.service.js +0 -7
- package/dist/modules/billing/billing.service.js.map +0 -1
- package/dist/modules/billing/usage.service.d.ts +0 -2
- package/dist/modules/billing/usage.service.js +0 -6
- package/dist/modules/billing/usage.service.js.map +0 -1
- package/dist/modules/email/adapters/email-adapter.interface.d.ts +0 -1
- package/dist/modules/email/adapters/email-adapter.interface.js +0 -6
- package/dist/modules/email/adapters/email-adapter.interface.js.map +0 -1
- package/dist/modules/email/adapters/noop.adapter.d.ts +0 -1
- package/dist/modules/email/adapters/noop.adapter.js +0 -6
- package/dist/modules/email/adapters/noop.adapter.js.map +0 -1
- package/dist/modules/email/adapters/resend.adapter.d.ts +0 -1
- package/dist/modules/email/adapters/resend.adapter.js +0 -6
- package/dist/modules/email/adapters/resend.adapter.js.map +0 -1
- package/dist/modules/email/email.module.d.ts +0 -2
- package/dist/modules/email/email.module.js +0 -17
- package/dist/modules/email/email.module.js.map +0 -1
- package/dist/modules/email/email.service.d.ts +0 -1
- package/dist/modules/email/email.service.js +0 -6
- package/dist/modules/email/email.service.js.map +0 -1
- package/dist/modules/email/templates/transactional.template.d.ts +0 -18
- package/dist/modules/email/templates/transactional.template.js +0 -43
- package/dist/modules/email/templates/transactional.template.js.map +0 -1
|
@@ -1,118 +0,0 @@
|
|
|
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 StripeAdapter_1;
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.StripeAdapter = void 0;
|
|
14
|
-
const common_1 = require("@nestjs/common");
|
|
15
|
-
const stripe_1 = require("stripe");
|
|
16
|
-
let StripeAdapter = StripeAdapter_1 = class StripeAdapter {
|
|
17
|
-
constructor(config, plans = []) {
|
|
18
|
-
this.logger = new common_1.Logger(StripeAdapter_1.name);
|
|
19
|
-
this.stripe = new stripe_1.default(config.secretKey, {
|
|
20
|
-
apiVersion: '2023-10-16',
|
|
21
|
-
});
|
|
22
|
-
this.plans = plans;
|
|
23
|
-
}
|
|
24
|
-
async createCustomer(params) {
|
|
25
|
-
const customer = await this.stripe.customers.create({
|
|
26
|
-
email: params.email,
|
|
27
|
-
name: params.name,
|
|
28
|
-
metadata: params.metadata ?? {},
|
|
29
|
-
});
|
|
30
|
-
this.logger.debug(`Created Stripe customer: ${customer.id}`);
|
|
31
|
-
return customer.id;
|
|
32
|
-
}
|
|
33
|
-
async createCheckoutSession(params) {
|
|
34
|
-
const plan = this.plans.find((p) => p.id === params.planId);
|
|
35
|
-
if (!plan?.stripePriceId) {
|
|
36
|
-
throw new Error(`Plan "${params.planId}" has no Stripe price ID configured`);
|
|
37
|
-
}
|
|
38
|
-
const session = await this.stripe.checkout.sessions.create({
|
|
39
|
-
mode: plan.interval ? 'subscription' : 'payment',
|
|
40
|
-
payment_method_types: ['card'],
|
|
41
|
-
line_items: [{ price: plan.stripePriceId, quantity: 1 }],
|
|
42
|
-
success_url: params.successUrl,
|
|
43
|
-
cancel_url: params.cancelUrl,
|
|
44
|
-
metadata: {
|
|
45
|
-
userId: params.userId,
|
|
46
|
-
planId: params.planId,
|
|
47
|
-
...params.metadata,
|
|
48
|
-
},
|
|
49
|
-
subscription_data: plan.interval
|
|
50
|
-
? { metadata: { userId: params.userId, planId: params.planId } }
|
|
51
|
-
: undefined,
|
|
52
|
-
});
|
|
53
|
-
return { sessionId: session.id, url: session.url };
|
|
54
|
-
}
|
|
55
|
-
async createSubscription(params) {
|
|
56
|
-
const subscription = await this.stripe.subscriptions.create({
|
|
57
|
-
customer: params.customerId,
|
|
58
|
-
items: [{ price: params.priceId }],
|
|
59
|
-
trial_period_days: params.trialDays,
|
|
60
|
-
payment_behavior: 'default_incomplete',
|
|
61
|
-
expand: ['latest_invoice.payment_intent'],
|
|
62
|
-
});
|
|
63
|
-
return {
|
|
64
|
-
subscriptionId: subscription.id,
|
|
65
|
-
status: subscription.status,
|
|
66
|
-
currentPeriodEnd: new Date(subscription.current_period_end * 1000),
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
async cancelSubscription(subscriptionId, atPeriodEnd = true) {
|
|
70
|
-
if (atPeriodEnd) {
|
|
71
|
-
await this.stripe.subscriptions.update(subscriptionId, {
|
|
72
|
-
cancel_at_period_end: true,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
await this.stripe.subscriptions.cancel(subscriptionId);
|
|
77
|
-
}
|
|
78
|
-
this.logger.log(`Subscription ${subscriptionId} cancelled (atPeriodEnd=${atPeriodEnd})`);
|
|
79
|
-
}
|
|
80
|
-
async getSubscription(subscriptionId) {
|
|
81
|
-
const sub = await this.stripe.subscriptions.retrieve(subscriptionId);
|
|
82
|
-
return {
|
|
83
|
-
subscriptionId: sub.id,
|
|
84
|
-
status: sub.status,
|
|
85
|
-
currentPeriodEnd: new Date(sub.current_period_end * 1000),
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
async getPortalUrl(customerId, returnUrl) {
|
|
89
|
-
const session = await this.stripe.billingPortal.sessions.create({
|
|
90
|
-
customer: customerId,
|
|
91
|
-
return_url: returnUrl,
|
|
92
|
-
});
|
|
93
|
-
return session.url;
|
|
94
|
-
}
|
|
95
|
-
async handleWebhook(payload, signature) {
|
|
96
|
-
let event;
|
|
97
|
-
try {
|
|
98
|
-
event = this.stripe.webhooks.constructEvent(payload, signature, process.env.STRIPE_WEBHOOK_SECRET ?? '');
|
|
99
|
-
}
|
|
100
|
-
catch (err) {
|
|
101
|
-
throw new Error(`Stripe webhook verification failed: ${err}`);
|
|
102
|
-
}
|
|
103
|
-
this.logger.debug(`Stripe webhook received: ${event.type}`);
|
|
104
|
-
return {
|
|
105
|
-
type: event.type,
|
|
106
|
-
data: event.data.object,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
getStripeInstance() {
|
|
110
|
-
return this.stripe;
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
exports.StripeAdapter = StripeAdapter;
|
|
114
|
-
exports.StripeAdapter = StripeAdapter = StripeAdapter_1 = __decorate([
|
|
115
|
-
(0, common_1.Injectable)(),
|
|
116
|
-
__metadata("design:paramtypes", [Object, Array])
|
|
117
|
-
], StripeAdapter);
|
|
118
|
-
//# sourceMappingURL=stripe.adapter.js.map
|
|
@@ -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CAAC,QAAQ,CAAC,cAAc,CACzC,OAAO,EACP,SAAS,EACT,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CACxC,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAG5D,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,MAAiC;SACnD,CAAC;IACJ,CAAC;IAID,iBAAiB;QACf,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF,CAAA;AAnIY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;;GACA,aAAa,CAmIzB"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { PlanService, UsageService } from '@agentforge/core';
|
|
2
|
-
import { BillingService } from './billing.service';
|
|
3
|
-
export declare class BillingController {
|
|
4
|
-
private readonly billing;
|
|
5
|
-
private readonly usage;
|
|
6
|
-
private readonly plans;
|
|
7
|
-
constructor(billing: BillingService, usage: UsageService, plans: PlanService);
|
|
8
|
-
getPlans(): Promise<import("@agentforge/core").Plan[]>;
|
|
9
|
-
checkoutSuccess(sessionId?: string): {
|
|
10
|
-
status: string;
|
|
11
|
-
message: string;
|
|
12
|
-
sessionId: string | null;
|
|
13
|
-
};
|
|
14
|
-
checkoutCancel(): {
|
|
15
|
-
status: string;
|
|
16
|
-
message: string;
|
|
17
|
-
};
|
|
18
|
-
createCheckout(body: {
|
|
19
|
-
planId: string;
|
|
20
|
-
}, userId: string): Promise<import("@agentforge/core").CheckoutResult>;
|
|
21
|
-
getPortal(body: {
|
|
22
|
-
returnUrl?: string;
|
|
23
|
-
}, userId: string): Promise<import("@agentforge/core").PortalResult>;
|
|
24
|
-
getOverview(userId: string): Promise<import("@agentforge/core").BillingOverviewResult>;
|
|
25
|
-
cancelSubscription(userId: string, body: {
|
|
26
|
-
immediately?: boolean;
|
|
27
|
-
}): Promise<{
|
|
28
|
-
success: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
getMyBilling(userId: string): Promise<{
|
|
31
|
-
plan: {
|
|
32
|
-
id: string;
|
|
33
|
-
name: string;
|
|
34
|
-
features: string[];
|
|
35
|
-
limits: {
|
|
36
|
-
requestsPerMonth: number;
|
|
37
|
-
tokensPerMonth: number;
|
|
38
|
-
};
|
|
39
|
-
priceInCents: number | undefined;
|
|
40
|
-
interval: "month" | "year" | undefined;
|
|
41
|
-
};
|
|
42
|
-
usage: {
|
|
43
|
-
period: string;
|
|
44
|
-
requestCount: number;
|
|
45
|
-
totalTokens: number;
|
|
46
|
-
requestLimit: number;
|
|
47
|
-
tokenLimit: number;
|
|
48
|
-
};
|
|
49
|
-
availablePlans: import("@agentforge/core").Plan[];
|
|
50
|
-
}>;
|
|
51
|
-
handleWebhook(payload: Buffer, signature: string): Promise<{
|
|
52
|
-
received: boolean;
|
|
53
|
-
}>;
|
|
54
|
-
}
|
|
@@ -1,180 +0,0 @@
|
|
|
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.BillingController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const core_1 = require("@agentforge/core");
|
|
19
|
-
const billing_service_1 = require("./billing.service");
|
|
20
|
-
const public_decorator_1 = require("../auth/decorators/public.decorator");
|
|
21
|
-
const current_user_decorator_1 = require("../auth/decorators/current-user.decorator");
|
|
22
|
-
let BillingController = class BillingController {
|
|
23
|
-
constructor(billing, usage, plans) {
|
|
24
|
-
this.billing = billing;
|
|
25
|
-
this.usage = usage;
|
|
26
|
-
this.plans = plans;
|
|
27
|
-
}
|
|
28
|
-
getPlans() {
|
|
29
|
-
return this.billing.getPlans();
|
|
30
|
-
}
|
|
31
|
-
checkoutSuccess(sessionId) {
|
|
32
|
-
return {
|
|
33
|
-
status: 'success',
|
|
34
|
-
message: 'Checkout completed. The subscription will activate once the webhook is processed.',
|
|
35
|
-
sessionId: sessionId ?? null,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
checkoutCancel() {
|
|
39
|
-
return {
|
|
40
|
-
status: 'canceled',
|
|
41
|
-
message: 'Checkout was canceled. No charge was made.',
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
async createCheckout(body, userId) {
|
|
45
|
-
return this.billing.createCheckout({ userId, planId: body.planId });
|
|
46
|
-
}
|
|
47
|
-
async getPortal(body, userId) {
|
|
48
|
-
return this.billing.getPortalUrl(userId, body.returnUrl);
|
|
49
|
-
}
|
|
50
|
-
async getOverview(userId) {
|
|
51
|
-
return this.billing.getOverview(userId);
|
|
52
|
-
}
|
|
53
|
-
async cancelSubscription(userId, body) {
|
|
54
|
-
await this.billing.cancelSubscription(userId, body.immediately);
|
|
55
|
-
return { success: true };
|
|
56
|
-
}
|
|
57
|
-
async getMyBilling(userId) {
|
|
58
|
-
const summary = await this.usage.getSummary(userId);
|
|
59
|
-
const allPlans = await this.plans.list();
|
|
60
|
-
const plan = allPlans.find((p) => p.id === summary.planId);
|
|
61
|
-
return {
|
|
62
|
-
plan: {
|
|
63
|
-
id: summary.planId,
|
|
64
|
-
name: plan?.name ?? summary.planId,
|
|
65
|
-
features: plan?.features ?? [],
|
|
66
|
-
limits: {
|
|
67
|
-
requestsPerMonth: summary.requestsLimit,
|
|
68
|
-
tokensPerMonth: summary.tokensLimit,
|
|
69
|
-
},
|
|
70
|
-
priceInCents: plan?.priceInCents,
|
|
71
|
-
interval: plan?.interval,
|
|
72
|
-
},
|
|
73
|
-
usage: {
|
|
74
|
-
period: summary.periodStart.toISOString().slice(0, 7),
|
|
75
|
-
requestCount: summary.requestsUsed,
|
|
76
|
-
totalTokens: summary.tokensUsed,
|
|
77
|
-
requestLimit: summary.requestsLimit,
|
|
78
|
-
tokenLimit: summary.tokensLimit,
|
|
79
|
-
},
|
|
80
|
-
availablePlans: allPlans,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
async handleWebhook(payload, signature) {
|
|
84
|
-
await this.billing.handleWebhook(payload, signature);
|
|
85
|
-
return { received: true };
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
exports.BillingController = BillingController;
|
|
89
|
-
__decorate([
|
|
90
|
-
(0, public_decorator_1.Public)(),
|
|
91
|
-
(0, common_1.Get)('plans'),
|
|
92
|
-
(0, swagger_1.ApiOperation)({ summary: 'List available plans' }),
|
|
93
|
-
__metadata("design:type", Function),
|
|
94
|
-
__metadata("design:paramtypes", []),
|
|
95
|
-
__metadata("design:returntype", void 0)
|
|
96
|
-
], BillingController.prototype, "getPlans", null);
|
|
97
|
-
__decorate([
|
|
98
|
-
(0, public_decorator_1.Public)(),
|
|
99
|
-
(0, common_1.Get)('success'),
|
|
100
|
-
(0, swagger_1.ApiOperation)({
|
|
101
|
-
summary: 'Default landing for Stripe success redirect (used when no frontend is configured)',
|
|
102
|
-
}),
|
|
103
|
-
__param(0, (0, common_1.Query)('session_id')),
|
|
104
|
-
__metadata("design:type", Function),
|
|
105
|
-
__metadata("design:paramtypes", [String]),
|
|
106
|
-
__metadata("design:returntype", void 0)
|
|
107
|
-
], BillingController.prototype, "checkoutSuccess", null);
|
|
108
|
-
__decorate([
|
|
109
|
-
(0, public_decorator_1.Public)(),
|
|
110
|
-
(0, common_1.Get)('cancel'),
|
|
111
|
-
(0, swagger_1.ApiOperation)({
|
|
112
|
-
summary: 'Default landing for Stripe cancel redirect (used when no frontend is configured)',
|
|
113
|
-
}),
|
|
114
|
-
__metadata("design:type", Function),
|
|
115
|
-
__metadata("design:paramtypes", []),
|
|
116
|
-
__metadata("design:returntype", void 0)
|
|
117
|
-
], BillingController.prototype, "checkoutCancel", null);
|
|
118
|
-
__decorate([
|
|
119
|
-
(0, common_1.Post)('checkout'),
|
|
120
|
-
(0, swagger_1.ApiOperation)({ summary: 'Create a checkout session for the authenticated user' }),
|
|
121
|
-
__param(0, (0, common_1.Body)()),
|
|
122
|
-
__param(1, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
123
|
-
__metadata("design:type", Function),
|
|
124
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
125
|
-
__metadata("design:returntype", Promise)
|
|
126
|
-
], BillingController.prototype, "createCheckout", null);
|
|
127
|
-
__decorate([
|
|
128
|
-
(0, common_1.Post)('portal'),
|
|
129
|
-
(0, swagger_1.ApiOperation)({ summary: 'Get customer portal URL for the authenticated user' }),
|
|
130
|
-
__param(0, (0, common_1.Body)()),
|
|
131
|
-
__param(1, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
132
|
-
__metadata("design:type", Function),
|
|
133
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
134
|
-
__metadata("design:returntype", Promise)
|
|
135
|
-
], BillingController.prototype, "getPortal", null);
|
|
136
|
-
__decorate([
|
|
137
|
-
(0, common_1.Get)('overview'),
|
|
138
|
-
(0, swagger_1.ApiOperation)({ summary: 'Get billing overview for the authenticated user' }),
|
|
139
|
-
__param(0, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
140
|
-
__metadata("design:type", Function),
|
|
141
|
-
__metadata("design:paramtypes", [String]),
|
|
142
|
-
__metadata("design:returntype", Promise)
|
|
143
|
-
], BillingController.prototype, "getOverview", null);
|
|
144
|
-
__decorate([
|
|
145
|
-
(0, common_1.Delete)('subscription'),
|
|
146
|
-
(0, swagger_1.ApiOperation)({ summary: 'Cancel the authenticated user’s subscription' }),
|
|
147
|
-
__param(0, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
148
|
-
__param(1, (0, common_1.Body)()),
|
|
149
|
-
__metadata("design:type", Function),
|
|
150
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
151
|
-
__metadata("design:returntype", Promise)
|
|
152
|
-
], BillingController.prototype, "cancelSubscription", null);
|
|
153
|
-
__decorate([
|
|
154
|
-
(0, common_1.Get)('me'),
|
|
155
|
-
(0, swagger_1.ApiOperation)({
|
|
156
|
-
summary: 'Personal billing overview for the authenticated user — plan, usage, available plans',
|
|
157
|
-
}),
|
|
158
|
-
__param(0, (0, current_user_decorator_1.CurrentUser)('userId')),
|
|
159
|
-
__metadata("design:type", Function),
|
|
160
|
-
__metadata("design:paramtypes", [String]),
|
|
161
|
-
__metadata("design:returntype", Promise)
|
|
162
|
-
], BillingController.prototype, "getMyBilling", null);
|
|
163
|
-
__decorate([
|
|
164
|
-
(0, public_decorator_1.Public)(),
|
|
165
|
-
(0, common_1.Post)('webhook'),
|
|
166
|
-
(0, swagger_1.ApiOperation)({ summary: 'Handle payment provider webhook (signature-verified)' }),
|
|
167
|
-
__param(0, (0, common_1.RawBody)()),
|
|
168
|
-
__param(1, (0, common_1.Headers)('stripe-signature')),
|
|
169
|
-
__metadata("design:type", Function),
|
|
170
|
-
__metadata("design:paramtypes", [Buffer, String]),
|
|
171
|
-
__metadata("design:returntype", Promise)
|
|
172
|
-
], BillingController.prototype, "handleWebhook", null);
|
|
173
|
-
exports.BillingController = BillingController = __decorate([
|
|
174
|
-
(0, swagger_1.ApiTags)('Billing'),
|
|
175
|
-
(0, common_1.Controller)('billing'),
|
|
176
|
-
__metadata("design:paramtypes", [billing_service_1.BillingService,
|
|
177
|
-
core_1.UsageService,
|
|
178
|
-
core_1.PlanService])
|
|
179
|
-
], BillingController);
|
|
180
|
-
//# sourceMappingURL=billing.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"billing.controller.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,6CAAwD;AACxD,2CAA6D;AAC7D,uDAAmD;AACnD,0EAA6D;AAC7D,sFAAwE;AAIjE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC5B,YACmB,OAAuB,EACvB,KAAmB,EACnB,KAAkB;QAFlB,YAAO,GAAP,OAAO,CAAgB;QACvB,UAAK,GAAL,KAAK,CAAc;QACnB,UAAK,GAAL,KAAK,CAAa;IAClC,CAAC;IAKJ,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;IAOD,eAAe,CAAsB,SAAkB;QACrD,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,mFAAmF;YAC5F,SAAS,EAAE,SAAS,IAAI,IAAI;SAC7B,CAAC;IACJ,CAAC;IAOD,cAAc;QACZ,OAAO;YACL,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,4CAA4C;SACtD,CAAC;IACJ,CAAC;IAIK,AAAN,KAAK,CAAC,cAAc,CACV,IAAwB,EACT,MAAc;QAErC,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC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< 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.BillingModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const core_1 = require("@agentforge/core");
|
|
12
|
-
const billing_controller_1 = require("./billing.controller");
|
|
13
|
-
const billing_adapter_interface_1 = require("./adapters/billing-adapter.interface");
|
|
14
|
-
const constants_1 = require("../../constants");
|
|
15
|
-
let BillingModule = class BillingModule {
|
|
16
|
-
};
|
|
17
|
-
exports.BillingModule = BillingModule;
|
|
18
|
-
exports.BillingModule = BillingModule = __decorate([
|
|
19
|
-
(0, common_1.Module)({
|
|
20
|
-
providers: [
|
|
21
|
-
{
|
|
22
|
-
provide: billing_adapter_interface_1.BILLING_ADAPTER,
|
|
23
|
-
inject: [constants_1.AGENT_FORGE_CONFIG],
|
|
24
|
-
useFactory: (config) => {
|
|
25
|
-
if (!config.billing) {
|
|
26
|
-
return new NoopBillingAdapter();
|
|
27
|
-
}
|
|
28
|
-
if (config.billing.provider === 'stripe') {
|
|
29
|
-
if (!config.billing.stripe) {
|
|
30
|
-
throw new Error('Stripe config is required when provider is "stripe"');
|
|
31
|
-
}
|
|
32
|
-
return new core_1.StripeAdapter(config.billing.stripe, config.billing.plans ?? []);
|
|
33
|
-
}
|
|
34
|
-
if (config.billing.provider === 'custom' && config.billing.customAdapter) {
|
|
35
|
-
return new config.billing.customAdapter();
|
|
36
|
-
}
|
|
37
|
-
throw new Error(`Unknown billing provider: ${config.billing.provider}`);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
controllers: [billing_controller_1.BillingController],
|
|
42
|
-
exports: [billing_adapter_interface_1.BILLING_ADAPTER],
|
|
43
|
-
})
|
|
44
|
-
], BillingModule);
|
|
45
|
-
class NoopBillingAdapter {
|
|
46
|
-
error() {
|
|
47
|
-
throw new Error('Billing is not configured. Add a billing config to AgentForgeModule.forRoot()');
|
|
48
|
-
}
|
|
49
|
-
createCheckoutSession() { return this.error(); }
|
|
50
|
-
createSubscription() { return this.error(); }
|
|
51
|
-
cancelSubscription() { return this.error(); }
|
|
52
|
-
handleWebhook() { return this.error(); }
|
|
53
|
-
getPortalUrl() { return this.error(); }
|
|
54
|
-
createCustomer() { return this.error(); }
|
|
55
|
-
getSubscription() { return this.error(); }
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=billing.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"billing.module.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,2CAAiD;AAEjD,6DAAyD;AACzD,oFAAuE;AACvE,+CAAqD;AA2C9C,IAAM,aAAa,GAAnB,MAAM,aAAa;CAAG,CAAA;AAAhB,sCAAa;wBAAb,aAAa;IA5BzB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,2CAAe;gBACxB,MAAM,EAAE,CAAC,8BAAkB,CAAC;gBAC5B,UAAU,EAAE,CAAC,MAAwB,EAAmB,EAAE;oBACxD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;wBACpB,OAAO,IAAI,kBAAkB,EAAE,CAAC;oBAClC,CAAC;oBAED,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;wBACzC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;4BAC3B,MAAM,IAAI,KAAK,CAA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
|
3
|
-
exports.BillingError = exports.BillingService = void 0;
|
|
4
|
-
var core_1 = require("@agentforge/core");
|
|
5
|
-
Object.defineProperty(exports, "BillingService", { enumerable: true, get: function () { return core_1.BillingService; } });
|
|
6
|
-
Object.defineProperty(exports, "BillingError", { enumerable: true, get: function () { return core_1.BillingError; } });
|
|
7
|
-
//# sourceMappingURL=billing.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"billing.service.js","sourceRoot":"","sources":["../../../src/modules/billing/billing.service.ts"],"names":[],"mappings":";;;AAAA,yCAAgE;AAAvD,sGAAA,cAAc,OAAA;AAAE,oGAAA,YAAY,OAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UsageService = void 0;
|
|
4
|
-
var core_1 = require("@agentforge/core");
|
|
5
|
-
Object.defineProperty(exports, "UsageService", { enumerable: true, get: function () { return core_1.UsageService; } });
|
|
6
|
-
//# sourceMappingURL=usage.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usage.service.js","sourceRoot":"","sources":["../../../src/modules/billing/usage.service.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAAvC,oGAAA,YAAY,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { EMAIL_ADAPTER, type EmailAdapter, type EmailMessage, type EmailSendResult, } from '@agentforge/core';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EMAIL_ADAPTER = void 0;
|
|
4
|
-
var core_1 = require("@agentforge/core");
|
|
5
|
-
Object.defineProperty(exports, "EMAIL_ADAPTER", { enumerable: true, get: function () { return core_1.EMAIL_ADAPTER; } });
|
|
6
|
-
//# sourceMappingURL=email-adapter.interface.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email-adapter.interface.js","sourceRoot":"","sources":["../../../../src/modules/email/adapters/email-adapter.interface.ts"],"names":[],"mappings":";;;AAEA,yCAK0B;AAJxB,qGAAA,aAAa,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { NoopEmailAdapter } from '@agentforge/core';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoopEmailAdapter = void 0;
|
|
4
|
-
var core_1 = require("@agentforge/core");
|
|
5
|
-
Object.defineProperty(exports, "NoopEmailAdapter", { enumerable: true, get: function () { return core_1.NoopEmailAdapter; } });
|
|
6
|
-
//# sourceMappingURL=noop.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"noop.adapter.js","sourceRoot":"","sources":["../../../../src/modules/email/adapters/noop.adapter.ts"],"names":[],"mappings":";;;AAAA,yCAAoD;AAA3C,wGAAA,gBAAgB,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ResendAdapter } from '@agentforge/core';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ResendAdapter = void 0;
|
|
4
|
-
var core_1 = require("@agentforge/core");
|
|
5
|
-
Object.defineProperty(exports, "ResendAdapter", { enumerable: true, get: function () { return core_1.ResendAdapter; } });
|
|
6
|
-
//# sourceMappingURL=resend.adapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resend.adapter.js","sourceRoot":"","sources":["../../../../src/modules/email/adapters/resend.adapter.ts"],"names":[],"mappings":";;;AACA,yCAAiD;AAAxC,qGAAA,aAAa,OAAA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.EmailModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
let EmailModule = class EmailModule {
|
|
12
|
-
};
|
|
13
|
-
exports.EmailModule = EmailModule;
|
|
14
|
-
exports.EmailModule = EmailModule = __decorate([
|
|
15
|
-
(0, common_1.Module)({})
|
|
16
|
-
], EmailModule);
|
|
17
|
-
//# sourceMappingURL=email.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.module.js","sourceRoot":"","sources":["../../../src/modules/email/email.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AAOjC,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CAAG"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { EmailService } from '@agentforge/core';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmailService = void 0;
|
|
4
|
-
var core_1 = require("@agentforge/core");
|
|
5
|
-
Object.defineProperty(exports, "EmailService", { enumerable: true, get: function () { return core_1.EmailService; } });
|
|
6
|
-
//# sourceMappingURL=email.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../src/modules/email/email.service.ts"],"names":[],"mappings":";;;AAAA,yCAAgD;AAAvC,oGAAA,YAAY,OAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare function verifyEmailTemplate(params: {
|
|
2
|
-
appName?: string;
|
|
3
|
-
url: string;
|
|
4
|
-
expiresInHours: number;
|
|
5
|
-
}): {
|
|
6
|
-
subject: string;
|
|
7
|
-
html: string;
|
|
8
|
-
text: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function passwordResetTemplate(params: {
|
|
11
|
-
appName?: string;
|
|
12
|
-
url: string;
|
|
13
|
-
expiresInMinutes: number;
|
|
14
|
-
}): {
|
|
15
|
-
subject: string;
|
|
16
|
-
html: string;
|
|
17
|
-
text: string;
|
|
18
|
-
};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.verifyEmailTemplate = verifyEmailTemplate;
|
|
4
|
-
exports.passwordResetTemplate = passwordResetTemplate;
|
|
5
|
-
const wrapper = (body) => `<!doctype html>
|
|
6
|
-
<html><head><meta charset="utf-8" /></head>
|
|
7
|
-
<body style="font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif; background:#f4f4f7; padding:24px; color:#111;">
|
|
8
|
-
<div style="max-width:520px;margin:0 auto;background:#fff;border-radius:12px;padding:32px;box-shadow:0 2px 8px rgba(0,0,0,0.04);">
|
|
9
|
-
${body}
|
|
10
|
-
</div>
|
|
11
|
-
<p style="text-align:center;color:#888;font-size:12px;margin-top:16px;">Powered by AgentForge</p>
|
|
12
|
-
</body></html>`;
|
|
13
|
-
const button = (url, label) => `
|
|
14
|
-
<a href="${url}" style="display:inline-block;background:#7c5cff;color:#fff;padding:12px 22px;border-radius:8px;text-decoration:none;font-weight:600;font-size:14px;">
|
|
15
|
-
${label}
|
|
16
|
-
</a>`;
|
|
17
|
-
function verifyEmailTemplate(params) {
|
|
18
|
-
const appName = params.appName ?? 'your account';
|
|
19
|
-
return {
|
|
20
|
-
subject: `Confirm your email`,
|
|
21
|
-
text: `Confirm your email for ${appName}: ${params.url}\n\nThis link expires in ${params.expiresInHours} hours.`,
|
|
22
|
-
html: wrapper(`
|
|
23
|
-
<h1 style="font-size:20px;margin:0 0 12px;">Confirm your email</h1>
|
|
24
|
-
<p style="margin:0 0 20px;color:#444;line-height:1.5;">Click the button below to verify your email and finish setting up ${appName}.</p>
|
|
25
|
-
${button(params.url, 'Verify email')}
|
|
26
|
-
<p style="margin:24px 0 0;color:#888;font-size:13px;">This link expires in ${params.expiresInHours} hours. If you didn't sign up, you can ignore this email.</p>
|
|
27
|
-
`),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function passwordResetTemplate(params) {
|
|
31
|
-
const appName = params.appName ?? 'your account';
|
|
32
|
-
return {
|
|
33
|
-
subject: `Reset your password`,
|
|
34
|
-
text: `Reset your password for ${appName}: ${params.url}\n\nThis link expires in ${params.expiresInMinutes} minutes.`,
|
|
35
|
-
html: wrapper(`
|
|
36
|
-
<h1 style="font-size:20px;margin:0 0 12px;">Reset your password</h1>
|
|
37
|
-
<p style="margin:0 0 20px;color:#444;line-height:1.5;">We received a request to reset the password for ${appName}. Click below to choose a new one.</p>
|
|
38
|
-
${button(params.url, 'Reset password')}
|
|
39
|
-
<p style="margin:24px 0 0;color:#888;font-size:13px;">This link expires in ${params.expiresInMinutes} minutes. If you didn't request a reset, you can safely ignore this email.</p>
|
|
40
|
-
`),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=transactional.template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transactional.template.js","sourceRoot":"","sources":["../../../../src/modules/email/templates/transactional.template.ts"],"names":[],"mappings":";;AAkBA,kDAgBC;AAED,sDAgBC;AAhDD,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC;;;;MAI5B,IAAI;;;eAGK,CAAC;AAEhB,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,KAAa,EAAE,EAAE,CAAC;aAClC,GAAG;MACV,KAAK;OACJ,CAAC;AAER,SAAgB,mBAAmB,CAAC,MAInC;IACC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,cAAc,CAAC;IACjD,OAAO;QACL,OAAO,EAAE,oBAAoB;QAC7B,IAAI,EAAE,0BAA0B,OAAO,KAAK,MAAM,CAAC,GAAG,4BAA4B,MAAM,CAAC,cAAc,SAAS;QAChH,IAAI,EAAE,OAAO,CAAC;;iIAE+G,OAAO;QAChI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC;mFACyC,MAAM,CAAC,cAAc;KACnG,CAAC;KACH,CAAC;AACJ,CAAC;AAED,SAAgB,qBAAqB,CAAC,MAIrC;IACC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,cAAc,CAAC;IACjD,OAAO;QACL,OAAO,EAAE,qBAAqB;QAC9B,IAAI,EAAE,2BAA2B,OAAO,KAAK,MAAM,CAAC,GAAG,4BAA4B,MAAM,CAAC,gBAAgB,WAAW;QACrH,IAAI,EAAE,OAAO,CAAC;;+GAE6F,OAAO;QAC9G,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,gBAAgB,CAAC;mFACuC,MAAM,CAAC,gBAAgB;KACrG,CAAC;KACH,CAAC;AACJ,CAAC"}
|