UNPKG

@iota-big3/sdk-gateway

Version:

Universal API Gateway with protocol translation, intelligent routing, rate limiting, health checking, and caching

313 lines 12 kB
"use strict"; /** * @fileoverview Comprehensive types for engagement systems (Donors, Extracurricular, Marketing) * @module @iota-big3/sdk-types/engagement * @description * Provides strictly-typed definitions for engagement management including: * - Donor Management (fundraising, campaigns, recognition) * - Extracurricular Activities (clubs, sports, arts, volunteer) * - Marketing (campaigns, outreach, communications) * * Designed for AI/debugging friendliness with descriptive names and comprehensive documentation. * * @example * ```typescript * import type { Donor, Activity, MarketingCampaign } from '@iota-big3/sdk-types'; * * // Donor Management * const donor: Donor = { * id: 'donor_123', * personalInfo: { * firstName: 'Jane', * lastName: 'Smith', * email: 'jane.smith@email.com', * phone: '+1-555-0456' * }, * donorProfile: { * type: DonorType.INDIVIDUAL, * category: DonorCategory.MAJOR_DONOR, * firstGiftDate: '2015-03-15', * lifetimeGiving: 250000n, * lastGiftDate: '2024-01-15', * communicationPreferences: { * email: true, * phone: false, * mail: true, * frequency: CommunicationFrequency.QUARTERLY * } * } * }; * ``` * * @since 1.0.0 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.engagementTypes = exports.ContentType = exports.AudienceSegment = exports.MarketingCampaignStatus = exports.MarketingChannel = exports.ParticipationStatus = exports.ActivityStatus = exports.ActivityType = exports.RecognitionLevel = exports.CommunicationFrequency = exports.GiftType = exports.DonorCategory = exports.DonorType = void 0; exports.calculateDonorRetention = calculateDonorRetention; exports.isActivityFull = isActivityFull; exports.calculateCampaignROI = calculateCampaignROI; exports.getDonorRecognitionLevel = getDonorRecognitionLevel; // ============================================================================ // Donor Management Types // ============================================================================ /** * Donor types * @description Categories of donors */ var DonorType; (function (DonorType) { DonorType["INDIVIDUAL"] = "INDIVIDUAL"; DonorType["CORPORATION"] = "CORPORATION"; DonorType["FOUNDATION"] = "FOUNDATION"; DonorType["GOVERNMENT"] = "GOVERNMENT"; DonorType["ALUMNI"] = "ALUMNI"; DonorType["PARENT"] = "PARENT"; DonorType["STAFF"] = "STAFF"; DonorType["ANONYMOUS"] = "ANONYMOUS"; })(DonorType || (exports.DonorType = DonorType = {})); /** * Donor categories * @description Classification levels for donors */ var DonorCategory; (function (DonorCategory) { DonorCategory["MAJOR_DONOR"] = "MAJOR_DONOR"; DonorCategory["MID_LEVEL"] = "MID_LEVEL"; DonorCategory["ANNUAL_FUND"] = "ANNUAL_FUND"; DonorCategory["ENTRY_LEVEL"] = "ENTRY_LEVEL"; DonorCategory["PLANNED_GIVING"] = "PLANNED_GIVING"; DonorCategory["MONTHLY_GIVING"] = "MONTHLY_GIVING"; DonorCategory["LAPSED"] = "LAPSED"; DonorCategory["PROSPECT"] = "PROSPECT"; // Never given })(DonorCategory || (exports.DonorCategory = DonorCategory = {})); /** * Gift types * @description Types of donations */ var GiftType; (function (GiftType) { GiftType["CASH"] = "CASH"; GiftType["CHECK"] = "CHECK"; GiftType["CREDIT_CARD"] = "CREDIT_CARD"; GiftType["ACH"] = "ACH"; GiftType["STOCK"] = "STOCK"; GiftType["PROPERTY"] = "PROPERTY"; GiftType["IN_KIND"] = "IN_KIND"; GiftType["PLANNED"] = "PLANNED"; GiftType["PLEDGE"] = "PLEDGE"; GiftType["GRANT"] = "GRANT"; })(GiftType || (exports.GiftType = GiftType = {})); /** * Communication frequency * @description How often to communicate with donors */ var CommunicationFrequency; (function (CommunicationFrequency) { CommunicationFrequency["WEEKLY"] = "WEEKLY"; CommunicationFrequency["MONTHLY"] = "MONTHLY"; CommunicationFrequency["QUARTERLY"] = "QUARTERLY"; CommunicationFrequency["SEMI_ANNUALLY"] = "SEMI_ANNUALLY"; CommunicationFrequency["ANNUALLY"] = "ANNUALLY"; CommunicationFrequency["AS_NEEDED"] = "AS_NEEDED"; CommunicationFrequency["DO_NOT_CONTACT"] = "DO_NOT_CONTACT"; })(CommunicationFrequency || (exports.CommunicationFrequency = CommunicationFrequency = {})); /** * Recognition level * @description Donor recognition tiers */ var RecognitionLevel; (function (RecognitionLevel) { RecognitionLevel["FOUNDERS_CIRCLE"] = "FOUNDERS_CIRCLE"; RecognitionLevel["PRESIDENTS_CIRCLE"] = "PRESIDENTS_CIRCLE"; RecognitionLevel["BENEFACTOR"] = "BENEFACTOR"; RecognitionLevel["PATRON"] = "PATRON"; RecognitionLevel["PARTNER"] = "PARTNER"; RecognitionLevel["SUPPORTER"] = "SUPPORTER"; RecognitionLevel["FRIEND"] = "FRIEND"; RecognitionLevel["MEMBER"] = "MEMBER"; // Under $1K })(RecognitionLevel || (exports.RecognitionLevel = RecognitionLevel = {})); // ============================================================================ // Extracurricular Activity Types // ============================================================================ /** * Activity types * @description Categories of extracurricular activities */ var ActivityType; (function (ActivityType) { ActivityType["ACADEMIC"] = "ACADEMIC"; ActivityType["ARTS"] = "ARTS"; ActivityType["ATHLETICS"] = "ATHLETICS"; ActivityType["CULTURAL"] = "CULTURAL"; ActivityType["SERVICE"] = "SERVICE"; ActivityType["LEADERSHIP"] = "LEADERSHIP"; ActivityType["STEM"] = "STEM"; ActivityType["RECREATION"] = "RECREATION"; ActivityType["PROFESSIONAL"] = "PROFESSIONAL"; ActivityType["RELIGIOUS"] = "RELIGIOUS"; // Faith-based groups })(ActivityType || (exports.ActivityType = ActivityType = {})); /** * Activity status * @description Current status of an activity */ var ActivityStatus; (function (ActivityStatus) { ActivityStatus["ACTIVE"] = "ACTIVE"; ActivityStatus["INACTIVE"] = "INACTIVE"; ActivityStatus["SUSPENDED"] = "SUSPENDED"; ActivityStatus["PLANNING"] = "PLANNING"; ActivityStatus["CANCELLED"] = "CANCELLED"; })(ActivityStatus || (exports.ActivityStatus = ActivityStatus = {})); /** * Participation status * @description Student's participation status */ var ParticipationStatus; (function (ParticipationStatus) { ParticipationStatus["ACTIVE"] = "ACTIVE"; ParticipationStatus["INACTIVE"] = "INACTIVE"; ParticipationStatus["GRADUATED"] = "GRADUATED"; ParticipationStatus["WITHDRAWN"] = "WITHDRAWN"; ParticipationStatus["SUSPENDED"] = "SUSPENDED"; })(ParticipationStatus || (exports.ParticipationStatus = ParticipationStatus = {})); // ============================================================================ // Marketing Types // ============================================================================ /** * Marketing channel * @description Communication channels for marketing */ var MarketingChannel; (function (MarketingChannel) { MarketingChannel["EMAIL"] = "EMAIL"; MarketingChannel["SOCIAL_MEDIA"] = "SOCIAL_MEDIA"; MarketingChannel["WEBSITE"] = "WEBSITE"; MarketingChannel["PRINT"] = "PRINT"; MarketingChannel["RADIO"] = "RADIO"; MarketingChannel["TV"] = "TV"; MarketingChannel["OUTDOOR"] = "OUTDOOR"; MarketingChannel["EVENTS"] = "EVENTS"; MarketingChannel["DIRECT_MAIL"] = "DIRECT_MAIL"; MarketingChannel["DIGITAL_ADS"] = "DIGITAL_ADS"; })(MarketingChannel || (exports.MarketingChannel = MarketingChannel = {})); /** * Campaign status * @description Status of marketing campaign */ var MarketingCampaignStatus; (function (MarketingCampaignStatus) { MarketingCampaignStatus["DRAFT"] = "DRAFT"; MarketingCampaignStatus["SCHEDULED"] = "SCHEDULED"; MarketingCampaignStatus["ACTIVE"] = "ACTIVE"; MarketingCampaignStatus["PAUSED"] = "PAUSED"; MarketingCampaignStatus["COMPLETED"] = "COMPLETED"; MarketingCampaignStatus["CANCELLED"] = "CANCELLED"; })(MarketingCampaignStatus || (exports.MarketingCampaignStatus = MarketingCampaignStatus = {})); /** * Audience segment * @description Target audience for marketing */ var AudienceSegment; (function (AudienceSegment) { AudienceSegment["PROSPECTIVE_STUDENTS"] = "PROSPECTIVE_STUDENTS"; AudienceSegment["CURRENT_STUDENTS"] = "CURRENT_STUDENTS"; AudienceSegment["ALUMNI"] = "ALUMNI"; AudienceSegment["PARENTS"] = "PARENTS"; AudienceSegment["DONORS"] = "DONORS"; AudienceSegment["COMMUNITY"] = "COMMUNITY"; AudienceSegment["STAFF"] = "STAFF"; AudienceSegment["MEDIA"] = "MEDIA"; AudienceSegment["PARTNERS"] = "PARTNERS"; })(AudienceSegment || (exports.AudienceSegment = AudienceSegment = {})); /** * Content type * @description Types of marketing content */ var ContentType; (function (ContentType) { ContentType["ARTICLE"] = "ARTICLE"; ContentType["VIDEO"] = "VIDEO"; ContentType["IMAGE"] = "IMAGE"; ContentType["INFOGRAPHIC"] = "INFOGRAPHIC"; ContentType["PODCAST"] = "PODCAST"; ContentType["NEWSLETTER"] = "NEWSLETTER"; ContentType["PRESS_RELEASE"] = "PRESS_RELEASE"; ContentType["SOCIAL_POST"] = "SOCIAL_POST"; ContentType["WEBINAR"] = "WEBINAR"; ContentType["EBOOK"] = "EBOOK"; })(ContentType || (exports.ContentType = ContentType = {})); // ============================================================================ // Validation Functions // ============================================================================ /** * Calculate donor retention rate * @param donors - Array of donors * @param year - Year to calculate for * @returns Retention rate as percentage */ function calculateDonorRetention(donors, year) { const previousYear = year - 1; const previousYearDonors = donors.filter(donor => donor.donations?.some(d => new Date(d.date).getFullYear() === previousYear)); const retainedDonors = previousYearDonors.filter(donor => donor.donations?.some(d => new Date(d.date).getFullYear() === year)); return previousYearDonors.length > 0 ? (retainedDonors.length / previousYearDonors.length) * 100 : 0; } /** * Check if activity is at capacity * @param activity - Activity to check * @returns True if at or over capacity */ function isActivityFull(activity) { if (!activity.capacity) return false; return activity.capacity.current >= activity.capacity.max; } /** * Calculate marketing campaign ROI * @param campaign - Marketing campaign * @returns ROI as percentage */ function calculateCampaignROI(campaign) { if (!campaign.metrics?.conversions || campaign.budget.spent === 0n) { return 0; } // Assuming average value per conversion (this would come from elsewhere) const avgConversionValue = 50000n; // $500 in cents const revenue = BigInt(campaign.metrics.conversions) * avgConversionValue; const roi = ((revenue - campaign.budget.spent) * 100n) / campaign.budget.spent; return Number(roi); } /** * Get donor recognition level * @param lifetimeGiving - Total lifetime giving in cents * @returns Recognition level */ function getDonorRecognitionLevel(lifetimeGiving) { if (lifetimeGiving >= 100000000n) return RecognitionLevel.FOUNDERS_CIRCLE; // $1M+ if (lifetimeGiving >= 50000000n) return RecognitionLevel.PRESIDENTS_CIRCLE; // $500K+ if (lifetimeGiving >= 10000000n) return RecognitionLevel.BENEFACTOR; // $100K+ if (lifetimeGiving >= 5000000n) return RecognitionLevel.PATRON; // $50K+ if (lifetimeGiving >= 2500000n) return RecognitionLevel.PARTNER; // $25K+ if (lifetimeGiving >= 1000000n) return RecognitionLevel.SUPPORTER; // $10K+ if (lifetimeGiving >= 100000n) return RecognitionLevel.FRIEND; // $1K+ return RecognitionLevel.MEMBER; } // Export grouped by domain exports.engagementTypes = { // Donor Management calculateDonorRetention, getDonorRecognitionLevel, // Extracurricular isActivityFull, // Marketing calculateCampaignROI }; //# sourceMappingURL=engagement-types.js.map