editia-core
Version:
Core services and utilities for Editia applications - Authentication, Monetization, Video Generation Types, and Database Management
143 lines • 4.22 kB
TypeScript
/**
* Monetization types for Editia Core
*
* This file defines strict types for all monetization-related concepts:
* - Feature identifiers
* - Action types
* - Usage tracking
* - Plan management
*/
import { PlanIdentifier } from './database';
/**
* All available features in the system
*/
export declare const FEATURES: {
readonly VIDEO_GENERATION: "video_generation";
readonly SOURCE_VIDEOS: "source_videos";
readonly VOICE_CLONE: "voice_clone";
readonly ACCOUNT_ANALYSIS: "account_analysis";
readonly ACCOUNT_INSIGHTS: "account_insights";
readonly ACCOUNT_CHAT: "account_chat";
readonly SCRIPT_CONVERSATIONS: "script_conversations";
readonly SCRIPT_GENERATION: "script_generation";
readonly CHAT_AI: "chat_ai";
};
/**
* Feature identifier type
*/
export type FeatureId = typeof FEATURES[keyof typeof FEATURES];
/**
* All available actions that can be performed
*/
export declare const ACTIONS: {
readonly VIDEO_GENERATION: "video_generation";
readonly SOURCE_VIDEO_UPLOAD: "source_video_upload";
readonly VOICE_CLONE: "voice_clone";
readonly ACCOUNT_ANALYSIS: "account_analysis";
readonly ACCOUNT_INSIGHTS: "account_insights";
readonly ACCOUNT_CHAT: "account_chat";
readonly SCRIPT_CONVERSATIONS: "script_conversations";
};
/**
* Action type
*/
export type Action = typeof ACTIONS[keyof typeof ACTIONS];
/**
* Usage tracking fields in the database
*/
export declare const USAGE_FIELDS: {
readonly VIDEOS_GENERATED: "videos_generated";
readonly SOURCE_VIDEOS_USED: "source_videos_used";
readonly VOICE_CLONES_USED: "voice_clones_used";
readonly ACCOUNT_ANALYSIS_USED: "account_analysis_used";
readonly ACCOUNT_INSIGHTS_USED: "account_insights_used";
readonly SCRIPT_CONVERSATIONS_USED: "script_conversations_used";
readonly ACCOUNT_CHAT_USED: "account_chat_used";
};
/**
* Usage field type
*/
export type UsageField = typeof USAGE_FIELDS[keyof typeof USAGE_FIELDS];
/**
* Maps features to their corresponding actions
*/
export declare const FEATURE_TO_ACTION_MAP: Record<FeatureId, Action>;
/**
* Maps actions to their corresponding usage fields
*/
export declare const ACTION_TO_USAGE_FIELD_MAP: Record<Action, UsageField>;
/**
* Maps features to their corresponding usage fields
*/
export declare const FEATURE_TO_USAGE_FIELD_MAP: Record<FeatureId, UsageField>;
/**
* Usage information for a specific feature/action
*/
export interface UsageInfo {
used: number;
total: number;
remaining: number;
percentage: number;
}
/**
* Feature access result
*/
export interface FeatureAccessResult {
hasAccess: boolean;
requiredPlan: PlanIdentifier | null;
remainingUsage: number;
totalLimit: number;
currentPlan: PlanIdentifier;
error?: string;
}
/**
* Usage validation result
*/
export interface UsageValidationResult {
isValid: boolean;
remainingUsage: number;
totalLimit: number;
error?: string;
}
/**
* Comprehensive monetization check result
*/
export interface MonetizationCheckResult {
success: boolean;
hasAccess: boolean;
currentPlan: PlanIdentifier;
remainingUsage: number;
totalLimit: number;
error?: string;
details?: {
featureId: FeatureId;
requiredPlan: PlanIdentifier | null;
usageType: UsageField;
};
}
/**
* Get the action corresponding to a feature
*/
export declare function getActionForFeature(featureId: FeatureId): Action;
/**
* Get the usage field corresponding to an action
*/
export declare function getUsageFieldForAction(action: Action): UsageField;
/**
* Get the usage field corresponding to a feature
*/
export declare function getUsageFieldForFeature(featureId: FeatureId): UsageField;
/**
* Check if a string is a valid feature ID
*/
export declare function isValidFeatureId(value: string): value is FeatureId;
/**
* Check if a string is a valid action
*/
export declare function isValidAction(value: string): value is Action;
/**
* Check if a string is a valid usage field
*/
export declare function isValidUsageField(value: string): value is UsageField;
export type { PlanIdentifier } from './database';
//# sourceMappingURL=monetization.d.ts.map