@blackcode_sa/metaestetics-api 1.14.46 → 1.14.49

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.
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.46",
4
+ "version": "1.14.49",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -2200,6 +2200,34 @@ export class AppointmentService extends BaseService {
2200
2200
  }
2201
2201
  }
2202
2202
 
2203
+ /**
2204
+ * Updates visibility of notes for a zone item (product or standalone note)
2205
+ *
2206
+ * @param appointmentId ID of the appointment
2207
+ * @param zoneId Zone ID
2208
+ * @param itemIndex Index of the item in the zone
2209
+ * @param notesVisibleToPatient Whether the notes should be visible to patient
2210
+ * @returns The updated appointment
2211
+ */
2212
+ async updateZoneItemNoteVisibility(
2213
+ appointmentId: string,
2214
+ zoneId: string,
2215
+ itemIndex: number,
2216
+ notesVisibleToPatient: boolean,
2217
+ ): Promise<Appointment> {
2218
+ try {
2219
+ console.log(
2220
+ `[APPOINTMENT_SERVICE] Updating zone item note visibility at index ${itemIndex} for zone ${zoneId} to ${notesVisibleToPatient}`,
2221
+ );
2222
+ return await updateZoneItemUtil(this.db, appointmentId, zoneId, itemIndex, {
2223
+ notesVisibleToPatient,
2224
+ });
2225
+ } catch (error) {
2226
+ console.error(`[APPOINTMENT_SERVICE] Error updating zone item note visibility:`, error);
2227
+ throw error;
2228
+ }
2229
+ }
2230
+
2203
2231
  /**
2204
2232
  * Gets a specific photo entry from a zone
2205
2233
  *
@@ -2238,6 +2266,12 @@ export class AppointmentService extends BaseService {
2238
2266
  internalNotes?: string | null,
2239
2267
  ): Promise<Appointment> {
2240
2268
  try {
2269
+ console.log('🔍 [APPOINTMENT_SERVICE] updateFinalizationNotes called:', {
2270
+ appointmentId,
2271
+ sharedNotes,
2272
+ internalNotes,
2273
+ });
2274
+
2241
2275
  const appointment = await this.getAppointmentById(appointmentId);
2242
2276
  if (!appointment) {
2243
2277
  throw new Error(`Appointment ${appointmentId} not found`);
@@ -2256,29 +2290,51 @@ export class AppointmentService extends BaseService {
2256
2290
  finalizationNotes: null,
2257
2291
  };
2258
2292
 
2293
+ console.log('🔍 [APPOINTMENT_SERVICE] Current metadata:', {
2294
+ finalizationNotesShared: currentMetadata.finalizationNotesShared,
2295
+ finalizationNotesInternal: currentMetadata.finalizationNotesInternal,
2296
+ finalizationNotes: currentMetadata.finalizationNotes,
2297
+ });
2298
+
2299
+ const metadataUpdate = {
2300
+ selectedZones: currentMetadata.selectedZones,
2301
+ zonePhotos: currentMetadata.zonePhotos,
2302
+ zonesData: currentMetadata.zonesData || null,
2303
+ appointmentProducts: currentMetadata.appointmentProducts || [],
2304
+ extendedProcedures: currentMetadata.extendedProcedures || [],
2305
+ recommendedProcedures: currentMetadata.recommendedProcedures || [],
2306
+ finalbilling: currentMetadata.finalbilling,
2307
+ finalizationNotesShared:
2308
+ sharedNotes !== undefined ? sharedNotes : currentMetadata.finalizationNotesShared,
2309
+ finalizationNotesInternal:
2310
+ internalNotes !== undefined ? internalNotes : currentMetadata.finalizationNotesInternal,
2311
+ // Keep deprecated field for backward compatibility during migration
2312
+ finalizationNotes:
2313
+ sharedNotes !== undefined
2314
+ ? sharedNotes
2315
+ : currentMetadata.finalizationNotes || currentMetadata.finalizationNotesShared,
2316
+ };
2317
+
2318
+ console.log('🔍 [APPOINTMENT_SERVICE] Update data metadata:', {
2319
+ finalizationNotesShared: metadataUpdate.finalizationNotesShared,
2320
+ finalizationNotesInternal: metadataUpdate.finalizationNotesInternal,
2321
+ finalizationNotes: metadataUpdate.finalizationNotes,
2322
+ });
2323
+
2259
2324
  const updateData: UpdateAppointmentData = {
2260
- metadata: {
2261
- selectedZones: currentMetadata.selectedZones,
2262
- zonePhotos: currentMetadata.zonePhotos,
2263
- zonesData: currentMetadata.zonesData || null,
2264
- appointmentProducts: currentMetadata.appointmentProducts || [],
2265
- extendedProcedures: currentMetadata.extendedProcedures || [],
2266
- recommendedProcedures: currentMetadata.recommendedProcedures || [],
2267
- finalbilling: currentMetadata.finalbilling,
2268
- finalizationNotesShared:
2269
- sharedNotes !== undefined ? sharedNotes : currentMetadata.finalizationNotesShared,
2270
- finalizationNotesInternal:
2271
- internalNotes !== undefined ? internalNotes : currentMetadata.finalizationNotesInternal,
2272
- // Keep deprecated field for backward compatibility during migration
2273
- finalizationNotes:
2274
- sharedNotes !== undefined
2275
- ? sharedNotes
2276
- : currentMetadata.finalizationNotes || currentMetadata.finalizationNotesShared,
2277
- },
2325
+ metadata: metadataUpdate,
2278
2326
  updatedAt: serverTimestamp(),
2279
2327
  };
2280
2328
 
2281
- return await this.updateAppointment(appointmentId, updateData);
2329
+ const result = await this.updateAppointment(appointmentId, updateData);
2330
+
2331
+ console.log('🔍 [APPOINTMENT_SERVICE] After update, result metadata:', {
2332
+ finalizationNotesShared: result.metadata?.finalizationNotesShared,
2333
+ finalizationNotesInternal: result.metadata?.finalizationNotesInternal,
2334
+ finalizationNotes: result.metadata?.finalizationNotes,
2335
+ });
2336
+
2337
+ return result;
2282
2338
  } catch (error) {
2283
2339
  console.error(`[APPOINTMENT_SERVICE] Error updating finalization notes:`, error);
2284
2340
  throw error;
@@ -1,4 +1,4 @@
1
- import { Firestore, updateDoc, serverTimestamp, doc } from 'firebase/firestore';
1
+ import { Firestore, updateDoc, serverTimestamp, doc, Timestamp } from 'firebase/firestore';
2
2
  import {
3
3
  Appointment,
4
4
  BeforeAfterPerZone,
@@ -9,6 +9,9 @@ import { MediaResource } from '../../media/media.service';
9
9
 
10
10
  /**
11
11
  * Updates visibility fields with audit trail
12
+ * Note: We use Timestamp.now() instead of serverTimestamp() because Firestore
13
+ * doesn't support serverTimestamp() inside arrays. The timestamp will be set
14
+ * on the client side, which is acceptable for audit purposes.
12
15
  * @param updates Partial updates object
13
16
  * @param doctorId ID of the doctor making the change
14
17
  */
@@ -24,7 +27,7 @@ function addVisibilityAudit(
24
27
  ) {
25
28
  return {
26
29
  ...updates,
27
- visibilityUpdatedAt: serverTimestamp() as any,
30
+ visibilityUpdatedAt: Timestamp.now(), // Use client-side timestamp (Firestore limitation)
28
31
  visibilityUpdatedBy: doctorId,
29
32
  };
30
33
  }
@@ -166,6 +166,7 @@ export interface ZoneItemData {
166
166
  parentZone: string; // Zone key in format "category.zone" (e.g., "face.forehead")
167
167
  subzones: string[];
168
168
  notes?: string;
169
+ notesVisibleToPatient?: boolean; // Whether notes are visible to patient (privacy-first, default false)
169
170
  subtotal?: number;
170
171
  ionNumber?: string;
171
172
  createdAt?: string; // ISO timestamp