Release/v8001.0.0 - #255
Conversation
|
Warning Review limit reached
On-demand reviews are free for the next 16 days. After that, they cost $0.25 per reviewed file. View limit detailsReview configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (199)
Comment |
| return documentClassInfoJson | ||
| } | ||
|
|
||
| private fun serializeClassInfoComponent(idName: String?, rawValue: String): JSONObject { |
There was a problem hiding this comment.
Android emits invalid DocumentTypeID values. BlinkIdSerializationUtilities.kt:341 lowercases only the first enum-name character. For example, MyPr, MyPolis, and MySSSCard become myPr, myPolis, and mySSSCard, while the declared/iOS values are myPR, mypolis, and mysssCard. Android results therefore violate the public type and cross-platform comparisons fail. Use canonical raw-value mappings.
Fix, and check if there are other values that need to be transformed
private fun serializeClassInfoComponent(idName: String?, rawValue: String): JSONObject {
val json = JSONObject()
idName?.let {
json.put("id", serializeClassInfoId(it))
}
json.put("rawValue", rawValue)
return json
}
private fun serializeClassInfoId(idName: String): String = when (idName) {
// These Android enum names do not preserve the public casing used by iOS and TypeScript.
"MyPr" -> "myPR"
"MyPolis" -> "mypolis"
"MySSSCard" -> "mysssCard"
else -> idName.replaceFirstChar { char -> char.lowercase() }
}There was a problem hiding this comment.
The mapping should define a canonical React Native wire contract rather than treating either platform’s native spelling as authoritative. Since this is a major release, we should also correct existing misspellings and casing in the TypeScript contract:
export const RegionID = {
// ...
SaoPaolo: "saoPaolo",
RioDeJaneiro: "rioDeJaneiro",
NorthwestTerritories: "northwestTerritories",
Alagoas: "alagoas",
} as const;
export const DocumentTypeID = {
// ...
DrivingPrivilegeCard: "drivingPrivilegeCard",
Eid: "eid",
MyPr: "myPR",
MyPolis: "mypolis",
MysssCard: "mysssCard",
} as const;Native bridges should translate exceptional native spellings to these values and otherwise use lower camel case:
private fun serializeDocumentTypeId(id: DocumentTypeId): String =
when (id) {
DocumentTypeId.MyPr -> "myPR"
DocumentTypeId.MyPolis -> "mypolis"
DocumentTypeId.MySSSCard -> "mysssCard"
else -> id.name.replaceFirstChar { it.lowercase() }
}This gives Android, iOS, and TypeScript one meaningful contract and prevents known IDs from becoming platform-dependent strings.
|
|
||
| private fun serializeDocumentClassInfo(documentClassInfo: DocumentClassInfo): JSONObject { | ||
| val documentClassInfoJson = JSONObject() | ||
| // TODO: Align country/region/documentType strings with iOS (rawValue). Android uses |
There was a problem hiding this comment.
Remove todo after comment is fixed.
There was a problem hiding this comment.
Once the explicit country, region, and document-type mappings are implemented, this TODO becomes misleading because the platforms will no longer rely on incompatible native spellings.
Remove it as part of the mapping fix:
-// TODO: Align country/region/documentType strings with iOS (rawValue).
-// Android uses enum.name with only the first character lowercased; values
-// usually match but are not guaranteed identical for every enum.
-// Prefer shared explicit string mappers on both platforms.Keeping the TODO after introducing the canonical wrapper mappings would incorrectly suggest that the cross-platform contract is still unresolved.
| } | ||
|
|
||
| private fun serializeDocumentClassInfo(documentClassInfo: DocumentClassInfo): JSONObject { | ||
| val documentClassInfoJson = JSONObject() |
There was a problem hiding this comment.
Android no longer returns DocumentClassInfo.empty. BlinkIdSerializationUtilities.kt:335 removes the previous serialization without removing the public property; iOS still returns it. Existing Android consumers checking documentClassInfo.empty now receive undefined.
val documentClassInfoJson = JSONObject()
val classIds = listOf(
documentClassInfo.country?.id?.name,
documentClassInfo.region?.id?.name,
documentClassInfo.documentType?.id?.name
)
documentClassInfoJson.put(
"empty",
classIds.any { it == null } || classIds.all { it == "None" }
)| @@ -239,16 +242,42 @@ class BlinkIdSerializationUtils { | |||
| // TODO: Align country/region/documentType strings with Android (enum.name lowercased). | |||
There was a problem hiding this comment.
Remove TODO after comment is fixed.
There was a problem hiding this comment.
Once iOS translates its native raw values to the canonical React Native identifiers, this TODO should be removed:
-// TODO: Align country/region/documentType strings with Android
-// (enum.name lowercased). iOS uses rawValue here; values usually match
-// TypeScript types but are not guaranteed identical for every enum.
-// Prefer shared explicit string mappers on both platforms.The explicit mapper becomes the source of truth, so retaining the TODO would incorrectly imply that platform consistency is still unresolved.
No description provided.