UNPKG

pricing4ts

Version:

![NPM Version](https://img.shields.io/npm/v/pricing4ts) Pricing4TS is a TypeScript-based toolkit designed to enhance the server-side functionality of a pricing-driven SaaS by enabling the seamless integration of pricing plans into the application logic. T

70 lines (65 loc) 1.69 kB
import { Feature } from './feature'; import { UsageLimit } from './usage-limit'; import { Plan } from './plan'; import { AddOn } from './addon'; export interface Pricing { saasName: string; syntaxVersion: string; version: string; url?: string; createdAt: Date; currency: string; tags?: string[]; billing?: {[key: string]: number}; variables: {[key: string]: number | string | boolean}; features: Record<string, Feature>; usageLimits?: Record<string, UsageLimit>; plans?: Record<string, Plan>; addOns?: Record<string, AddOn>; } export interface ExtractedPricing extends Omit<Pricing, 'syntaxVersion' | 'createdAt'> { syntaxVersion: string; createdAt: string | Date; } export interface PricingToBeWritten extends Omit<Pricing, 'createdAt' | 'features'> { createdAt: string; features: Record<string, Feature> | undefined; } export function generateEmptyPricing(): Pricing { return { saasName: "", syntaxVersion: "0.0", version: "", url: "", createdAt: new Date(), currency: "", billing: { "monthly": 1, }, variables: {}, tags: [], features: {}, usageLimits: {}, plans: {}, addOns: {} } } export function generatePricingToBeWritten(): PricingToBeWritten { return { saasName: "", syntaxVersion: "0.0", version: "", url: "", createdAt: "", currency: "", billing: { "monthly": 1, }, variables: {}, tags: [], features: {}, usageLimits: {}, plans: {}, addOns: {} } }