All files / dal index.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266                                                                                                                                                                                                                                                                                                                                                                            51x 51x                                                                                                                                                                    
// Data Access Layer - Central Export
import type { DrizzleD1Database } from "drizzle-orm/d1";
import type * as schema from "../db/schema";
import type { DualCache } from "../lib/cache";
import { AnalyticsDal } from "./analytics.dal";
import { BlogAnalyticsDal } from "./blog-analytics.dal";
import { BlogCategoriesDal } from "./blog-categories.dal";
import { BlogGenerationJobsDal } from "./blog-generation-jobs.dal";
import { BlogImagesDal } from "./blog-images.dal";
import { BlogProjectsDal } from "./blog-projects.dal";
import { BlogProsDal } from "./blog-pros.dal";
import { BlogRevisionsDal } from "./blog-revisions.dal";
import { BlogTagsDal } from "./blog-tags.dal";
import { BlogsDal } from "./blogs.dal";
import { CalculatorConfigDal } from "./calculator-config.dal";
import {
	CommunicationLogAnnotationsDal,
	CommunicationLogsDal,
	ConsentRecordsDal,
	InquiryMessagesDal,
} from "./communication-history.dal";
import { CompanyProfileDal } from "./company-profile.dal";
import { ConsultationBookingsDal } from "./consultation-bookings.dal";
import { CrmAnalyticsDal } from "./crm-analytics.dal";
import { CrmSettingsDal } from "./crm-settings.dal";
import { HoFavoritesDal } from "./ho-favorites.dal";
import { HoMoodBoardMembersDal } from "./ho-mood-board-members.dal";
import { HoMoodBoardSharesDal } from "./ho-mood-board-shares.dal";
import { HoMoodBoardsDal } from "./ho-mood-boards.dal";
import { HoProViewsDal } from "./ho-pro-views.dal";
import { HoProfilesDal } from "./ho-profiles.dal";
import { HoUsersDal } from "./ho-users.dal";
import { HomeownerInquiriesDal } from "./homeowner-inquiries.dal";
import { InquiriesDal } from "./inquiries.dal";
import { LandingLeadsDal } from "./landing-leads.dal";
import { LeadActivitiesDal } from "./lead-activities.dal";
import { LeadDocumentsDal } from "./lead-documents.dal";
import { LeadRemindersDal } from "./lead-reminders.dal";
import { LeadSourcesDal } from "./lead-sources.dal";
import { LeadsDal } from "./leads.dal";
import { MediaDal } from "./media.dal";
import { NotificationDeliveryLogDal } from "./notification-delivery-log.dal";
import { NotificationLogDal } from "./notification-log.dal";
import { NotificationPreferencesDal } from "./notification-preferences.dal";
import { NotificationsDal } from "./notifications.dal";
import { PipelineStagesDal } from "./pipeline-stages.dal";
import { ProBlogSuggestionsDal } from "./pro-blog-suggestions.dal";
import { ProWebsitesDal } from "./pro-websites.dal";
import { ProWhatsAppRecipientsDal } from "./pro-whatsapp-recipients.dal";
import { ProjectsDal } from "./projects.dal";
import { ProsDal } from "./pros.dal";
import { PushSubscriptionsDal } from "./push-subscriptions.dal";
import {
	PrerequisiteGateChecksDal,
	ProRestrictionStatusDal,
	RestrictionCohortsDal,
} from "./restriction.dal";
import { RoomTypesDal } from "./room-types.dal";
import { RoomsDal } from "./rooms.dal";
import { SlugRedirectsDal } from "./slug-redirects.dal";
import { SocialDraftsDal } from "./social-drafts.dal";
import { TeamInvitationsDal } from "./team-invitations.dal";
import { UploadsDal } from "./uploads.dal";
import { UserTenantRolesDal } from "./user-tenant-roles.dal";
import { UsersDal } from "./users.dal";
import { WebsiteBuildJobsDal } from "./website-build-jobs.dal";
import { WebsiteTemplatesDal } from "./website-templates.dal";
import {
	WaCampaignsDal,
	WaConversationsDal,
	WaMessagesDal,
	WaTemplatesDal,
} from "./whatsapp";
 
export { AnalyticsDal } from "./analytics.dal";
export { BlogAnalyticsDal } from "./blog-analytics.dal";
export {
	BlogCategoriesDal,
	type BlogCategoryFilters,
} from "./blog-categories.dal";
export {
	type BlogGenerationJobFilters,
	BlogGenerationJobsDal,
} from "./blog-generation-jobs.dal";
export { BlogImagesDal } from "./blog-images.dal";
export { BlogProjectsDal } from "./blog-projects.dal";
export { type BlogProFilters, BlogProsDal } from "./blog-pros.dal";
export { BlogRevisionsDal } from "./blog-revisions.dal";
export { type BlogTagFilters, BlogTagsDal } from "./blog-tags.dal";
export { type BlogFilters, BlogsDal } from "./blogs.dal";
export { CalculatorConfigDal } from "./calculator-config.dal";
export { CompanyProfileDal } from "./company-profile.dal";
export { ConsultationBookingsDal } from "./consultation-bookings.dal";
export { CrmAnalyticsDal } from "./crm-analytics.dal";
export { CrmSettingsDal } from "./crm-settings.dal";
export { HoFavoritesDal } from "./ho-favorites.dal";
export { HoMoodBoardMembersDal } from "./ho-mood-board-members.dal";
export { HoMoodBoardSharesDal } from "./ho-mood-board-shares.dal";
export { HoMoodBoardsDal } from "./ho-mood-boards.dal";
export { HoProViewsDal } from "./ho-pro-views.dal";
export { HoProfilesDal } from "./ho-profiles.dal";
export { HoUsersDal } from "./ho-users.dal";
export { InquiriesDal } from "./inquiries.dal";
export { LandingLeadsDal } from "./landing-leads.dal";
export { LeadActivitiesDal } from "./lead-activities.dal";
export { LeadDocumentsDal } from "./lead-documents.dal";
export { LeadRemindersDal } from "./lead-reminders.dal";
export { LeadSourcesDal } from "./lead-sources.dal";
export { type LeadFilters, LeadsDal } from "./leads.dal";
export { MediaDal } from "./media.dal";
export {
	NotificationDeliveryLogDal,
	type NotificationDeliveryLogFilters,
} from "./notification-delivery-log.dal";
export { NotificationLogDal } from "./notification-log.dal";
export { NotificationPreferencesDal } from "./notification-preferences.dal";
export { NotificationsDal } from "./notifications.dal";
export { PipelineStagesDal } from "./pipeline-stages.dal";
export {
	type ProBlogSuggestionFilters,
	ProBlogSuggestionsDal,
} from "./pro-blog-suggestions.dal";
export { ProWebsitesDal } from "./pro-websites.dal";
export {
	AlreadyVerifiedError,
	DuplicateRecipientError,
	OtpCooldownError,
	OtpExpiredError,
	OtpMismatchError,
	ProWhatsAppRecipientsDal,
	RecipientLimitError,
	RecipientNotFoundError,
} from "./pro-whatsapp-recipients.dal";
export { type ProjectFilters, ProjectsDal } from "./projects.dal";
export { type ProFilters, ProsDal } from "./pros.dal";
export { PushSubscriptionsDal } from "./push-subscriptions.dal";
export { RoomTypesDal } from "./room-types.dal";
export { RoomsDal } from "./rooms.dal";
export type { SlugRedirectEntityType } from "./slug-redirects.dal";
export { SlugRedirectsDal } from "./slug-redirects.dal";
export { SocialDraftsDal } from "./social-drafts.dal";
export { TeamInvitationsDal } from "./team-invitations.dal";
export { UploadsDal } from "./uploads.dal";
export { UserTenantRolesDal } from "./user-tenant-roles.dal";
export { type UserFilters, UsersDal } from "./users.dal";
export {
	type BuildJobFilters,
	WebsiteBuildJobsDal,
} from "./website-build-jobs.dal";
export { WebsiteTemplatesDal } from "./website-templates.dal";
export {
	type WaCampaignFilters,
	WaCampaignsDal,
} from "./whatsapp/campaigns.dal";
export {
	type WaConversationFilters,
	WaConversationsDal,
} from "./whatsapp/conversations.dal";
export { WaMessagesDal } from "./whatsapp/messages.dal";
export { WaTemplatesDal } from "./whatsapp/templates.dal";
 
import { ProgramConfigDal } from "./partners/config.dal";
import { PartnersDal } from "./partners/partners.dal";
import { ReferralsDal } from "./partners/referrals.dal";
import {
	RrmConfigDal,
	RrmEventsDal,
	RrmLinksDal,
	RrmProspectsDal,
	RrmSuppressionDal,
} from "./rrm";
 
export function createDal(
	db: DrizzleD1Database<typeof schema>,
	_cache?: DualCache,
	env?: Partial<{
		SCORE_WEIGHT_PHOTO: string;
		SCORE_WEIGHT_COVER: string;
		SCORE_WEIGHT_COMPLETE: string;
		SCORE_WEIGHT_RECENCY: string;
	}>,
) {
	const projects = new ProjectsDal(db, env);
	return {
		db,
		// RRM — recruitment CRM (F-21). Grouped so the whole campaign can be
		// lifted out in one directory if the 14-day gate is missed.
		rrmProspects: new RrmProspectsDal(db),
		rrmEvents: new RrmEventsDal(db),
		rrmSuppression: new RrmSuppressionDal(db),
		rrmConfig: new RrmConfigDal(db),
		rrmLinks: new RrmLinksDal(db),
		// Partner programme (SRS-PP-001). Unprefixed tables, joined to RRM by
		// exactly one column — partners.prospect_id.
		partners: new PartnersDal(db),
		referrals: new ReferralsDal(db),
		programConfig: new ProgramConfigDal(db),
		pros: new ProsDal(db),
		projects,
		inquiries: new InquiriesDal(db),
		landingLeads: new LandingLeadsDal(db),
		consultationBookings: new ConsultationBookingsDal(db),
		calculatorConfig: new CalculatorConfigDal(db),
		userTenantRoles: new UserTenantRolesDal(db),
		users: new UsersDal(db),
		teamInvitations: new TeamInvitationsDal(db),
		rooms: new RoomsDal(db),
		media: new MediaDal(db, projects),
		roomTypes: new RoomTypesDal(db),
		companyProfile: new CompanyProfileDal(db),
		analytics: new AnalyticsDal(db),
		blogs: new BlogsDal(db),
		blogCategories: new BlogCategoriesDal(db),
		blogTags: new BlogTagsDal(db),
		blogPros: new BlogProsDal(db),
		blogProjects: new BlogProjectsDal(db),
		blogRevisions: new BlogRevisionsDal(db),
		proBlogSuggestions: new ProBlogSuggestionsDal(db),
		blogAnalytics: new BlogAnalyticsDal(db),
		blogImages: new BlogImagesDal(db),
		blogGenerationJobs: new BlogGenerationJobsDal(db),
		proWebsites: new ProWebsitesDal(db),
		proWhatsAppRecipients: new ProWhatsAppRecipientsDal(db),
		websiteTemplates: new WebsiteTemplatesDal(db),
		websiteBuildJobs: new WebsiteBuildJobsDal(db),
		pipelineStages: new PipelineStagesDal(db),
		leadSources: new LeadSourcesDal(db),
		crmSettings: new CrmSettingsDal(db),
		leads: new LeadsDal(db),
		leadActivities: new LeadActivitiesDal(db),
		leadDocuments: new LeadDocumentsDal(db),
		leadReminders: new LeadRemindersDal(db),
		crmAnalytics: new CrmAnalyticsDal(db),
		waConversations: new WaConversationsDal(db),
		waMessages: new WaMessagesDal(db),
		waTemplates: new WaTemplatesDal(db),
		waCampaigns: new WaCampaignsDal(db),
		notificationPreferences: new NotificationPreferencesDal(db),
		notificationLog: new NotificationLogDal(db),
		notificationDeliveryLog: new NotificationDeliveryLogDal(db),
		notifications: new NotificationsDal(db),
		pushSubscriptions: new PushSubscriptionsDal(db),
		uploads: new UploadsDal(db),
		socialDrafts: new SocialDraftsDal(db),
		hoProfiles: new HoProfilesDal(db),
		hoUsers: new HoUsersDal(db),
		hoFavorites: new HoFavoritesDal(db),
		hoMoodBoards: new HoMoodBoardsDal(db),
		hoMoodBoardShares: new HoMoodBoardSharesDal(db),
		hoMoodBoardMembers: new HoMoodBoardMembersDal(db),
		hoProViews: new HoProViewsDal(db),
		slugRedirects: new SlugRedirectsDal(db),
		// Homeowner inquiry portal + Restrict Direct Contact + Communication Log
		homeownerInquiries: new HomeownerInquiriesDal(db),
		communicationLogs: new CommunicationLogsDal(db),
		communicationLogAnnotations: new CommunicationLogAnnotationsDal(db),
		consentRecords: new ConsentRecordsDal(db),
		inquiryMessages: new InquiryMessagesDal(db),
		proRestrictionStatus: new ProRestrictionStatusDal(db),
		restrictionCohorts: new RestrictionCohortsDal(db),
		prerequisiteGateChecks: new PrerequisiteGateChecksDal(db),
	};
}
 
export type Dal = ReturnType<typeof createDal>;