@blackcode_sa/metaestetics-api 1.14.37 → 1.14.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,18 @@ declare enum UserRole {
8
8
  APP_ADMIN = "app_admin",
9
9
  CLINIC_ADMIN = "clinic_admin"
10
10
  }
11
+ /**
12
+ * Enum for acquisition source - how the user found out about the app
13
+ */
14
+ declare enum AcquisitionSource {
15
+ FRIEND_FAMILY = "friend_family",
16
+ ONLINE_SEARCH = "online_search",
17
+ SOCIAL_MEDIA_AD = "social_media_ad",
18
+ TRADITIONAL_AD = "traditional_ad",
19
+ BLOG_ARTICLE = "blog_article",
20
+ HEALTHCARE_PROVIDER = "healthcare_provider",
21
+ OTHER = "other"
22
+ }
11
23
  interface User {
12
24
  uid: string;
13
25
  email: string | null;
@@ -19,6 +31,12 @@ interface User {
19
31
  patientProfile?: string;
20
32
  practitionerProfile?: string;
21
33
  adminProfile?: string;
34
+ /** How the user found out about the app (marketing attribution) */
35
+ acquisitionSource?: AcquisitionSource | null;
36
+ /** Custom text when acquisitionSource is 'other' */
37
+ acquisitionSourceOther?: string | null;
38
+ /** Timestamp when acquisition source was collected */
39
+ acquisitionSourceTimestamp?: Timestamp | null;
22
40
  }
23
41
 
24
42
  /**
@@ -8,6 +8,18 @@ declare enum UserRole {
8
8
  APP_ADMIN = "app_admin",
9
9
  CLINIC_ADMIN = "clinic_admin"
10
10
  }
11
+ /**
12
+ * Enum for acquisition source - how the user found out about the app
13
+ */
14
+ declare enum AcquisitionSource {
15
+ FRIEND_FAMILY = "friend_family",
16
+ ONLINE_SEARCH = "online_search",
17
+ SOCIAL_MEDIA_AD = "social_media_ad",
18
+ TRADITIONAL_AD = "traditional_ad",
19
+ BLOG_ARTICLE = "blog_article",
20
+ HEALTHCARE_PROVIDER = "healthcare_provider",
21
+ OTHER = "other"
22
+ }
11
23
  interface User {
12
24
  uid: string;
13
25
  email: string | null;
@@ -19,6 +31,12 @@ interface User {
19
31
  patientProfile?: string;
20
32
  practitionerProfile?: string;
21
33
  adminProfile?: string;
34
+ /** How the user found out about the app (marketing attribution) */
35
+ acquisitionSource?: AcquisitionSource | null;
36
+ /** Custom text when acquisitionSource is 'other' */
37
+ acquisitionSourceOther?: string | null;
38
+ /** Timestamp when acquisition source was collected */
39
+ acquisitionSourceTimestamp?: Timestamp | null;
22
40
  }
23
41
 
24
42
  /**
@@ -3081,6 +3081,15 @@ var AppointmentAggregationService = class {
3081
3081
  const dueDateTime = new Date(appointment.appointmentStartTime.toMillis());
3082
3082
  if (template.timeframe.unit === "days" /* DAYS */) {
3083
3083
  dueDateTime.setDate(dueDateTime.getDate() - notifyAtValue);
3084
+ if (notifyAtValue === 0) {
3085
+ const DEFAULT_MORNING_HOUR = 8;
3086
+ const appointmentHour = dueDateTime.getHours();
3087
+ if (appointmentHour > DEFAULT_MORNING_HOUR) {
3088
+ dueDateTime.setHours(DEFAULT_MORNING_HOUR, 0, 0, 0);
3089
+ } else {
3090
+ dueDateTime.setHours(Math.max(0, appointmentHour - 2), 0, 0, 0);
3091
+ }
3092
+ }
3084
3093
  } else if (template.timeframe.unit === "hours" /* HOURS */) {
3085
3094
  dueDateTime.setHours(dueDateTime.getHours() - notifyAtValue);
3086
3095
  }
@@ -3005,6 +3005,15 @@ var AppointmentAggregationService = class {
3005
3005
  const dueDateTime = new Date(appointment.appointmentStartTime.toMillis());
3006
3006
  if (template.timeframe.unit === "days" /* DAYS */) {
3007
3007
  dueDateTime.setDate(dueDateTime.getDate() - notifyAtValue);
3008
+ if (notifyAtValue === 0) {
3009
+ const DEFAULT_MORNING_HOUR = 8;
3010
+ const appointmentHour = dueDateTime.getHours();
3011
+ if (appointmentHour > DEFAULT_MORNING_HOUR) {
3012
+ dueDateTime.setHours(DEFAULT_MORNING_HOUR, 0, 0, 0);
3013
+ } else {
3014
+ dueDateTime.setHours(Math.max(0, appointmentHour - 2), 0, 0, 0);
3015
+ }
3016
+ }
3008
3017
  } else if (template.timeframe.unit === "hours" /* HOURS */) {
3009
3018
  dueDateTime.setHours(dueDateTime.getHours() - notifyAtValue);
3010
3019
  }
@@ -734,6 +734,14 @@ interface IProductService {
734
734
  * @param brandId - ID of the brand
735
735
  */
736
736
  getByBrand(brandId: string): Promise<Product[]>;
737
+ /**
738
+ * Exports products to CSV format
739
+ * @param options - Export options
740
+ */
741
+ exportToCsv(options?: {
742
+ includeInactive?: boolean;
743
+ includeBom?: boolean;
744
+ }): Promise<string>;
737
745
  /**
738
746
  * @deprecated Use createTopLevel instead
739
747
  * Creates a new product
@@ -734,6 +734,14 @@ interface IProductService {
734
734
  * @param brandId - ID of the brand
735
735
  */
736
736
  getByBrand(brandId: string): Promise<Product[]>;
737
+ /**
738
+ * Exports products to CSV format
739
+ * @param options - Export options
740
+ */
741
+ exportToCsv(options?: {
742
+ includeInactive?: boolean;
743
+ includeBom?: boolean;
744
+ }): Promise<string>;
737
745
  /**
738
746
  * @deprecated Use createTopLevel instead
739
747
  * Creates a new product
@@ -1878,11 +1878,19 @@ var ProductService = class extends BaseService {
1878
1878
  */
1879
1879
  async getAllTopLevel(options) {
1880
1880
  const { rowsPerPage, lastVisible, brandId, category } = options;
1881
+ console.log("[ProductService.getAllTopLevel] Called with:", {
1882
+ rowsPerPage,
1883
+ hasLastVisible: !!lastVisible,
1884
+ brandId: brandId || "none",
1885
+ category: category || "none"
1886
+ });
1881
1887
  const constraints = [(0, import_firestore8.where)("isActive", "==", true), (0, import_firestore8.orderBy)("name")];
1882
1888
  if (brandId) {
1889
+ console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
1883
1890
  constraints.push((0, import_firestore8.where)("brandId", "==", brandId));
1884
1891
  }
1885
1892
  if (category) {
1893
+ console.log("[ProductService.getAllTopLevel] Adding category filter:", category);
1886
1894
  constraints.push((0, import_firestore8.where)("category", "==", category));
1887
1895
  }
1888
1896
  if (lastVisible) {
@@ -1854,11 +1854,19 @@ var ProductService = class extends BaseService {
1854
1854
  */
1855
1855
  async getAllTopLevel(options) {
1856
1856
  const { rowsPerPage, lastVisible, brandId, category } = options;
1857
+ console.log("[ProductService.getAllTopLevel] Called with:", {
1858
+ rowsPerPage,
1859
+ hasLastVisible: !!lastVisible,
1860
+ brandId: brandId || "none",
1861
+ category: category || "none"
1862
+ });
1857
1863
  const constraints = [where6("isActive", "==", true), orderBy6("name")];
1858
1864
  if (brandId) {
1865
+ console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
1859
1866
  constraints.push(where6("brandId", "==", brandId));
1860
1867
  }
1861
1868
  if (category) {
1869
+ console.log("[ProductService.getAllTopLevel] Adding category filter:", category);
1862
1870
  constraints.push(where6("category", "==", category));
1863
1871
  }
1864
1872
  if (lastVisible) {
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Firestore, FieldValue, DocumentData, QueryDocumentSnapshot, Timestamp, DocumentSnapshot } from 'firebase/firestore';
1
+ import { Firestore, Timestamp, FieldValue, DocumentData, QueryDocumentSnapshot, DocumentSnapshot } from 'firebase/firestore';
2
2
  import { Auth, User as User$1 } from 'firebase/auth';
3
3
  import { FirebaseApp } from 'firebase/app';
4
4
  import { FirebaseStorage } from 'firebase/storage';
@@ -671,6 +671,14 @@ interface IProductService {
671
671
  * @param brandId - ID of the brand
672
672
  */
673
673
  getByBrand(brandId: string): Promise<Product[]>;
674
+ /**
675
+ * Exports products to CSV format
676
+ * @param options - Export options
677
+ */
678
+ exportToCsv(options?: {
679
+ includeInactive?: boolean;
680
+ includeBom?: boolean;
681
+ }): Promise<string>;
674
682
  /**
675
683
  * @deprecated Use createTopLevel instead
676
684
  * Creates a new product
@@ -1114,6 +1122,18 @@ declare enum UserRole {
1114
1122
  APP_ADMIN = "app_admin",
1115
1123
  CLINIC_ADMIN = "clinic_admin"
1116
1124
  }
1125
+ /**
1126
+ * Enum for acquisition source - how the user found out about the app
1127
+ */
1128
+ declare enum AcquisitionSource {
1129
+ FRIEND_FAMILY = "friend_family",
1130
+ ONLINE_SEARCH = "online_search",
1131
+ SOCIAL_MEDIA_AD = "social_media_ad",
1132
+ TRADITIONAL_AD = "traditional_ad",
1133
+ BLOG_ARTICLE = "blog_article",
1134
+ HEALTHCARE_PROVIDER = "healthcare_provider",
1135
+ OTHER = "other"
1136
+ }
1117
1137
  interface User {
1118
1138
  uid: string;
1119
1139
  email: string | null;
@@ -1125,6 +1145,12 @@ interface User {
1125
1145
  patientProfile?: string;
1126
1146
  practitionerProfile?: string;
1127
1147
  adminProfile?: string;
1148
+ /** How the user found out about the app (marketing attribution) */
1149
+ acquisitionSource?: AcquisitionSource | null;
1150
+ /** Custom text when acquisitionSource is 'other' */
1151
+ acquisitionSourceOther?: string | null;
1152
+ /** Timestamp when acquisition source was collected */
1153
+ acquisitionSourceTimestamp?: Timestamp | null;
1128
1154
  }
1129
1155
  interface CreateUserData {
1130
1156
  uid: string;
@@ -1134,6 +1160,9 @@ interface CreateUserData {
1134
1160
  createdAt: FieldValue;
1135
1161
  updatedAt: FieldValue;
1136
1162
  lastLoginAt: FieldValue;
1163
+ acquisitionSource?: AcquisitionSource | null;
1164
+ acquisitionSourceOther?: string | null;
1165
+ acquisitionSourceTimestamp?: FieldValue | Timestamp | null;
1137
1166
  }
1138
1167
  declare const USERS_COLLECTION = "users";
1139
1168
  type FirebaseUser = User$1;
@@ -8316,6 +8345,15 @@ declare class UserService extends BaseService {
8316
8345
  * Uklanja rolu korisniku i briše odgovarajući profil
8317
8346
  */
8318
8347
  removeRoleAndProfile(uid: string, role: UserRole): Promise<void>;
8348
+ /**
8349
+ * Updates the acquisition source information for a user
8350
+ * @param uid - User ID
8351
+ * @param data - Acquisition source data
8352
+ */
8353
+ updateAcquisitionSource(uid: string, data: {
8354
+ acquisitionSource: AcquisitionSource | null;
8355
+ acquisitionSourceOther?: string | null;
8356
+ }): Promise<void>;
8319
8357
  deleteUser(uid: string): Promise<void>;
8320
8358
  }
8321
8359
 
@@ -9204,4 +9242,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
9204
9242
  declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
9205
9243
  declare const getFirebaseFunctions: () => Promise<Functions>;
9206
9244
 
9207
- export { AESTHETIC_ANALYSIS_COLLECTION, ANALYTICS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, AnalyticsCloudService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, AnalyticsService, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AppointmentTrend, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseMetrics, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, type Break, CALENDAR_COLLECTION, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicAnalytics, type ClinicBranchSetupData, type ClinicComparisonMetrics, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CostPerPatientMetrics, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DASHBOARD_ANALYTICS_SUBCOLLECTION, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DashboardAnalytics, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DurationTrend, type DynamicTextElement, DynamicVariable, type EmergencyContact, type EntityType, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NextStepsRecommendation, type NoShowMetrics, type Notification, NotificationService, NotificationStatus, NotificationType, type OverallReviewAverages, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type ParagraphElement, type PatientAnalytics, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLifetimeValueMetrics, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientRetentionMetrics, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerAnalytics, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureAnalytics, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedurePopularity, type ProcedureProduct, type ProcedureProfitability, type ProcedureRecommendationNotification, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, type ProductRevenueMetrics, ProductService, type ProductUsageByProcedure, type ProductUsageMetrics, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVENUE_ANALYTICS_SUBCOLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type ReadStoredAnalyticsOptions, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAnalyticsMetrics, ReviewAnalyticsService, type ReviewDetail, type ReviewMetrics, type ReviewRequestNotification, ReviewService, type ReviewTrend, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeEfficiencyMetrics, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, type TrendPeriod, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
9245
+ export { AESTHETIC_ANALYSIS_COLLECTION, ANALYTICS_COLLECTION, APPOINTMENTS_COLLECTION, AcquisitionSource, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, AnalyticsCloudService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, AnalyticsService, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AppointmentTrend, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseMetrics, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, type Break, CALENDAR_COLLECTION, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicAnalytics, type ClinicBranchSetupData, type ClinicComparisonMetrics, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CostPerPatientMetrics, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DASHBOARD_ANALYTICS_SUBCOLLECTION, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DashboardAnalytics, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DurationTrend, type DynamicTextElement, DynamicVariable, type EmergencyContact, type EntityType, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NextStepsRecommendation, type NoShowMetrics, type Notification, NotificationService, NotificationStatus, NotificationType, type OverallReviewAverages, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type ParagraphElement, type PatientAnalytics, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLifetimeValueMetrics, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientRetentionMetrics, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerAnalytics, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureAnalytics, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedurePopularity, type ProcedureProduct, type ProcedureProfitability, type ProcedureRecommendationNotification, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, type ProductRevenueMetrics, ProductService, type ProductUsageByProcedure, type ProductUsageMetrics, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVENUE_ANALYTICS_SUBCOLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type ReadStoredAnalyticsOptions, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAnalyticsMetrics, ReviewAnalyticsService, type ReviewDetail, type ReviewMetrics, type ReviewRequestNotification, ReviewService, type ReviewTrend, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeEfficiencyMetrics, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, type TrendPeriod, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Firestore, FieldValue, DocumentData, QueryDocumentSnapshot, Timestamp, DocumentSnapshot } from 'firebase/firestore';
1
+ import { Firestore, Timestamp, FieldValue, DocumentData, QueryDocumentSnapshot, DocumentSnapshot } from 'firebase/firestore';
2
2
  import { Auth, User as User$1 } from 'firebase/auth';
3
3
  import { FirebaseApp } from 'firebase/app';
4
4
  import { FirebaseStorage } from 'firebase/storage';
@@ -671,6 +671,14 @@ interface IProductService {
671
671
  * @param brandId - ID of the brand
672
672
  */
673
673
  getByBrand(brandId: string): Promise<Product[]>;
674
+ /**
675
+ * Exports products to CSV format
676
+ * @param options - Export options
677
+ */
678
+ exportToCsv(options?: {
679
+ includeInactive?: boolean;
680
+ includeBom?: boolean;
681
+ }): Promise<string>;
674
682
  /**
675
683
  * @deprecated Use createTopLevel instead
676
684
  * Creates a new product
@@ -1114,6 +1122,18 @@ declare enum UserRole {
1114
1122
  APP_ADMIN = "app_admin",
1115
1123
  CLINIC_ADMIN = "clinic_admin"
1116
1124
  }
1125
+ /**
1126
+ * Enum for acquisition source - how the user found out about the app
1127
+ */
1128
+ declare enum AcquisitionSource {
1129
+ FRIEND_FAMILY = "friend_family",
1130
+ ONLINE_SEARCH = "online_search",
1131
+ SOCIAL_MEDIA_AD = "social_media_ad",
1132
+ TRADITIONAL_AD = "traditional_ad",
1133
+ BLOG_ARTICLE = "blog_article",
1134
+ HEALTHCARE_PROVIDER = "healthcare_provider",
1135
+ OTHER = "other"
1136
+ }
1117
1137
  interface User {
1118
1138
  uid: string;
1119
1139
  email: string | null;
@@ -1125,6 +1145,12 @@ interface User {
1125
1145
  patientProfile?: string;
1126
1146
  practitionerProfile?: string;
1127
1147
  adminProfile?: string;
1148
+ /** How the user found out about the app (marketing attribution) */
1149
+ acquisitionSource?: AcquisitionSource | null;
1150
+ /** Custom text when acquisitionSource is 'other' */
1151
+ acquisitionSourceOther?: string | null;
1152
+ /** Timestamp when acquisition source was collected */
1153
+ acquisitionSourceTimestamp?: Timestamp | null;
1128
1154
  }
1129
1155
  interface CreateUserData {
1130
1156
  uid: string;
@@ -1134,6 +1160,9 @@ interface CreateUserData {
1134
1160
  createdAt: FieldValue;
1135
1161
  updatedAt: FieldValue;
1136
1162
  lastLoginAt: FieldValue;
1163
+ acquisitionSource?: AcquisitionSource | null;
1164
+ acquisitionSourceOther?: string | null;
1165
+ acquisitionSourceTimestamp?: FieldValue | Timestamp | null;
1137
1166
  }
1138
1167
  declare const USERS_COLLECTION = "users";
1139
1168
  type FirebaseUser = User$1;
@@ -8316,6 +8345,15 @@ declare class UserService extends BaseService {
8316
8345
  * Uklanja rolu korisniku i briše odgovarajući profil
8317
8346
  */
8318
8347
  removeRoleAndProfile(uid: string, role: UserRole): Promise<void>;
8348
+ /**
8349
+ * Updates the acquisition source information for a user
8350
+ * @param uid - User ID
8351
+ * @param data - Acquisition source data
8352
+ */
8353
+ updateAcquisitionSource(uid: string, data: {
8354
+ acquisitionSource: AcquisitionSource | null;
8355
+ acquisitionSourceOther?: string | null;
8356
+ }): Promise<void>;
8319
8357
  deleteUser(uid: string): Promise<void>;
8320
8358
  }
8321
8359
 
@@ -9204,4 +9242,4 @@ declare const getFirebaseApp: () => Promise<FirebaseApp>;
9204
9242
  declare const getFirebaseStorage: () => Promise<FirebaseStorage>;
9205
9243
  declare const getFirebaseFunctions: () => Promise<Functions>;
9206
9244
 
9207
- export { AESTHETIC_ANALYSIS_COLLECTION, ANALYTICS_COLLECTION, APPOINTMENTS_COLLECTION, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, AnalyticsCloudService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, AnalyticsService, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AppointmentTrend, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseMetrics, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, type Break, CALENDAR_COLLECTION, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicAnalytics, type ClinicBranchSetupData, type ClinicComparisonMetrics, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CostPerPatientMetrics, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DASHBOARD_ANALYTICS_SUBCOLLECTION, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DashboardAnalytics, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DurationTrend, type DynamicTextElement, DynamicVariable, type EmergencyContact, type EntityType, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NextStepsRecommendation, type NoShowMetrics, type Notification, NotificationService, NotificationStatus, NotificationType, type OverallReviewAverages, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type ParagraphElement, type PatientAnalytics, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLifetimeValueMetrics, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientRetentionMetrics, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerAnalytics, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureAnalytics, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedurePopularity, type ProcedureProduct, type ProcedureProfitability, type ProcedureRecommendationNotification, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, type ProductRevenueMetrics, ProductService, type ProductUsageByProcedure, type ProductUsageMetrics, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVENUE_ANALYTICS_SUBCOLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type ReadStoredAnalyticsOptions, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAnalyticsMetrics, ReviewAnalyticsService, type ReviewDetail, type ReviewMetrics, type ReviewRequestNotification, ReviewService, type ReviewTrend, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeEfficiencyMetrics, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, type TrendPeriod, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
9245
+ export { AESTHETIC_ANALYSIS_COLLECTION, ANALYTICS_COLLECTION, APPOINTMENTS_COLLECTION, AcquisitionSource, type AddAllergyData, type AddBlockingConditionData, type AddContraindicationData, type AddMedicationData, type AddressData, type AdminInfo, type AdminToken, AdminTokenStatus, type AestheticAnalysis, type AestheticAnalysisStatus, type Allergy, type AllergySubtype, AllergyType, type AllergyTypeWithSubtype, AnalyticsCloudService, type AnalyticsDateRange, type AnalyticsFilters, type AnalyticsMetadata, type AnalyticsPeriod, AnalyticsService, type Appointment, type AppointmentCancelledNotification, type AppointmentMediaItem, type AppointmentMetadata, type AppointmentProductMetadata, type AppointmentReminderNotification, type AppointmentRescheduledProposalNotification, AppointmentService, AppointmentStatus, type AppointmentStatusChangeNotification, type AppointmentTrend, type AssessmentScales, AuthService, type BaseDocumentElement, type BaseMetrics, type BaseNotification, BaseService, type BeforeAfterPerZone, type BillingInfo, type BillingPerZone, type BillingTransaction, BillingTransactionType, BillingTransactionsService, type BinaryChoiceElement, BlockingCondition, type Brand, BrandService, type Break, CALENDAR_COLLECTION, CANCELLATION_ANALYTICS_SUBCOLLECTION, CLINICS_COLLECTION, CLINIC_ADMINS_COLLECTION, CLINIC_ANALYTICS_SUBCOLLECTION, CLINIC_GROUPS_COLLECTION, type CalendarEvent, CalendarEventStatus, type CalendarEventTime, CalendarEventType, CalendarServiceV2, CalendarServiceV3, CalendarSyncStatus, type CancellationMetrics, type CancellationRateTrend, type CancellationReasonStats, type Category, CategoryService, CertificationLevel, CertificationSpecialty, type Clinic, type ClinicAdmin, ClinicAdminService, type ClinicAdminSignupData, type ClinicAnalytics, type ClinicBranchSetupData, type ClinicComparisonMetrics, type ClinicContactInfo, type ClinicGroup, ClinicGroupService, type ClinicGroupSetupData, type ClinicInfo, type ClinicLocation, ClinicPhotoTag, type ClinicReview, type ClinicReviewInfo, ClinicService, ClinicTag, type ClinicTags, type ClinicalFindingDetail, type ClinicalFindings, ConstantsService, type ContactPerson, Contraindication, type ContraindicationDynamic, CosmeticAllergySubtype, type CostPerPatientMetrics, type CreateAdminTokenData, type CreateAestheticAnalysisData, type CreateAppointmentData, type CreateAppointmentHttpData, type CreateAppointmentParams, type CreateBillingTransactionData, type CreateBlockingEventParams, type CreateCalendarEventData, type CreateClinicAdminData, type CreateClinicData, type CreateClinicGroupData, type CreateDefaultClinicGroupData, type CreateDocumentTemplateData, type CreateDraftPractitionerData, type CreateManualPatientData, type CreatePatientLocationInfoData, type CreatePatientMedicalInfoData, type CreatePatientProfileData, type CreatePatientSensitiveInfoData, type CreatePatientTokenData, type CreatePractitionerData, type CreatePractitionerInviteData, type CreatePractitionerTokenData, type CreateProcedureData, type CreateSyncedCalendarData, type CreateUserData, Currency, DASHBOARD_ANALYTICS_SUBCOLLECTION, DEFAULT_MEDICAL_INFO, DOCTOR_FORMS_SUBCOLLECTION, DOCUMENTATION_TEMPLATES_COLLECTION, type DashboardAnalytics, type DatePickerElement, type DateRange, type DigitalSignatureElement, type DoctorInfo, type DocumentElement, DocumentElementType, type DocumentTemplate, DocumentationTemplateService, type DurationTrend, type DynamicTextElement, DynamicVariable, type EmergencyContact, type EntityType, EnvironmentalAllergySubtype, type ExtendedProcedureInfo, ExternalCalendarService, FILLED_DOCUMENTS_COLLECTION, type FileUploadElement, type FilledDocument, type FilledDocumentFileValue, FilledDocumentService, FilledDocumentStatus, type FinalBilling, type FirebaseUser, FoodAllergySubtype, type FormReminderNotification, type FormSubmissionConfirmationNotification, type GamificationInfo, Gender, type GeneralMessageNotification, type GroupedAnalyticsBase, type GroupedPatientBehaviorMetrics, type GroupedPatientRetentionMetrics, type GroupedPractitionerPerformanceMetrics, type GroupedProcedurePerformanceMetrics, type GroupedProductUsageMetrics, type GroupedRevenueMetrics, type GroupedTimeEfficiencyMetrics, type GroupingPeriod, type HeadingElement, HeadingLevel, INVITE_TOKENS_COLLECTION, Language, type LinkedFormInfo, type ListElement, ListType, type LocationData, MEDIA_METADATA_COLLECTION, MediaAccessLevel, type MediaMetadata, type MediaResource, MediaService, MediaType, MedicationAllergySubtype, type MultipleChoiceElement, NOTIFICATIONS_COLLECTION, NO_SHOW_ANALYTICS_SUBCOLLECTION, type NextStepsRecommendation, type NoShowMetrics, type Notification, NotificationService, NotificationStatus, NotificationType, type OverallReviewAverages, PATIENTS_COLLECTION, PATIENT_APPOINTMENTS_COLLECTION, PATIENT_LOCATION_INFO_COLLECTION, PATIENT_MEDICAL_HISTORY_COLLECTION, PATIENT_MEDICAL_INFO_COLLECTION, PATIENT_REQUIREMENTS_SUBCOLLECTION_NAME, PATIENT_SENSITIVE_INFO_COLLECTION, PRACTITIONERS_COLLECTION, PRACTITIONER_ANALYTICS_SUBCOLLECTION, PRACTITIONER_INVITES_COLLECTION, PROCEDURES_COLLECTION, PROCEDURE_ANALYTICS_SUBCOLLECTION, type ParagraphElement, type PatientAnalytics, type PatientClinic, type PatientDoctor, type PatientGoals, PatientInstructionStatus, type PatientLifetimeValueMetrics, type PatientLocationInfo, type PatientMedicalInfo, type PatientProfile, type PatientProfileComplete, type PatientProfileForDoctor, type PatientProfileInfo, type PatientRequirementInstance, type PatientRequirementInstruction, PatientRequirementOverallStatus, type PatientRequirementsFilters, PatientRequirementsService, type PatientRetentionMetrics, type PatientReviewInfo, type PatientSensitiveInfo, PatientService, type PatientToken, PatientTokenStatus, type PaymentConfirmationNotification, PaymentStatus, type PaymentStatusBreakdown, type PlanDetails, type PostRequirementNotification, PracticeType, type Practitioner, type PractitionerAnalytics, type PractitionerBasicInfo, type PractitionerCertification, type PractitionerClinicProcedures, type PractitionerClinicWorkingHours, type PractitionerInvite, type PractitionerInviteFilters, PractitionerInviteService, PractitionerInviteStatus, type PractitionerProfileInfo, type PractitionerReview, type PractitionerReviewInfo, PractitionerService, PractitionerStatus, type PractitionerToken, PractitionerTokenStatus, type PractitionerWorkingHours, type PreRequirementNotification, PricingMeasure, type Procedure, type ProcedureAnalytics, type ProcedureCategorization, type ProcedureExtendedInfo, ProcedureFamily, type ProcedureInfo, type ProcedurePopularity, type ProcedureProduct, type ProcedureProfitability, type ProcedureRecommendationNotification, type ProcedureReview, type ProcedureReviewInfo, ProcedureService, type ProcedureSummaryInfo, type Product, type ProductRevenueMetrics, ProductService, type ProductUsageByProcedure, type ProductUsageMetrics, type ProposedWorkingHours, REGISTER_TOKENS_COLLECTION, REVENUE_ANALYTICS_SUBCOLLECTION, REVIEWS_COLLECTION, type RatingScaleElement, type ReadStoredAnalyticsOptions, type RecommendedProcedure, type RequesterInfo, type Requirement, type RequirementInstructionDueNotification, type RequirementSourceProcedure, RequirementType, type RevenueMetrics, type RevenueTrend, type Review, type ReviewAnalyticsMetrics, ReviewAnalyticsService, type ReviewDetail, type ReviewMetrics, type ReviewRequestNotification, ReviewService, type ReviewTrend, SYNCED_CALENDARS_COLLECTION, type SearchAppointmentsParams, type SearchCalendarEventsParams, SearchLocationEnum, type SearchPatientsParams, type SignatureElement, type SingleChoiceElement, type StoredCancellationMetrics, type StoredClinicAnalytics, type StoredDashboardAnalytics, type StoredNoShowMetrics, type StoredPractitionerAnalytics, type StoredProcedureAnalytics, type StoredRevenueMetrics, type StoredTimeEfficiencyMetrics, type StripeTransactionData, type Subcategory, SubcategoryService, SubscriptionModel, SubscriptionStatus, type SyncedCalendar, type SyncedCalendarEvent, SyncedCalendarProvider, SyncedCalendarsService, TIME_EFFICIENCY_ANALYTICS_SUBCOLLECTION, type Technology, type TechnologyDocumentationTemplate, TechnologyService, type TextInputElement, type TimeEfficiencyMetrics, type TimeSlot, TimeUnit, TreatmentBenefit, type TreatmentBenefitDynamic, type TrendPeriod, USERS_COLLECTION, USER_FORMS_SUBCOLLECTION, type UpdateAestheticAnalysisData, type UpdateAllergyData, type UpdateAppointmentData, type UpdateAppointmentParams, type UpdateBlockingConditionData, type UpdateBlockingEventParams, type UpdateCalendarEventData, type UpdateClinicAdminData, type UpdateClinicData, type UpdateClinicGroupData, type UpdateContraindicationData, type UpdateDocumentTemplateData, type UpdateMedicationData, type UpdatePatientLocationInfoData, type UpdatePatientMedicalInfoData, type UpdatePatientProfileData, type UpdatePatientSensitiveInfoData, type UpdatePractitionerData, type UpdatePractitionerInviteData, type UpdateProcedureData, type UpdateSyncedCalendarData, type UpdateVitalStatsData, type User, UserRole, UserService, type VitalStats, type WorkingHours, type ZoneItemData, type ZonePhotoUploadData, getFirebaseApp, getFirebaseAuth, getFirebaseDB, getFirebaseFunctions, getFirebaseInstance, getFirebaseStorage, initializeFirebase };
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ __export(index_exports, {
33
33
  AESTHETIC_ANALYSIS_COLLECTION: () => AESTHETIC_ANALYSIS_COLLECTION,
34
34
  ANALYTICS_COLLECTION: () => ANALYTICS_COLLECTION,
35
35
  APPOINTMENTS_COLLECTION: () => APPOINTMENTS_COLLECTION,
36
+ AcquisitionSource: () => AcquisitionSource,
36
37
  AdminTokenStatus: () => AdminTokenStatus,
37
38
  AllergyType: () => AllergyType,
38
39
  AnalyticsCloudService: () => AnalyticsCloudService,
@@ -7231,6 +7232,16 @@ var UserRole = /* @__PURE__ */ ((UserRole2) => {
7231
7232
  UserRole2["CLINIC_ADMIN"] = "clinic_admin";
7232
7233
  return UserRole2;
7233
7234
  })(UserRole || {});
7235
+ var AcquisitionSource = /* @__PURE__ */ ((AcquisitionSource2) => {
7236
+ AcquisitionSource2["FRIEND_FAMILY"] = "friend_family";
7237
+ AcquisitionSource2["ONLINE_SEARCH"] = "online_search";
7238
+ AcquisitionSource2["SOCIAL_MEDIA_AD"] = "social_media_ad";
7239
+ AcquisitionSource2["TRADITIONAL_AD"] = "traditional_ad";
7240
+ AcquisitionSource2["BLOG_ARTICLE"] = "blog_article";
7241
+ AcquisitionSource2["HEALTHCARE_PROVIDER"] = "healthcare_provider";
7242
+ AcquisitionSource2["OTHER"] = "other";
7243
+ return AcquisitionSource2;
7244
+ })(AcquisitionSource || {});
7234
7245
  var USERS_COLLECTION = "users";
7235
7246
 
7236
7247
  // src/types/calendar/synced-calendar.types.ts
@@ -7366,6 +7377,7 @@ var passwordSchema = import_zod4.z.string().min(8, "Password must be at least 8
7366
7377
  );
7367
7378
  var userRoleSchema = import_zod4.z.nativeEnum(UserRole);
7368
7379
  var userRolesSchema = import_zod4.z.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
7380
+ var acquisitionSourceSchema = import_zod4.z.nativeEnum(AcquisitionSource);
7369
7381
  var clinicAdminOptionsSchema = import_zod4.z.object({
7370
7382
  isGroupOwner: import_zod4.z.boolean(),
7371
7383
  groupToken: import_zod4.z.string().optional(),
@@ -7397,7 +7409,10 @@ var userSchema = import_zod4.z.object({
7397
7409
  lastLoginAt: import_zod4.z.any(),
7398
7410
  patientProfile: import_zod4.z.string().optional(),
7399
7411
  practitionerProfile: import_zod4.z.string().optional(),
7400
- adminProfile: import_zod4.z.string().optional()
7412
+ adminProfile: import_zod4.z.string().optional(),
7413
+ acquisitionSource: acquisitionSourceSchema.nullable().optional(),
7414
+ acquisitionSourceOther: import_zod4.z.string().max(200).nullable().optional(),
7415
+ acquisitionSourceTimestamp: import_zod4.z.any().nullable().optional()
7401
7416
  });
7402
7417
 
7403
7418
  // src/errors/auth.errors.ts
@@ -13274,6 +13289,29 @@ var UserService = class extends BaseService {
13274
13289
  updatedAt: (0, import_firestore33.serverTimestamp)()
13275
13290
  });
13276
13291
  }
13292
+ /**
13293
+ * Updates the acquisition source information for a user
13294
+ * @param uid - User ID
13295
+ * @param data - Acquisition source data
13296
+ */
13297
+ async updateAcquisitionSource(uid, data) {
13298
+ const userRef = (0, import_firestore33.doc)(this.db, USERS_COLLECTION, uid);
13299
+ const userDoc = await (0, import_firestore33.getDoc)(userRef);
13300
+ if (!userDoc.exists()) {
13301
+ throw USER_ERRORS.NOT_FOUND;
13302
+ }
13303
+ const updateData = {
13304
+ acquisitionSource: data.acquisitionSource,
13305
+ acquisitionSourceTimestamp: import_firestore33.Timestamp.now(),
13306
+ updatedAt: (0, import_firestore33.serverTimestamp)()
13307
+ };
13308
+ if (data.acquisitionSource === "other" /* OTHER */) {
13309
+ updateData.acquisitionSourceOther = data.acquisitionSourceOther || null;
13310
+ } else {
13311
+ updateData.acquisitionSourceOther = null;
13312
+ }
13313
+ await (0, import_firestore33.updateDoc)(userRef, updateData);
13314
+ }
13277
13315
  // Delete operations
13278
13316
  async deleteUser(uid) {
13279
13317
  const userRef = (0, import_firestore33.doc)(this.db, USERS_COLLECTION, uid);
@@ -25285,11 +25323,19 @@ var ProductService = class extends BaseService {
25285
25323
  */
25286
25324
  async getAllTopLevel(options) {
25287
25325
  const { rowsPerPage, lastVisible, brandId, category } = options;
25326
+ console.log("[ProductService.getAllTopLevel] Called with:", {
25327
+ rowsPerPage,
25328
+ hasLastVisible: !!lastVisible,
25329
+ brandId: brandId || "none",
25330
+ category: category || "none"
25331
+ });
25288
25332
  const constraints = [(0, import_firestore65.where)("isActive", "==", true), (0, import_firestore65.orderBy)("name")];
25289
25333
  if (brandId) {
25334
+ console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
25290
25335
  constraints.push((0, import_firestore65.where)("brandId", "==", brandId));
25291
25336
  }
25292
25337
  if (category) {
25338
+ console.log("[ProductService.getAllTopLevel] Adding category filter:", category);
25293
25339
  constraints.push((0, import_firestore65.where)("category", "==", category));
25294
25340
  }
25295
25341
  if (lastVisible) {
@@ -25838,6 +25884,7 @@ var RequirementType = /* @__PURE__ */ ((RequirementType2) => {
25838
25884
  AESTHETIC_ANALYSIS_COLLECTION,
25839
25885
  ANALYTICS_COLLECTION,
25840
25886
  APPOINTMENTS_COLLECTION,
25887
+ AcquisitionSource,
25841
25888
  AdminTokenStatus,
25842
25889
  AllergyType,
25843
25890
  AnalyticsCloudService,
package/dist/index.mjs CHANGED
@@ -7137,6 +7137,16 @@ var UserRole = /* @__PURE__ */ ((UserRole2) => {
7137
7137
  UserRole2["CLINIC_ADMIN"] = "clinic_admin";
7138
7138
  return UserRole2;
7139
7139
  })(UserRole || {});
7140
+ var AcquisitionSource = /* @__PURE__ */ ((AcquisitionSource2) => {
7141
+ AcquisitionSource2["FRIEND_FAMILY"] = "friend_family";
7142
+ AcquisitionSource2["ONLINE_SEARCH"] = "online_search";
7143
+ AcquisitionSource2["SOCIAL_MEDIA_AD"] = "social_media_ad";
7144
+ AcquisitionSource2["TRADITIONAL_AD"] = "traditional_ad";
7145
+ AcquisitionSource2["BLOG_ARTICLE"] = "blog_article";
7146
+ AcquisitionSource2["HEALTHCARE_PROVIDER"] = "healthcare_provider";
7147
+ AcquisitionSource2["OTHER"] = "other";
7148
+ return AcquisitionSource2;
7149
+ })(AcquisitionSource || {});
7140
7150
  var USERS_COLLECTION = "users";
7141
7151
 
7142
7152
  // src/types/calendar/synced-calendar.types.ts
@@ -7272,6 +7282,7 @@ var passwordSchema = z4.string().min(8, "Password must be at least 8 characters"
7272
7282
  );
7273
7283
  var userRoleSchema = z4.nativeEnum(UserRole);
7274
7284
  var userRolesSchema = z4.array(userRoleSchema).min(1, "User must have at least one role").max(3, "User cannot have more than 3 roles");
7285
+ var acquisitionSourceSchema = z4.nativeEnum(AcquisitionSource);
7275
7286
  var clinicAdminOptionsSchema = z4.object({
7276
7287
  isGroupOwner: z4.boolean(),
7277
7288
  groupToken: z4.string().optional(),
@@ -7303,7 +7314,10 @@ var userSchema = z4.object({
7303
7314
  lastLoginAt: z4.any(),
7304
7315
  patientProfile: z4.string().optional(),
7305
7316
  practitionerProfile: z4.string().optional(),
7306
- adminProfile: z4.string().optional()
7317
+ adminProfile: z4.string().optional(),
7318
+ acquisitionSource: acquisitionSourceSchema.nullable().optional(),
7319
+ acquisitionSourceOther: z4.string().max(200).nullable().optional(),
7320
+ acquisitionSourceTimestamp: z4.any().nullable().optional()
7307
7321
  });
7308
7322
 
7309
7323
  // src/errors/auth.errors.ts
@@ -13297,6 +13311,29 @@ var UserService = class extends BaseService {
13297
13311
  updatedAt: serverTimestamp18()
13298
13312
  });
13299
13313
  }
13314
+ /**
13315
+ * Updates the acquisition source information for a user
13316
+ * @param uid - User ID
13317
+ * @param data - Acquisition source data
13318
+ */
13319
+ async updateAcquisitionSource(uid, data) {
13320
+ const userRef = doc21(this.db, USERS_COLLECTION, uid);
13321
+ const userDoc = await getDoc23(userRef);
13322
+ if (!userDoc.exists()) {
13323
+ throw USER_ERRORS.NOT_FOUND;
13324
+ }
13325
+ const updateData = {
13326
+ acquisitionSource: data.acquisitionSource,
13327
+ acquisitionSourceTimestamp: Timestamp18.now(),
13328
+ updatedAt: serverTimestamp18()
13329
+ };
13330
+ if (data.acquisitionSource === "other" /* OTHER */) {
13331
+ updateData.acquisitionSourceOther = data.acquisitionSourceOther || null;
13332
+ } else {
13333
+ updateData.acquisitionSourceOther = null;
13334
+ }
13335
+ await updateDoc17(userRef, updateData);
13336
+ }
13300
13337
  // Delete operations
13301
13338
  async deleteUser(uid) {
13302
13339
  const userRef = doc21(this.db, USERS_COLLECTION, uid);
@@ -25602,11 +25639,19 @@ var ProductService = class extends BaseService {
25602
25639
  */
25603
25640
  async getAllTopLevel(options) {
25604
25641
  const { rowsPerPage, lastVisible, brandId, category } = options;
25642
+ console.log("[ProductService.getAllTopLevel] Called with:", {
25643
+ rowsPerPage,
25644
+ hasLastVisible: !!lastVisible,
25645
+ brandId: brandId || "none",
25646
+ category: category || "none"
25647
+ });
25605
25648
  const constraints = [where39("isActive", "==", true), orderBy23("name")];
25606
25649
  if (brandId) {
25650
+ console.log("[ProductService.getAllTopLevel] Adding brandId filter:", brandId);
25607
25651
  constraints.push(where39("brandId", "==", brandId));
25608
25652
  }
25609
25653
  if (category) {
25654
+ console.log("[ProductService.getAllTopLevel] Adding category filter:", category);
25610
25655
  constraints.push(where39("category", "==", category));
25611
25656
  }
25612
25657
  if (lastVisible) {
@@ -26161,6 +26206,7 @@ export {
26161
26206
  AESTHETIC_ANALYSIS_COLLECTION,
26162
26207
  ANALYTICS_COLLECTION,
26163
26208
  APPOINTMENTS_COLLECTION,
26209
+ AcquisitionSource,
26164
26210
  AdminTokenStatus,
26165
26211
  AllergyType,
26166
26212
  AnalyticsCloudService,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.14.37",
4
+ "version": "1.14.43",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -59,6 +59,7 @@ This service is responsible for handling side effects and data aggregation tasks
59
59
  - **`createPreAppointmentRequirementInstances(appointment: Appointment)`**:
60
60
  - Creates `PatientRequirementInstance` documents for pre-appointment requirements based on `appointment.preProcedureRequirements`.
61
61
  - Calculates due times for instructions based on `appointment.appointmentStartTime`.
62
+ - **Same-day notification handling**: For `notifyAt: 0` with `unit: "days"`, notifications are sent at 8 AM instead of the appointment time. If the appointment is before 8 AM, the notification is sent 2 hours before the appointment.
62
63
  - Sets `actionableWindow` with a placeholder value (TODO noted).
63
64
  - Batch writes instances to Firestore.
64
65
  - **`createPostAppointmentRequirementInstances(appointment: Appointment)`**:
@@ -695,6 +695,21 @@ export class AppointmentAggregationService {
695
695
  const dueDateTime = new Date(appointment.appointmentStartTime.toMillis());
696
696
  if (template.timeframe.unit === TimeUnit.DAYS) {
697
697
  dueDateTime.setDate(dueDateTime.getDate() - notifyAtValue);
698
+
699
+ // Edge case: For "same day" PRE notifications (0 days before),
700
+ // send at morning time instead of appointment time
701
+ if (notifyAtValue === 0) {
702
+ const DEFAULT_MORNING_HOUR = 8;
703
+ const appointmentHour = dueDateTime.getHours();
704
+
705
+ if (appointmentHour > DEFAULT_MORNING_HOUR) {
706
+ // Appointment is after 8 AM - send notification at 8 AM
707
+ dueDateTime.setHours(DEFAULT_MORNING_HOUR, 0, 0, 0);
708
+ } else {
709
+ // Appointment is before/at 8 AM - send 2 hours before appointment
710
+ dueDateTime.setHours(Math.max(0, appointmentHour - 2), 0, 0, 0);
711
+ }
712
+ }
698
713
  } else if (template.timeframe.unit === TimeUnit.HOURS) {
699
714
  dueDateTime.setHours(dueDateTime.getHours() - notifyAtValue);
700
715
  }
@@ -295,13 +295,22 @@ export class ProductService extends BaseService implements IProductService {
295
295
  }): Promise<{ products: Product[]; lastVisible: any }> {
296
296
  const { rowsPerPage, lastVisible, brandId, category } = options;
297
297
 
298
+ console.log('[ProductService.getAllTopLevel] Called with:', {
299
+ rowsPerPage,
300
+ hasLastVisible: !!lastVisible,
301
+ brandId: brandId || 'none',
302
+ category: category || 'none',
303
+ });
304
+
298
305
  const constraints: QueryConstraint[] = [where('isActive', '==', true), orderBy('name')];
299
306
 
300
307
  if (brandId) {
308
+ console.log('[ProductService.getAllTopLevel] Adding brandId filter:', brandId);
301
309
  constraints.push(where('brandId', '==', brandId));
302
310
  }
303
311
 
304
312
  if (category) {
313
+ console.log('[ProductService.getAllTopLevel] Adding category filter:', category);
305
314
  constraints.push(where('category', '==', category));
306
315
  }
307
316
 
@@ -136,6 +136,15 @@ export interface IProductService {
136
136
  */
137
137
  getByBrand(brandId: string): Promise<Product[]>;
138
138
 
139
+ /**
140
+ * Exports products to CSV format
141
+ * @param options - Export options
142
+ */
143
+ exportToCsv(options?: {
144
+ includeInactive?: boolean;
145
+ includeBom?: boolean;
146
+ }): Promise<string>;
147
+
139
148
  // ==========================================
140
149
  // DEPRECATED METHODS: Kept for backward compatibility
141
150
  // ==========================================
@@ -13,7 +13,7 @@ import {
13
13
  serverTimestamp,
14
14
  } from 'firebase/firestore';
15
15
  import { initializeFirebase } from '../../config/firebase';
16
- import { User, UserRole, USERS_COLLECTION, CreateUserData } from '../../types';
16
+ import { User, UserRole, USERS_COLLECTION, CreateUserData, AcquisitionSource } from '../../types';
17
17
  import { userSchema } from '../../validations/schemas';
18
18
  import { AuthError } from '../../errors/auth.errors';
19
19
  import { USER_ERRORS } from '../../errors/user.errors';
@@ -453,6 +453,47 @@ export class UserService extends BaseService {
453
453
  });
454
454
  }
455
455
 
456
+ /**
457
+ * Updates the acquisition source information for a user
458
+ * @param uid - User ID
459
+ * @param data - Acquisition source data
460
+ */
461
+ async updateAcquisitionSource(
462
+ uid: string,
463
+ data: {
464
+ acquisitionSource: AcquisitionSource | null;
465
+ acquisitionSourceOther?: string | null;
466
+ }
467
+ ): Promise<void> {
468
+ const userRef = doc(this.db, USERS_COLLECTION, uid);
469
+ const userDoc = await getDoc(userRef);
470
+
471
+ if (!userDoc.exists()) {
472
+ throw USER_ERRORS.NOT_FOUND;
473
+ }
474
+
475
+ const updateData: {
476
+ acquisitionSource: AcquisitionSource | null;
477
+ acquisitionSourceOther?: string | null;
478
+ acquisitionSourceTimestamp: Timestamp;
479
+ updatedAt: ReturnType<typeof serverTimestamp>;
480
+ } = {
481
+ acquisitionSource: data.acquisitionSource,
482
+ acquisitionSourceTimestamp: Timestamp.now(),
483
+ updatedAt: serverTimestamp(),
484
+ };
485
+
486
+ // Only include acquisitionSourceOther if acquisitionSource is 'other'
487
+ if (data.acquisitionSource === AcquisitionSource.OTHER) {
488
+ updateData.acquisitionSourceOther = data.acquisitionSourceOther || null;
489
+ } else {
490
+ // Clear acquisitionSourceOther if not 'other'
491
+ updateData.acquisitionSourceOther = null;
492
+ }
493
+
494
+ await updateDoc(userRef, updateData);
495
+ }
496
+
456
497
  // Delete operations
457
498
  async deleteUser(uid: string): Promise<void> {
458
499
  const userRef = doc(this.db, USERS_COLLECTION, uid);
@@ -9,6 +9,19 @@ export enum UserRole {
9
9
  CLINIC_ADMIN = "clinic_admin",
10
10
  }
11
11
 
12
+ /**
13
+ * Enum for acquisition source - how the user found out about the app
14
+ */
15
+ export enum AcquisitionSource {
16
+ FRIEND_FAMILY = "friend_family",
17
+ ONLINE_SEARCH = "online_search",
18
+ SOCIAL_MEDIA_AD = "social_media_ad",
19
+ TRADITIONAL_AD = "traditional_ad",
20
+ BLOG_ARTICLE = "blog_article",
21
+ HEALTHCARE_PROVIDER = "healthcare_provider",
22
+ OTHER = "other",
23
+ }
24
+
12
25
  export interface User {
13
26
  uid: string;
14
27
  email: string | null;
@@ -20,6 +33,12 @@ export interface User {
20
33
  patientProfile?: string;
21
34
  practitionerProfile?: string;
22
35
  adminProfile?: string;
36
+ /** How the user found out about the app (marketing attribution) */
37
+ acquisitionSource?: AcquisitionSource | null;
38
+ /** Custom text when acquisitionSource is 'other' */
39
+ acquisitionSourceOther?: string | null;
40
+ /** Timestamp when acquisition source was collected */
41
+ acquisitionSourceTimestamp?: Timestamp | null;
23
42
  }
24
43
 
25
44
  export interface CreateUserData {
@@ -30,6 +49,9 @@ export interface CreateUserData {
30
49
  createdAt: FieldValue;
31
50
  updatedAt: FieldValue;
32
51
  lastLoginAt: FieldValue;
52
+ acquisitionSource?: AcquisitionSource | null;
53
+ acquisitionSourceOther?: string | null;
54
+ acquisitionSourceTimestamp?: FieldValue | Timestamp | null;
33
55
  }
34
56
 
35
57
  export const USERS_COLLECTION = "users";
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- import { UserRole } from "../types";
2
+ import { UserRole, AcquisitionSource } from "../types";
3
3
  import { Timestamp, FieldValue } from "firebase/firestore";
4
4
 
5
5
  export const emailSchema = z
@@ -24,6 +24,8 @@ export const userRolesSchema = z
24
24
  .min(1, "User must have at least one role")
25
25
  .max(3, "User cannot have more than 3 roles");
26
26
 
27
+ export const acquisitionSourceSchema = z.nativeEnum(AcquisitionSource);
28
+
27
29
  // export const timestampSchema = z.custom<Timestamp | FieldValue | Date>(
28
30
  // (data) => {
29
31
  // // If it's a serverTimestamp (FieldValue), it's valid
@@ -96,6 +98,9 @@ export const userSchema = z.object({
96
98
  patientProfile: z.string().optional(),
97
99
  practitionerProfile: z.string().optional(),
98
100
  adminProfile: z.string().optional(),
101
+ acquisitionSource: acquisitionSourceSchema.nullable().optional(),
102
+ acquisitionSourceOther: z.string().max(200).nullable().optional(),
103
+ acquisitionSourceTimestamp: z.any().nullable().optional(),
99
104
  });
100
105
 
101
106
  export type ValidationSchema = z.infer<typeof userSchema>;