feat(subscriptions): add Subscriptions module with plans, quotas, and billing
- Add Subscription, Plan, UsageRecord domain entities - Implement Create, Upgrade, Cancel subscription commands - Add MeterUsage command for quota tracking - Support 4 plan tiers: Free, Agent Pro, Investor, Enterprise - Register SubscriptionsModule in AppModule Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
import { type PlanTier } from '@prisma/client';
|
||||
|
||||
export class SubscriptionCancelledEvent implements DomainEvent {
|
||||
readonly eventName = 'subscription.cancelled';
|
||||
readonly occurredAt = new Date();
|
||||
|
||||
constructor(
|
||||
public readonly aggregateId: string,
|
||||
public readonly userId: string,
|
||||
public readonly planTier: PlanTier,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
import { type PlanTier } from '@prisma/client';
|
||||
|
||||
export class SubscriptionCreatedEvent implements DomainEvent {
|
||||
readonly eventName = 'subscription.created';
|
||||
readonly occurredAt = new Date();
|
||||
|
||||
constructor(
|
||||
public readonly aggregateId: string,
|
||||
public readonly userId: string,
|
||||
public readonly planTier: PlanTier,
|
||||
) {}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { type DomainEvent } from '@modules/shared/domain/domain-event';
|
||||
import { type PlanTier } from '@prisma/client';
|
||||
|
||||
export class SubscriptionUpgradedEvent implements DomainEvent {
|
||||
readonly eventName = 'subscription.upgraded';
|
||||
readonly occurredAt = new Date();
|
||||
|
||||
constructor(
|
||||
public readonly aggregateId: string,
|
||||
public readonly userId: string,
|
||||
public readonly fromTier: PlanTier,
|
||||
public readonly toTier: PlanTier,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user