@blackcode_sa/metaestetics-api 1.12.71 → 1.12.72

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/dist/index.js CHANGED
@@ -18095,38 +18095,23 @@ var ReviewService = class extends BaseService {
18095
18095
  */
18096
18096
  convertTimestamp(timestamp) {
18097
18097
  if (!timestamp) {
18098
- console.warn("\u26A0\uFE0F convertTimestamp received null/undefined timestamp");
18099
18098
  return /* @__PURE__ */ new Date();
18100
18099
  }
18101
- console.log("\u{1F50D} convertTimestamp input:", {
18102
- type: typeof timestamp,
18103
- value: timestamp,
18104
- hasToDate: (timestamp == null ? void 0 : timestamp.toDate) !== void 0,
18105
- hasIsTimestamp: (timestamp == null ? void 0 : timestamp.__isTimestamp) !== void 0,
18106
- hasSeconds: (timestamp == null ? void 0 : timestamp.seconds) !== void 0
18107
- });
18108
18100
  if (timestamp && timestamp.__isTimestamp === true && typeof timestamp.seconds === "number") {
18109
- const converted = new Date(timestamp.seconds * 1e3 + (timestamp.nanoseconds || 0) / 1e6);
18110
- console.log("\u2705 Converted __isTimestamp:", converted);
18111
- return converted;
18101
+ return new Date(timestamp.seconds * 1e3 + (timestamp.nanoseconds || 0) / 1e6);
18112
18102
  }
18113
18103
  if (timestamp && timestamp.toDate && typeof timestamp.toDate === "function") {
18114
- const converted = timestamp.toDate();
18115
- console.log("\u2705 Converted using toDate():", converted);
18116
- return converted;
18104
+ return timestamp.toDate();
18117
18105
  }
18118
18106
  if (timestamp instanceof Date) {
18119
- console.log("\u2705 Already a Date object:", timestamp);
18120
18107
  return timestamp;
18121
18108
  }
18122
18109
  if (typeof timestamp === "string" || typeof timestamp === "number") {
18123
18110
  const date = new Date(timestamp);
18124
18111
  if (!isNaN(date.getTime())) {
18125
- console.log("\u2705 Converted from string/number:", date);
18126
18112
  return date;
18127
18113
  }
18128
18114
  }
18129
- console.warn("\u26A0\uFE0F Could not convert timestamp, returning current date. Input was:", timestamp);
18130
18115
  return /* @__PURE__ */ new Date();
18131
18116
  }
18132
18117
  /**
@@ -18138,25 +18123,6 @@ var ReviewService = class extends BaseService {
18138
18123
  const review = docData;
18139
18124
  review.createdAt = this.convertTimestamp(docData.createdAt);
18140
18125
  review.updatedAt = this.convertTimestamp(docData.updatedAt);
18141
- if (review.clinicReview) {
18142
- review.clinicReview.createdAt = this.convertTimestamp(review.clinicReview.createdAt);
18143
- review.clinicReview.updatedAt = this.convertTimestamp(review.clinicReview.updatedAt);
18144
- }
18145
- if (review.practitionerReview) {
18146
- review.practitionerReview.createdAt = this.convertTimestamp(review.practitionerReview.createdAt);
18147
- review.practitionerReview.updatedAt = this.convertTimestamp(review.practitionerReview.updatedAt);
18148
- }
18149
- if (review.procedureReview) {
18150
- review.procedureReview.createdAt = this.convertTimestamp(review.procedureReview.createdAt);
18151
- review.procedureReview.updatedAt = this.convertTimestamp(review.procedureReview.updatedAt);
18152
- }
18153
- if (review.extendedProcedureReviews && Array.isArray(review.extendedProcedureReviews)) {
18154
- review.extendedProcedureReviews = review.extendedProcedureReviews.map((extReview) => ({
18155
- ...extReview,
18156
- createdAt: this.convertTimestamp(extReview.createdAt),
18157
- updatedAt: this.convertTimestamp(extReview.updatedAt)
18158
- }));
18159
- }
18160
18126
  return review;
18161
18127
  }
18162
18128
  /**
package/dist/index.mjs CHANGED
@@ -18353,38 +18353,23 @@ var ReviewService = class extends BaseService {
18353
18353
  */
18354
18354
  convertTimestamp(timestamp) {
18355
18355
  if (!timestamp) {
18356
- console.warn("\u26A0\uFE0F convertTimestamp received null/undefined timestamp");
18357
18356
  return /* @__PURE__ */ new Date();
18358
18357
  }
18359
- console.log("\u{1F50D} convertTimestamp input:", {
18360
- type: typeof timestamp,
18361
- value: timestamp,
18362
- hasToDate: (timestamp == null ? void 0 : timestamp.toDate) !== void 0,
18363
- hasIsTimestamp: (timestamp == null ? void 0 : timestamp.__isTimestamp) !== void 0,
18364
- hasSeconds: (timestamp == null ? void 0 : timestamp.seconds) !== void 0
18365
- });
18366
18358
  if (timestamp && timestamp.__isTimestamp === true && typeof timestamp.seconds === "number") {
18367
- const converted = new Date(timestamp.seconds * 1e3 + (timestamp.nanoseconds || 0) / 1e6);
18368
- console.log("\u2705 Converted __isTimestamp:", converted);
18369
- return converted;
18359
+ return new Date(timestamp.seconds * 1e3 + (timestamp.nanoseconds || 0) / 1e6);
18370
18360
  }
18371
18361
  if (timestamp && timestamp.toDate && typeof timestamp.toDate === "function") {
18372
- const converted = timestamp.toDate();
18373
- console.log("\u2705 Converted using toDate():", converted);
18374
- return converted;
18362
+ return timestamp.toDate();
18375
18363
  }
18376
18364
  if (timestamp instanceof Date) {
18377
- console.log("\u2705 Already a Date object:", timestamp);
18378
18365
  return timestamp;
18379
18366
  }
18380
18367
  if (typeof timestamp === "string" || typeof timestamp === "number") {
18381
18368
  const date = new Date(timestamp);
18382
18369
  if (!isNaN(date.getTime())) {
18383
- console.log("\u2705 Converted from string/number:", date);
18384
18370
  return date;
18385
18371
  }
18386
18372
  }
18387
- console.warn("\u26A0\uFE0F Could not convert timestamp, returning current date. Input was:", timestamp);
18388
18373
  return /* @__PURE__ */ new Date();
18389
18374
  }
18390
18375
  /**
@@ -18396,25 +18381,6 @@ var ReviewService = class extends BaseService {
18396
18381
  const review = docData;
18397
18382
  review.createdAt = this.convertTimestamp(docData.createdAt);
18398
18383
  review.updatedAt = this.convertTimestamp(docData.updatedAt);
18399
- if (review.clinicReview) {
18400
- review.clinicReview.createdAt = this.convertTimestamp(review.clinicReview.createdAt);
18401
- review.clinicReview.updatedAt = this.convertTimestamp(review.clinicReview.updatedAt);
18402
- }
18403
- if (review.practitionerReview) {
18404
- review.practitionerReview.createdAt = this.convertTimestamp(review.practitionerReview.createdAt);
18405
- review.practitionerReview.updatedAt = this.convertTimestamp(review.practitionerReview.updatedAt);
18406
- }
18407
- if (review.procedureReview) {
18408
- review.procedureReview.createdAt = this.convertTimestamp(review.procedureReview.createdAt);
18409
- review.procedureReview.updatedAt = this.convertTimestamp(review.procedureReview.updatedAt);
18410
- }
18411
- if (review.extendedProcedureReviews && Array.isArray(review.extendedProcedureReviews)) {
18412
- review.extendedProcedureReviews = review.extendedProcedureReviews.map((extReview) => ({
18413
- ...extReview,
18414
- createdAt: this.convertTimestamp(extReview.createdAt),
18415
- updatedAt: this.convertTimestamp(extReview.updatedAt)
18416
- }));
18417
- }
18418
18384
  return review;
18419
18385
  }
18420
18386
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@blackcode_sa/metaestetics-api",
3
3
  "private": false,
4
- "version": "1.12.71",
4
+ "version": "1.12.72",
5
5
  "description": "Firebase authentication service with anonymous upgrade support",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",
@@ -35,37 +35,22 @@ export class ReviewService extends BaseService {
35
35
  * @returns A JavaScript Date object or null
36
36
  */
37
37
  private convertTimestamp(timestamp: any): Date {
38
- // Log what we receive for debugging
39
38
  if (!timestamp) {
40
- console.warn('⚠️ convertTimestamp received null/undefined timestamp');
41
39
  return new Date();
42
40
  }
43
41
 
44
- console.log('🔍 convertTimestamp input:', {
45
- type: typeof timestamp,
46
- value: timestamp,
47
- hasToDate: timestamp?.toDate !== undefined,
48
- hasIsTimestamp: timestamp?.__isTimestamp !== undefined,
49
- hasSeconds: timestamp?.seconds !== undefined,
50
- });
51
-
52
42
  // Firebase Timestamp object with __isTimestamp
53
43
  if (timestamp && timestamp.__isTimestamp === true && typeof timestamp.seconds === 'number') {
54
- const converted = new Date(timestamp.seconds * 1000 + (timestamp.nanoseconds || 0) / 1000000);
55
- console.log('✅ Converted __isTimestamp:', converted);
56
- return converted;
44
+ return new Date(timestamp.seconds * 1000 + (timestamp.nanoseconds || 0) / 1000000);
57
45
  }
58
46
 
59
47
  // Firebase Firestore Timestamp with toDate method
60
48
  if (timestamp && timestamp.toDate && typeof timestamp.toDate === 'function') {
61
- const converted = timestamp.toDate();
62
- console.log('✅ Converted using toDate():', converted);
63
- return converted;
49
+ return timestamp.toDate();
64
50
  }
65
51
 
66
52
  // Already a Date object
67
53
  if (timestamp instanceof Date) {
68
- console.log('✅ Already a Date object:', timestamp);
69
54
  return timestamp;
70
55
  }
71
56
 
@@ -73,12 +58,10 @@ export class ReviewService extends BaseService {
73
58
  if (typeof timestamp === 'string' || typeof timestamp === 'number') {
74
59
  const date = new Date(timestamp);
75
60
  if (!isNaN(date.getTime())) {
76
- console.log('✅ Converted from string/number:', date);
77
61
  return date;
78
62
  }
79
63
  }
80
64
 
81
- console.warn('⚠️ Could not convert timestamp, returning current date. Input was:', timestamp);
82
65
  return new Date();
83
66
  }
84
67
 
@@ -90,37 +73,10 @@ export class ReviewService extends BaseService {
90
73
  private convertDocToReview(docData: any): Review {
91
74
  const review = docData as Review;
92
75
 
93
- // Convert main review timestamps
76
+ // Convert main review timestamps (all sub-reviews share the same creation date)
94
77
  review.createdAt = this.convertTimestamp(docData.createdAt);
95
78
  review.updatedAt = this.convertTimestamp(docData.updatedAt);
96
79
 
97
- // Convert clinic review timestamps if present
98
- if (review.clinicReview) {
99
- review.clinicReview.createdAt = this.convertTimestamp(review.clinicReview.createdAt);
100
- review.clinicReview.updatedAt = this.convertTimestamp(review.clinicReview.updatedAt);
101
- }
102
-
103
- // Convert practitioner review timestamps if present
104
- if (review.practitionerReview) {
105
- review.practitionerReview.createdAt = this.convertTimestamp(review.practitionerReview.createdAt);
106
- review.practitionerReview.updatedAt = this.convertTimestamp(review.practitionerReview.updatedAt);
107
- }
108
-
109
- // Convert procedure review timestamps if present
110
- if (review.procedureReview) {
111
- review.procedureReview.createdAt = this.convertTimestamp(review.procedureReview.createdAt);
112
- review.procedureReview.updatedAt = this.convertTimestamp(review.procedureReview.updatedAt);
113
- }
114
-
115
- // Convert extended procedure reviews timestamps if present
116
- if (review.extendedProcedureReviews && Array.isArray(review.extendedProcedureReviews)) {
117
- review.extendedProcedureReviews = review.extendedProcedureReviews.map(extReview => ({
118
- ...extReview,
119
- createdAt: this.convertTimestamp(extReview.createdAt),
120
- updatedAt: this.convertTimestamp(extReview.updatedAt),
121
- }));
122
- }
123
-
124
80
  return review;
125
81
  }
126
82
 
@@ -1,65 +0,0 @@
1
- # Review Date Timestamp Fix
2
-
3
- ## Problem
4
- All reviews in the Patient App were displaying the same date (e.g., "September 26, 2025") regardless of when they were actually created. This was causing confusion as users couldn't distinguish between reviews from different dates.
5
-
6
- ## Root Cause
7
- When fetching reviews from Firestore, the `createdAt` and `updatedAt` fields were Firestore Timestamp objects that weren't being properly converted to JavaScript Date objects. The code was using:
8
-
9
- ```typescript
10
- const reviews = snapshot.docs.map(doc => doc.data() as Review);
11
- ```
12
-
13
- This direct type casting doesn't convert Firestore Timestamps (which have `seconds` and `nanoseconds` properties) into proper Date objects, leading to inconsistent date handling across the application.
14
-
15
- ## Solution
16
- Added two helper methods to the `ReviewService` class:
17
-
18
- ### 1. `convertTimestamp(timestamp: any): Date`
19
- Converts various timestamp formats to JavaScript Date objects:
20
- - Firestore Timestamp with `__isTimestamp` flag
21
- - Firestore Timestamp with `toDate()` method
22
- - Regular Date objects
23
- - String or number timestamps
24
- - Fallback to current date for invalid inputs
25
-
26
- ### 2. `convertDocToReview(docData: any): Review`
27
- Converts raw Firestore document data to a properly formatted Review object by:
28
- - Converting main review timestamps (`createdAt`, `updatedAt`)
29
- - Converting clinic review timestamps if present
30
- - Converting practitioner review timestamps if present
31
- - Converting procedure review timestamps if present
32
- - Converting extended procedure reviews timestamps if present
33
-
34
- ## Changes Made
35
-
36
- ### Files Modified
37
- - `Api/src/services/reviews/reviews.service.ts`
38
-
39
- ### Methods Updated
40
- All review fetching methods now use `convertDocToReview()`:
41
- 1. `getReviewsByPatient(patientId: string)` - Line 372
42
- 2. `getReviewsByClinic(clinicId: string)` - Line 443
43
- 3. `getReviewsByPractitioner(practitionerId: string)` - Line 538
44
- 4. `getReview(reviewId: string)` - Line 285
45
- 5. `getReviewByAppointment(appointmentId: string)` - Line 723
46
-
47
- ## Package Version
48
- - **Published Version**: `@blackcode_sa/metaestetics-api@1.12.70`
49
- - **Change Type**: Patch (bug fix)
50
-
51
- ## Apps Updated
52
- All apps have been updated to use version 1.12.70:
53
- - ✅ Mobile (Patient App)
54
- - ✅ DoctorMobile
55
- - ✅ ClinicApp
56
-
57
- ## Testing
58
- After updating, verify that:
59
- 1. Reviews display their actual creation dates
60
- 2. Each review shows a different date (if created on different days)
61
- 3. Dates are formatted correctly in the format: "Month Day, Year" (e.g., "September 26, 2025")
62
-
63
- ## Impact
64
- This fix ensures that all review dates are properly displayed across all applications, allowing users to accurately track when feedback was submitted.
65
-