@mohasinac/appkit 4.42.15 → 4.42.16
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.
|
@@ -21,6 +21,7 @@ import { normalizeError } from "../../../../errors/normalize";
|
|
|
21
21
|
import { serverLogger } from "../../../../monitoring";
|
|
22
22
|
import { ValidationError } from "../../../../errors";
|
|
23
23
|
import { ORDER_FIELDS } from "../../../../constants/field-names";
|
|
24
|
+
import { firestoreTimestampToDate } from "../../../../utils/type.converter";
|
|
24
25
|
import { PRODUCT_COLLECTION, PRODUCT_CODES_SUBCOLLECTION, } from "../../../../features/products/schemas/firestore";
|
|
25
26
|
/**
|
|
26
27
|
* Where a delivered asset's bytes live.
|
|
@@ -181,8 +182,28 @@ export async function listPoolEntries(productId) {
|
|
|
181
182
|
status: c.status,
|
|
182
183
|
...(c.fileName ? { fileName: c.fileName } : {}),
|
|
183
184
|
...(c.orderId ? { orderId: c.orderId } : {}),
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
/*
|
|
186
|
+
* 🛑 firestoreTimestampToDate, never `new Date(value)`.
|
|
187
|
+
*
|
|
188
|
+
* addPoolEntries writes `createdAt: new Date()`, and the Admin SDK stores
|
|
189
|
+
* that as a Firestore Timestamp and reads it back as one — NOT as a Date.
|
|
190
|
+
* `new Date(aTimestamp)` is an Invalid Date, and `.toISOString()` on an
|
|
191
|
+
* Invalid Date THROWS RangeError, so this map took the whole route down
|
|
192
|
+
* with a 500.
|
|
193
|
+
*
|
|
194
|
+
* It hid for as long as it possibly could: mapping over ZERO documents
|
|
195
|
+
* never throws, so GET answered `[]` for the entire period the pool had
|
|
196
|
+
* no writer (Root Cause #103) and only began failing once the first entry
|
|
197
|
+
* existed. The seller then saw "Nothing in the pool yet" — the component
|
|
198
|
+
* rendering a failed load as an empty state — and the rational response
|
|
199
|
+
* is to add the codes again, which silently accumulates duplicates.
|
|
200
|
+
*/
|
|
201
|
+
...(c.claimedAt
|
|
202
|
+
? { claimedAt: firestoreTimestampToDate(c.claimedAt).toISOString() }
|
|
203
|
+
: {}),
|
|
204
|
+
...(c.createdAt
|
|
205
|
+
? { createdAt: firestoreTimestampToDate(c.createdAt).toISOString() }
|
|
206
|
+
: {}),
|
|
186
207
|
};
|
|
187
208
|
});
|
|
188
209
|
}
|