SDKS-4670: Add support for extension in PhoneNumberCollector#573
SDKS-4670: Add support for extension in PhoneNumberCollector#573
Conversation
🦋 Changeset detectedLatest commit: 9aa183c The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 41 minutes and 47 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis changeset introduces extension support to the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit 9aa183c
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/davinci-client/src/lib/davinci.types.ts (1)
154-162:⚠️ Potential issue | 🟡 Minor
showExtensionas required may bite older DaVinci environments.Marking
showExtension: booleanas required enforces it at the type level, but DaVinci responses in older/unupdated environments may omit the field. Consider making it optional (showExtension?: boolean) and defaulting tofalseincollector.utils.tsto preserve backward compatibility. Otherwise, this is effectively a runtime coupling on a specific DaVinci version.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/davinci-client/src/lib/davinci.types.ts` around lines 154 - 162, The PhoneNumberField type currently requires showExtension which breaks with older DaVinci payloads; make showExtension optional by changing its declaration to showExtension?: boolean in the PhoneNumberField type and update the code that consumes it (see collector.utils.ts) to treat missing values as false by default (i.e., when accessing field.showExtension, coerce undefined to false). Ensure all usages of PhoneNumberField and any destructuring in collector.utils.ts handle the optional property.packages/davinci-client/src/lib/collector.utils.ts (1)
646-665:⚠️ Potential issue | 🟡 MinorConfirm
field.showExtensionis always present from DaVinci.
PhoneNumberField.showExtensionis declared as a requiredbooleanin davinci.types.ts, andoptions = { showExtension: field.showExtension }passes it through directly. However,PhoneNumberOptions.showExtensionis optional in collector.types.ts. If DaVinci ever returns a PHONE field withoutshowExtension(older environments or feature-flag rollouts),options.showExtensionwill beundefinedrather than a safe default. Consider adding a defensive default to avoid ambiguity:Suggested fix
- options = { showExtension: field.showExtension }; + options = { showExtension: field.showExtension ?? false };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/davinci-client/src/lib/collector.utils.ts` around lines 646 - 665, The code passes field.showExtension directly into options but PhoneNumberOptions.showExtension is optional; make this defensive by ensuring options.showExtension is always a boolean (e.g., use nullish coalescing or Boolean conversion) so it defaults when PhoneNumberField may omit it; update the assignment of options (the variable named options and the property field.showExtension) to coerce a safe default (for example false) rather than letting undefined through.
🧹 Nitpick comments (2)
packages/davinci-client/src/lib/collector.types.test-d.ts (1)
410-432: Outputvaluein the type-check literal is missingextension.The concrete
PhoneNumberCollectorliteral at line 428 setsoutput.value: { countryCode: '+1', phoneNumber: '5555555555' }withoutextension. That's fine becausePhoneNumberOutputValue.extensionis optional, but the companion test at line 382 does includeextension: ''in both input and output values — consistency here would better document the intended shape and guard against future regressions ifextensionis ever tightened to required on the output type.- value: { countryCode: '+1', phoneNumber: '5555555555' }, + value: { countryCode: '+1', phoneNumber: '5555555555', extension: '' },🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/davinci-client/src/lib/collector.types.test-d.ts` around lines 410 - 432, The test literal for PhoneNumberCollector omits the optional extension field in output.value; update the PhoneNumberCollector test object (the variable named collector used in the spec) so its output.value includes extension: '' to match the input.value and the PhoneNumberOutputValue shape (i.e., set output.value to { countryCode: '+1', phoneNumber: '5555555555', extension: '' }) so the literal remains consistent with PhoneNumberCollector and guards against future tightening of the type.packages/davinci-client/src/lib/collector.utils.ts (1)
680-686: Inconsistentoptionsfallback in output spread.
...(options && { options: options || [] })mixes object/array semantics. ForPhoneNumberCollector,optionsis{ showExtension: boolean }(an object), so the inner|| []fallback would yield a type‑incompatible empty array. It's also dead code — the outer&&already guaranteesoptionsis truthy. Consider simplifying to avoid future confusion:♻️ Proposed simplification
- ...(options && { options: options || [] }), - ...(defaultValue && { value: defaultValue }), + ...(options !== undefined && { options }), + ...(defaultValue !== undefined && { value: defaultValue }),🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/davinci-client/src/lib/collector.utils.ts` around lines 680 - 686, The spread for options in the output object mixes array fallback and redundant checks; replace ...(options && { options: options || [] }) with a simple ...(options && { options }) (or equivalently include options only when defined) inside the output object in collector.utils.ts (the object that builds output: { key, label, type, ... }). This avoids returning an incompatible [] for PhoneNumberCollector (where options is an object) and removes the dead || [] code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/davinci-client/src/lib/collector.types.ts`:
- Around line 309-311: The PhoneNumberOptions interface currently makes
showExtension optional, but downstream code and collector.utils.ts
unconditionally sets options: { showExtension: field.showExtension }, so update
the type to reflect reality by changing PhoneNumberOptions to require
showExtension: boolean; also check collector.utils.ts and any other creators to
ensure they return a boolean (coerce if necessary) so the required type is
always satisfied across producers and consumers.
- Around line 297-307: The change made PhoneNumberInputValue.extension to be
required in collector.types.ts but tests and consumers still construct
PhoneNumberInputValue without extension; update all tests and any call sites
that create PhoneNumberInputValue (look for usages constructing objects with
countryCode and phoneNumber) to include extension: '' or appropriate value, and
add a changeset entry documenting this public breaking change so consumers are
aware; ensure PhoneNumberInputValue, PhoneNumberOutputValue, and any utility
that fallbacks extension remain consistent.
---
Outside diff comments:
In `@packages/davinci-client/src/lib/collector.utils.ts`:
- Around line 646-665: The code passes field.showExtension directly into options
but PhoneNumberOptions.showExtension is optional; make this defensive by
ensuring options.showExtension is always a boolean (e.g., use nullish coalescing
or Boolean conversion) so it defaults when PhoneNumberField may omit it; update
the assignment of options (the variable named options and the property
field.showExtension) to coerce a safe default (for example false) rather than
letting undefined through.
In `@packages/davinci-client/src/lib/davinci.types.ts`:
- Around line 154-162: The PhoneNumberField type currently requires
showExtension which breaks with older DaVinci payloads; make showExtension
optional by changing its declaration to showExtension?: boolean in the
PhoneNumberField type and update the code that consumes it (see
collector.utils.ts) to treat missing values as false by default (i.e., when
accessing field.showExtension, coerce undefined to false). Ensure all usages of
PhoneNumberField and any destructuring in collector.utils.ts handle the optional
property.
---
Nitpick comments:
In `@packages/davinci-client/src/lib/collector.types.test-d.ts`:
- Around line 410-432: The test literal for PhoneNumberCollector omits the
optional extension field in output.value; update the PhoneNumberCollector test
object (the variable named collector used in the spec) so its output.value
includes extension: '' to match the input.value and the PhoneNumberOutputValue
shape (i.e., set output.value to { countryCode: '+1', phoneNumber: '5555555555',
extension: '' }) so the literal remains consistent with PhoneNumberCollector and
guards against future tightening of the type.
In `@packages/davinci-client/src/lib/collector.utils.ts`:
- Around line 680-686: The spread for options in the output object mixes array
fallback and redundant checks; replace ...(options && { options: options || []
}) with a simple ...(options && { options }) (or equivalently include options
only when defined) inside the output object in collector.utils.ts (the object
that builds output: { key, label, type, ... }). This avoids returning an
incompatible [] for PhoneNumberCollector (where options is an object) and
removes the dead || [] code.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9343cbc3-031f-4e2b-b31e-cae954dcdb2c
📒 Files selected for processing (9)
.changeset/long-singers-do.mde2e/davinci-app/components/object-value.tse2e/davinci-suites/src/form-fields.test.tspackages/davinci-client/src/lib/collector.types.test-d.tspackages/davinci-client/src/lib/collector.types.tspackages/davinci-client/src/lib/collector.utils.test.tspackages/davinci-client/src/lib/collector.utils.tspackages/davinci-client/src/lib/davinci.types.tspackages/davinci-client/src/lib/node.reducer.test.ts
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (15.68%) is below the target coverage (40.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #573 +/- ##
===========================================
- Coverage 70.90% 15.68% -55.23%
===========================================
Files 53 154 +101
Lines 2021 26669 +24648
Branches 377 1129 +752
===========================================
+ Hits 1433 4183 +2750
- Misses 588 22486 +21898
🚀 New features to boost your workflow:
|
@forgerock/davinci-client
@forgerock/device-client
@forgerock/journey-client
@forgerock/oidc-client
@forgerock/protect
@forgerock/sdk-types
@forgerock/sdk-utilities
@forgerock/iframe-manager
@forgerock/sdk-logger
@forgerock/sdk-oidc
@forgerock/sdk-request-middleware
@forgerock/storage
commit: |
|
Deployed a63ae55 to https://ForgeRock.github.io/ping-javascript-sdk/pr-573/a63ae5595cc1ce1f2b8da6034bfc4ff944f7b5ea branch gh-pages in ForgeRock/ping-javascript-sdk |
📦 Bundle Size Analysis📦 Bundle Size Analysis🚨 Significant Changes🔻 @forgerock/device-client - 0.0 KB (-9.9 KB, -100.0%) 📊 Minor Changes📉 @forgerock/device-client - 9.9 KB (-0.0 KB) ➖ No Changes➖ @forgerock/oidc-client - 25.2 KB 14 packages analyzed • Baseline from latest Legend🆕 New package ℹ️ How bundle sizes are calculated
🔄 Updated automatically on each push to this PR |
866974e to
9aa183c
Compare
JIRA Ticket
https://pingidentity.atlassian.net/browse/SDKS-4670
Description
Adds support for extensions in PhoneNumberCollector. DaVinci now returns a
showExtensionproperty on thePHONEfield. Additionally, an extension can be pre-filled.showExtensionis always added to the collector's outputoption.optionis a new property on the PhoneNumberCollector output.formData(prefilled values from DaVinci) then both the collector input and output are prefilled with this value. This extension is therefore now included in the payload sent back to DaVinciextension fieldis now required onPhoneNumberInputValueObjectValueCollectorWithObjectValuetype was removed.ObjectOptionsCollectorWithObjectValuewas repurposed for PhoneNumberCollector to include the newoptionsobject that storesshowExtension. This is up for discussion. It is debatable where to putshowExtension. It can live inoptionsor possibly invalidatewhere it would not cause a breaking change.Summary by CodeRabbit
New Features
showExtensionproperty to phone number field configuration.Breaking Changes
ObjectValueCollectorWithObjectValuetype from exported interfaces.