Some checks are pending
CD Production (Hetzner k3s) / Promote Images (preprod → prod) (push) Waiting to run
CD Production (Hetzner k3s) / Deploy to k3s (xpeditis-prod) (push) Blocked by required conditions
CD Production (Hetzner k3s) / Smoke Tests (push) Blocked by required conditions
CD Production (Hetzner k3s) / Deployment Summary (push) Blocked by required conditions
CD Production (Hetzner k3s) / Notify Success (push) Blocked by required conditions
CD Production (Hetzner k3s) / Notify Failure (push) Blocked by required conditions
Aligns main with the complete application codebase (cicd branch). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
81 lines
2.7 KiB
TypeScript
81 lines
2.7 KiB
TypeScript
/**
|
|
* Subscription Domain Exceptions
|
|
*/
|
|
|
|
export class NoLicensesAvailableException extends Error {
|
|
constructor(
|
|
public readonly organizationId: string,
|
|
public readonly currentLicenses: number,
|
|
public readonly maxLicenses: number
|
|
) {
|
|
super(
|
|
`No licenses available for organization ${organizationId}. ` +
|
|
`Currently using ${currentLicenses}/${maxLicenses} licenses.`
|
|
);
|
|
this.name = 'NoLicensesAvailableException';
|
|
Object.setPrototypeOf(this, NoLicensesAvailableException.prototype);
|
|
}
|
|
}
|
|
|
|
export class SubscriptionNotFoundException extends Error {
|
|
constructor(public readonly identifier: string) {
|
|
super(`Subscription not found: ${identifier}`);
|
|
this.name = 'SubscriptionNotFoundException';
|
|
Object.setPrototypeOf(this, SubscriptionNotFoundException.prototype);
|
|
}
|
|
}
|
|
|
|
export class LicenseNotFoundException extends Error {
|
|
constructor(public readonly identifier: string) {
|
|
super(`License not found: ${identifier}`);
|
|
this.name = 'LicenseNotFoundException';
|
|
Object.setPrototypeOf(this, LicenseNotFoundException.prototype);
|
|
}
|
|
}
|
|
|
|
export class LicenseAlreadyAssignedException extends Error {
|
|
constructor(public readonly userId: string) {
|
|
super(`User ${userId} already has an assigned license`);
|
|
this.name = 'LicenseAlreadyAssignedException';
|
|
Object.setPrototypeOf(this, LicenseAlreadyAssignedException.prototype);
|
|
}
|
|
}
|
|
|
|
export class InvalidSubscriptionDowngradeException extends Error {
|
|
constructor(
|
|
public readonly currentPlan: string,
|
|
public readonly targetPlan: string,
|
|
public readonly currentUsers: number,
|
|
public readonly targetMaxLicenses: number
|
|
) {
|
|
super(
|
|
`Cannot downgrade from ${currentPlan} to ${targetPlan}. ` +
|
|
`Current users (${currentUsers}) exceed target plan limit (${targetMaxLicenses}).`
|
|
);
|
|
this.name = 'InvalidSubscriptionDowngradeException';
|
|
Object.setPrototypeOf(this, InvalidSubscriptionDowngradeException.prototype);
|
|
}
|
|
}
|
|
|
|
export class SubscriptionNotActiveException extends Error {
|
|
constructor(
|
|
public readonly subscriptionId: string,
|
|
public readonly currentStatus: string
|
|
) {
|
|
super(`Subscription ${subscriptionId} is not active. Current status: ${currentStatus}`);
|
|
this.name = 'SubscriptionNotActiveException';
|
|
Object.setPrototypeOf(this, SubscriptionNotActiveException.prototype);
|
|
}
|
|
}
|
|
|
|
export class InvalidSubscriptionStatusTransitionException extends Error {
|
|
constructor(
|
|
public readonly fromStatus: string,
|
|
public readonly toStatus: string
|
|
) {
|
|
super(`Invalid subscription status transition from ${fromStatus} to ${toStatus}`);
|
|
this.name = 'InvalidSubscriptionStatusTransitionException';
|
|
Object.setPrototypeOf(this, InvalidSubscriptionStatusTransitionException.prototype);
|
|
}
|
|
}
|