@opendoor/partner-sdk-server-js-core 1.0.6-beta.55.1 → 1.0.7-beta.56.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answerKeyMapping.d.ts","sourceRoot":"","sources":["../src/answerKeyMapping.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"answerKeyMapping.d.ts","sourceRoot":"","sources":["../src/answerKeyMapping.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAgGH;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2GzB"}
|
package/dist/answerKeyMapping.js
CHANGED
|
@@ -54,11 +54,36 @@ const DOT_TO_CAMEL = {
|
|
|
54
54
|
'seller.email': 'sellerEmail',
|
|
55
55
|
'seller.phone_number': 'sellerPhoneNumber',
|
|
56
56
|
'seller.sms_opt_in': 'sellerSmsOptIn',
|
|
57
|
+
// Seller details (DTC onboarding flow)
|
|
58
|
+
'seller.relation_to_owner': 'sellerRelationToOwner',
|
|
59
|
+
'seller.relation_to_owner.other': 'sellerRelationToOwnerOther',
|
|
60
|
+
'seller.sale_timeline': 'sellerSaleTimeline',
|
|
61
|
+
'seller.working_with_home_builder': 'sellerWorkingWithHomeBuilder',
|
|
62
|
+
'seller.home_builder': 'sellerHomeBuilder',
|
|
63
|
+
'seller.home_builder_email': 'sellerHomeBuilderEmail',
|
|
64
|
+
'seller.home_builder_community': 'sellerHomeBuilderCommunity',
|
|
57
65
|
};
|
|
58
66
|
/**
|
|
59
67
|
* Keys that should be skipped entirely (internal state, not sent to API).
|
|
60
68
|
*/
|
|
61
69
|
const SKIP_KEYS = new Set(['offerId']);
|
|
70
|
+
/**
|
|
71
|
+
* Keys whose string values should be coerced to numbers.
|
|
72
|
+
* Dropdown options produce strings ("3") but the GraphQL API expects numbers.
|
|
73
|
+
*/
|
|
74
|
+
const NUMERIC_KEYS = new Set([
|
|
75
|
+
'home.bedrooms',
|
|
76
|
+
'home.bathrooms.full',
|
|
77
|
+
'home.bathrooms.half',
|
|
78
|
+
'home.above_grade_sq_ft',
|
|
79
|
+
'home.exterior_stories',
|
|
80
|
+
'home.year_built',
|
|
81
|
+
'home.garage_spaces',
|
|
82
|
+
'home.carport_spaces',
|
|
83
|
+
'home.hoa_fees',
|
|
84
|
+
'home.basement_finished_sq_ft',
|
|
85
|
+
'home.basement_unfinished_sq_ft',
|
|
86
|
+
]);
|
|
62
87
|
/**
|
|
63
88
|
* Transform dot-notation answers from QualificationQuestions into
|
|
64
89
|
* the GraphQL OfferInput shape: camelCase fields + experimental array.
|
|
@@ -84,6 +109,29 @@ export function transformAnswersToOfferInput(answers) {
|
|
|
84
109
|
values.includes('gated_community');
|
|
85
110
|
continue;
|
|
86
111
|
}
|
|
112
|
+
// Special case: home.eligibility_criteria fans out to individual boolean fields
|
|
113
|
+
// DTC onboarding stores as string[] ("leased_solar_panels", "known_foundation_issues", etc.)
|
|
114
|
+
// GraphQL expects individual boolean fields like homeEligibilityCriteriaLeasedSolarPanels
|
|
115
|
+
if (key === 'home.eligibility_criteria') {
|
|
116
|
+
const values = Array.isArray(value) ? value : [];
|
|
117
|
+
const criteriaMap = {
|
|
118
|
+
leased_solar_panels: 'homeEligibilityCriteriaLeasedSolarPanels',
|
|
119
|
+
known_foundation_issues: 'homeEligibilityCriteriaKnownFoundationIssues',
|
|
120
|
+
fire_damage: 'homeEligibilityCriteriaFireDamage',
|
|
121
|
+
well_water: 'homeEligibilityCriteriaWellWater',
|
|
122
|
+
septic: 'homeEligibilityCriteriaSeptic',
|
|
123
|
+
asbestos_siding: 'homeEligibilityCriteriaAsbestosSiding',
|
|
124
|
+
livestock: 'homeEligibilityCriteriaLivestock',
|
|
125
|
+
mobile_manufactured_home: 'homeEligibilityCriteriaMobileManufacturedHome',
|
|
126
|
+
unique_ownership_structure: 'homeEligibilityCriteriaUniqueOwnershipStructure',
|
|
127
|
+
below_market_rate_ownership: 'homeEligibilityCriteriaBelowMarketRateOwnership',
|
|
128
|
+
rent_controlled_tenant_occupied: 'homeEligibilityCriteriaRentControlledTenantOccupied',
|
|
129
|
+
};
|
|
130
|
+
for (const [criteriaValue, graphqlField] of Object.entries(criteriaMap)) {
|
|
131
|
+
offerInput[graphqlField] = values.includes(criteriaValue);
|
|
132
|
+
}
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
87
135
|
// Special case: home.hoa_type.guarded_gated_community → boolean
|
|
88
136
|
if (key === 'home.hoa_type.guarded_gated_community') {
|
|
89
137
|
offerInput['homeHoaTypeGuardedGatedCommunity'] = value === 'has_guard';
|
|
@@ -91,10 +139,21 @@ export function transformAnswersToOfferInput(answers) {
|
|
|
91
139
|
}
|
|
92
140
|
const camelKey = DOT_TO_CAMEL[key];
|
|
93
141
|
if (camelKey) {
|
|
94
|
-
// Coerce "yes"/"no" to boolean
|
|
142
|
+
// Coerce "yes"/"no" and "true"/"false" strings to boolean
|
|
95
143
|
if (value === 'yes' || value === 'no') {
|
|
96
144
|
offerInput[camelKey] = value === 'yes';
|
|
97
145
|
}
|
|
146
|
+
else if (value === 'true' || value === 'false') {
|
|
147
|
+
offerInput[camelKey] = value === 'true';
|
|
148
|
+
}
|
|
149
|
+
else if (typeof value === 'string' &&
|
|
150
|
+
value !== '' &&
|
|
151
|
+
NUMERIC_KEYS.has(key) &&
|
|
152
|
+
!isNaN(Number(value))) {
|
|
153
|
+
// Coerce numeric strings to numbers for known numeric fields
|
|
154
|
+
// (dropdown options produce strings like "3" instead of 3)
|
|
155
|
+
offerInput[camelKey] = Number(value);
|
|
156
|
+
}
|
|
98
157
|
else {
|
|
99
158
|
offerInput[camelKey] = value;
|
|
100
159
|
}
|