Skip to content

SDKS-4670: Add support for extension in PhoneNumberCollector#573

Open
ancheetah wants to merge 1 commit intomainfrom
SDKS-4670-phone-ext
Open

SDKS-4670: Add support for extension in PhoneNumberCollector#573
ancheetah wants to merge 1 commit intomainfrom
SDKS-4670-phone-ext

Conversation

@ancheetah
Copy link
Copy Markdown
Collaborator

@ancheetah ancheetah commented Apr 17, 2026

JIRA Ticket

https://pingidentity.atlassian.net/browse/SDKS-4670

Description

Adds support for extensions in PhoneNumberCollector. DaVinci now returns a showExtension property on the PHONE field. Additionally, an extension can be pre-filled.

  1. showExtension is always added to the collector's output option. option is a new property on the PhoneNumberCollector output.
  2. If the extension is provided in 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 DaVinci
  3. BREAKING CHANGE: extension field is now required on PhoneNumberInputValue
  4. BREAKING CHANGE: ObjectValueCollectorWithObjectValue type was removed. ObjectOptionsCollectorWithObjectValue was repurposed for PhoneNumberCollector to include the new options object that stores showExtension. This is up for discussion. It is debatable where to put showExtension. It can live in options or possibly in validate where it would not cause a breaking change.

Summary by CodeRabbit

  • New Features

    • Added extension field support to phone number collection, allowing users to input and store phone extensions alongside phone numbers.
    • Added showExtension property to phone number field configuration.
  • Breaking Changes

    • Removed ObjectValueCollectorWithObjectValue type from exported interfaces.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 17, 2026

🦋 Changeset detected

Latest commit: 9aa183c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 12 packages
Name Type
@forgerock/davinci-client Minor
@forgerock/device-client Minor
@forgerock/journey-client Minor
@forgerock/oidc-client Minor
@forgerock/protect Minor
@forgerock/sdk-types Minor
@forgerock/sdk-utilities Minor
@forgerock/iframe-manager Minor
@forgerock/sdk-logger Minor
@forgerock/sdk-oidc Minor
@forgerock/sdk-request-middleware Minor
@forgerock/storage Minor

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 17, 2026

Warning

Rate limit exceeded

@ancheetah has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 47 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b0fe100c-d8a1-4052-840b-384c51fdcd9d

📥 Commits

Reviewing files that changed from the base of the PR and between 866974e and 9aa183c.

📒 Files selected for processing (9)
  • .changeset/long-singers-do.md
  • e2e/davinci-app/components/object-value.ts
  • e2e/davinci-suites/src/form-fields.test.ts
  • packages/davinci-client/src/lib/collector.types.test-d.ts
  • packages/davinci-client/src/lib/collector.types.ts
  • packages/davinci-client/src/lib/collector.utils.test.ts
  • packages/davinci-client/src/lib/collector.utils.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
📝 Walkthrough

Walkthrough

This changeset introduces extension support to the PhoneNumberCollector, adding extension fields to input/output values and a showExtension option. It removes the ObjectValueCollectorWithObjectValue interface and refactors ObjectOptionsCollectorWithObjectValue with new generics. Changes propagate across types, utilities, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Changeset Metadata
.changeset/long-singers-do.md
Declares minor version bump for @forgerock/davinci-client marking new extension support in PhoneNumberCollector and breaking removal of ObjectValueCollectorWithObjectValue.
Type Definitions
packages/davinci-client/src/lib/collector.types.ts, packages/davinci-client/src/lib/davinci.types.ts
Added extension: string to PhoneNumberInputValue, optional extension?: string to PhoneNumberOutputValue, new PhoneNumberOptions with showExtension?: boolean. Removed ObjectValueCollectorWithObjectValue interface. Refactored ObjectOptionsCollectorWithObjectValue with new generic parameter O for options and updated union type accordingly. PhoneNumberField now includes required showExtension: boolean.
Utility Implementation
packages/davinci-client/src/lib/collector.utils.ts
Updated returnObjectCollector's PHONE_NUMBER branch to define options with showExtension field and extend defaultValue with extension property populated from prefill data or empty string.
Type Tests
packages/davinci-client/src/lib/collector.types.test-d.ts
Added comprehensive type-level test coverage for PhoneNumberCollector, validating structural properties, generic resolution, and new options/extension fields.
Unit & Integration Tests
packages/davinci-client/src/lib/collector.utils.test.ts, packages/davinci-client/src/lib/node.reducer.test.ts
Extended test cases to verify showExtension propagation, extension field handling in input/output values, and options payload structure. Updated expectations across default, prefilled, and populated scenarios.
E2E Tests & Components
e2e/davinci-app/components/object-value.ts, e2e/davinci-suites/src/form-fields.test.ts
Updated phone input change handler to populate extension field in updater payload. Enhanced request payload parsing to handle missing/empty POST data. Extended form field assertions to include extension: '4321' in submitted phone structure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • cerebrl

Poem

🐰 A whisker-twitch of joy!

Extensions bloom where phones did call,
The collector hops with fields anew,
Old unions fade, new generics rise,
With showExtension we play so sly,
Types refined, the payloads dance! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding extension support to PhoneNumberCollector, which is the primary objective of this pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description check ✅ Passed The pull request description is complete and well-structured, including the JIRA ticket link, clear description of changes, and documentation of breaking changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SDKS-4670-phone-ext

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud bot commented Apr 17, 2026

View your CI Pipeline Execution ↗ for commit 9aa183c

Command Status Duration Result
nx run-many -t build --no-agents ✅ Succeeded <1s View ↗
nx affected -t build lint test typecheck e2e-ci ✅ Succeeded 2m 26s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-17 16:32:26 UTC

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

showExtension as required may bite older DaVinci environments.

Marking showExtension: boolean as 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 to false in collector.utils.ts to 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 | 🟡 Minor

Confirm field.showExtension is always present from DaVinci.

PhoneNumberField.showExtension is declared as a required boolean in davinci.types.ts, and options = { showExtension: field.showExtension } passes it through directly. However, PhoneNumberOptions.showExtension is optional in collector.types.ts. If DaVinci ever returns a PHONE field without showExtension (older environments or feature-flag rollouts), options.showExtension will be undefined rather 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: Output value in the type-check literal is missing extension.

The concrete PhoneNumberCollector literal at line 428 sets output.value: { countryCode: '+1', phoneNumber: '5555555555' } without extension. That's fine because PhoneNumberOutputValue.extension is optional, but the companion test at line 382 does include extension: '' in both input and output values — consistency here would better document the intended shape and guard against future regressions if extension is 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: Inconsistent options fallback in output spread.

...(options && { options: options || [] }) mixes object/array semantics. For PhoneNumberCollector, options is { showExtension: boolean } (an object), so the inner || [] fallback would yield a type‑incompatible empty array. It's also dead code — the outer && already guarantees options is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9088443 and 866974e.

📒 Files selected for processing (9)
  • .changeset/long-singers-do.md
  • e2e/davinci-app/components/object-value.ts
  • e2e/davinci-suites/src/form-fields.test.ts
  • packages/davinci-client/src/lib/collector.types.test-d.ts
  • packages/davinci-client/src/lib/collector.types.ts
  • packages/davinci-client/src/lib/collector.utils.test.ts
  • packages/davinci-client/src/lib/collector.utils.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts

Comment thread packages/davinci-client/src/lib/collector.types.ts
Comment thread packages/davinci-client/src/lib/collector.types.ts
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 15.68%. Comparing base (5d6747a) to head (9aa183c).
⚠️ Report is 32 commits behind head on main.

❌ 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     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/collector.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/collector.utils.ts 82.22% <100.00%> (ø)
packages/davinci-client/src/lib/davinci.types.ts 100.00% <ø> (ø)

... and 98 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 17, 2026

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/davinci-client@573

@forgerock/device-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/device-client@573

@forgerock/journey-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/journey-client@573

@forgerock/oidc-client

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/oidc-client@573

@forgerock/protect

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/protect@573

@forgerock/sdk-types

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-types@573

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-utilities@573

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/iframe-manager@573

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-logger@573

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-oidc@573

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/sdk-request-middleware@573

@forgerock/storage

pnpm add https://pkg.pr.new/ForgeRock/ping-javascript-sdk/@forgerock/storage@573

commit: 9aa183c

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

Deployed a63ae55 to https://ForgeRock.github.io/ping-javascript-sdk/pr-573/a63ae5595cc1ce1f2b8da6034bfc4ff944f7b5ea branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2026

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔻 @forgerock/device-client - 0.0 KB (-9.9 KB, -100.0%)
🔻 @forgerock/journey-client - 0.0 KB (-89.9 KB, -100.0%)

📊 Minor Changes

📉 @forgerock/device-client - 9.9 KB (-0.0 KB)
📈 @forgerock/davinci-client - 48.0 KB (+0.0 KB)

➖ No Changes

@forgerock/oidc-client - 25.2 KB
@forgerock/sdk-utilities - 11.2 KB
@forgerock/sdk-types - 7.9 KB
@forgerock/protect - 150.1 KB
@forgerock/journey-client - 89.9 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-oidc - 4.8 KB
@forgerock/sdk-request-middleware - 4.5 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/iframe-manager - 2.4 KB


14 packages analyzed • Baseline from latest main build

Legend

🆕 New package
🔺 Size increased
🔻 Size decreased
➖ No change

ℹ️ How bundle sizes are calculated
  • Current Size: Total gzipped size of all files in the package's dist directory
  • Baseline: Comparison against the latest build from the main branch
  • Files included: All build outputs except source maps and TypeScript build cache
  • Exclusions: .map, .tsbuildinfo, and .d.ts.map files

🔄 Updated automatically on each push to this PR

@ancheetah ancheetah force-pushed the SDKS-4670-phone-ext branch from 866974e to 9aa183c Compare April 17, 2026 16:28
@ancheetah ancheetah requested review from cerebrl and ryanbas21 April 17, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants