Skip to content

Conversation

@ryanbas21
Copy link
Collaborator

@ryanbas21 ryanbas21 commented Nov 13, 2025

JIRA Ticket

N/A release work

Description

Preliminary scan to make sure we are re-exporting common types.

Summary by CodeRabbit

  • Refactor

    • Expanded public type exports across davinci-client, device-client, journey-client, and oidc-client so more SDK types (log levels, middleware, storage, collectors, node states, errors, etc.) are importable directly.
    • Introduced generic Updater and CollectorValueType for stronger typing of updater callbacks.
    • Adjusted device-client types export path for the distributed package.
  • Tests

    • Added comprehensive compile-time type tests validating updater/collector narrowing and usage patterns.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

⚠️ No Changeset found

Latest commit: b160ecd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

Refines and expands public TypeScript type exports across davinci-, device-, journey-, and oidc-client packages, introduces generic Updater/CollectorValueType types, tightens updater generics in e2e components, adds a types test, and adjusts one package.json types export path.

Changes

Cohort / File(s) Summary
Davinci / Public types & generics
packages/davinci-client/src/types.ts, packages/davinci-client/src/lib/client.types.ts, packages/davinci-client/src/lib/client.store.ts, packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts, packages/davinci-client/src/lib/client.store.ts
Expanded public type exports (many node/collector types, LogLevel/CustomLogger, RequestMiddleware, ActionTypes, FidoClient, InternalErrorResponse). Introduced CollectorValueType<T> and generic Updater<T = unknown>. Updated update to return Updater<T>. Added comprehensive compile-time narrowing tests.
Device client / types & package manifest
packages/device-client/src/lib/types/index.ts, packages/device-client/package.json
Added re-exports: ConfigOptions from @forgerock/javascript-sdk and local push-device.types.js, bound-device.types.js, updateDeviceProfile.types.js. Updated package "./types" export path from ./dist/src/lib/types/index.d.ts to ./dist/src/types.d.ts.
Journey / type re-exports
packages/journey-client/src/types.ts
Added re-exports: LogLevel, CustomLogger from @forgerock/sdk-logger; RequestMiddleware from @forgerock/sdk-request-middleware; various types from @forgerock/sdk-types (Step, Callback, CallbackType, StepType, callbackType, GenericError, PolicyRequirement, FailedPolicyRequirement).
OIDC / type re-exports & local exchange types
packages/oidc-client/src/types.ts, packages/oidc-client/src/lib/exchange.types.js
Added type re-exports: LogLevel, CustomLogger (@forgerock/sdk-logger), RequestMiddleware (@forgerock/sdk-request-middleware), StorageConfig (@forgerock/storage); converted some exports to type-only (e.g., GenericError, GetAuthorizationUrlOptions); added export * from './lib/exchange.types.js'.
E2E app / updater narrowing in components
e2e/davinci-app/components/multi-value.ts, e2e/davinci-app/components/single-value.ts, e2e/davinci-app/components/text.ts, e2e/davinci-app/components/password.ts, e2e/davinci-app/components/protect.ts, e2e/davinci-app/components/object-value.ts
Tightened updater parameter generics across UI components to Updater<...> specialized by collector type(s); minor local casts added where needed. No runtime control-flow changes.

Sequence Diagram(s)

No sequence diagram provided — changes are type/export surface and type refinements without control-flow or runtime feature additions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Mixed changes: broad public API surface edits, new generic types, signature tightening across client and e2e components, and a new type-only test.
  • Pay extra attention to:
    • packages/davinci-client/src/types.ts and packages/davinci-client/src/lib/client.types.ts for correct generic mappings and exported names.
    • packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts for test assumptions matching new types.
    • packages/device-client/package.json export path correctness relative to build output.
    • packages/oidc-client/src/types.ts conversions from value to type-only exports and their consumer impact.

Possibly related PRs

Suggested reviewers

  • cerebrl

Poem

🐰 I hopped through types with nary a fuss,
Rejoined collectors and generics for us.
Exports aligned and tests that sing,
A tiny tweak — a clearer spring! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: type-exports' accurately and concisely summarizes the main change: expanding public type exports across multiple packages.
Description check ✅ Passed The description follows the template structure with JIRA ticket and description sections, though the description is minimal. It conveys the main purpose of the changes without providing detailed context.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-type-exports

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
Contributor

nx-cloud bot commented Nov 13, 2025

View your CI Pipeline Execution ↗ for commit b160ecd

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

☁️ Nx Cloud last updated this comment at 2025-11-13 21:53:10 UTC

*/

// Re-export types from external dependencies that consumers need
export type { ConfigOptions } from '@forgerock/javascript-sdk';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

technically this package uses the javascript-sdk. we can update this later though.

@codecov-commenter
Copy link

codecov-commenter commented Nov 13, 2025

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.21%. Comparing base (fa3d434) to head (b160ecd).
⚠️ Report is 57 commits behind head on main.

Files with missing lines Patch % Lines
packages/journey-client/src/types.ts 0.00% 15 Missing ⚠️
packages/davinci-client/src/lib/client.store.ts 0.00% 3 Missing ⚠️

❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (40.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #493       +/-   ##
===========================================
+ Coverage   18.52%   67.21%   +48.68%     
===========================================
  Files         138       97       -41     
  Lines       27402     7219    -20183     
  Branches      963      866       -97     
===========================================
- Hits         5076     4852      -224     
+ Misses      22326     2367    -19959     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/client.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/types.ts 50.00% <ø> (ø)
packages/device-client/src/lib/types/index.ts 14.28% <ø> (ø)
packages/oidc-client/src/types.ts 20.00% <ø> (+3.33%) ⬆️
packages/davinci-client/src/lib/client.store.ts 0.36% <0.00%> (ø)
packages/journey-client/src/types.ts 0.00% <0.00%> (ø)

... and 43 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

pkg-pr-new bot commented Nov 13, 2025

Open in StackBlitz

@forgerock/davinci-client

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

@forgerock/oidc-client

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

@forgerock/protect

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

@forgerock/sdk-types

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

@forgerock/sdk-utilities

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

@forgerock/iframe-manager

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

@forgerock/sdk-logger

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

@forgerock/sdk-oidc

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

@forgerock/sdk-request-middleware

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

@forgerock/storage

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

commit: b160ecd

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

Deployed 6915082 to https://ForgeRock.github.io/ping-javascript-sdk/pr-493/6915082429cdc2914ad886a44dfb280bfa18682b branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions
Copy link
Contributor

github-actions bot commented Nov 13, 2025

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔻 @forgerock/journey-client - 0.0 KB (-82.2 KB, -100.0%)

📊 Minor Changes

📈 @forgerock/device-client - 9.2 KB (+0.1 KB)
📈 @forgerock/oidc-client - 23.1 KB (+0.2 KB)
📈 @forgerock/journey-client - 82.4 KB (+0.1 KB)
📈 @forgerock/davinci-client - 39.5 KB (+0.6 KB)

➖ No Changes

@forgerock/protect - 150.1 KB
@forgerock/sdk-utilities - 7.5 KB
@forgerock/sdk-types - 8.0 KB
@forgerock/storage - 1.4 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/iframe-manager - 2.4 KB
@forgerock/sdk-request-middleware - 4.5 KB
@forgerock/sdk-oidc - 2.6 KB


13 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

Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
e2e/davinci-app/components/multi-value.ts (1)

9-20: Updater generic is correct; JSDoc still describes the wrong collector/behavior

The new updater: Updater<MultiSelectCollector> matches the string[] values array and the CollectorValueType<MultiSelectCollector> mapping, so the typing is solid. However, the JSDoc still references SingleSelectCollector and “single-select behavior (like radio buttons)”, which doesn’t match the MultiSelectCollector usage or the actual multi-select logic.

You can align the docs with the implementation like this:

-/**
- * Creates a group of checkboxes with single-select behavior (like radio buttons)
+/**
+ * Creates a group of checkboxes with multi-select behavior
  * based on the provided data and attaches it to the form
  * @param {HTMLFormElement} formEl - The form element to attach the checkboxes to
- * @param {SingleSelectCollector} collector - Contains the options and configuration
- * @param {Updater} updater - Function to call when selection changes
+ * @param {MultiSelectCollector} collector - Contains the options and configuration
+ * @param {Updater<MultiSelectCollector>} updater - Function to call when selection changes
  */
 export default function multiValueComponent(
   formEl: HTMLFormElement,
   collector: MultiSelectCollector,
-  updater: Updater<MultiSelectCollector>,
+  updater: Updater<MultiSelectCollector>,
 )
🧹 Nitpick comments (1)
e2e/davinci-app/components/object-value.ts (1)

56-56: Type assertions bypass type safety guarantees.

The as any casts on lines 56 and 90 work around TypeScript's limitation with union function types but eliminate compile-time type checking at the call site. While this is a pragmatic solution given the union-typed updater parameter, it means type mismatches won't be caught until runtime.

Consider these alternatives if type safety is a priority:

  • Make the component function generic with a type parameter that ties the collector and updater types together
  • Use separate handler functions for each collector type (already partially structured this way with the if/else branches)
  • Use a discriminated approach where the updater is narrowed based on the collector type

Also applies to: 90-90

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ffcf876 and b160ecd.

📒 Files selected for processing (10)
  • e2e/davinci-app/components/multi-value.ts (1 hunks)
  • e2e/davinci-app/components/object-value.ts (3 hunks)
  • e2e/davinci-app/components/password.ts (1 hunks)
  • e2e/davinci-app/components/protect.ts (1 hunks)
  • e2e/davinci-app/components/single-value.ts (1 hunks)
  • e2e/davinci-app/components/text.ts (1 hunks)
  • packages/davinci-client/src/lib/client.store.ts (1 hunks)
  • packages/davinci-client/src/lib/client.types.ts (1 hunks)
  • packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts (1 hunks)
  • packages/davinci-client/src/types.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (10)
e2e/davinci-app/components/protect.ts (3)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/types.ts (3)
  • Updater (21-21)
  • TextCollector (42-42)
  • ValidatedTextCollector (45-45)
packages/davinci-client/src/lib/collector.types.ts (2)
  • TextCollector (184-184)
  • ValidatedTextCollector (186-186)
packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts (3)
packages/davinci-client/src/types.ts (12)
  • PasswordCollector (41-41)
  • TextCollector (42-42)
  • ValidatedTextCollector (45-45)
  • SingleSelectCollector (48-48)
  • MultiSelectCollector (47-47)
  • DeviceRegistrationCollector (49-49)
  • DeviceAuthenticationCollector (50-50)
  • PhoneNumberCollector (51-51)
  • FidoRegistrationCollector (53-53)
  • FidoAuthenticationCollector (54-54)
  • Updater (21-21)
  • Collectors (32-32)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/lib/collector.types.ts (3)
  • PhoneNumberInputValue (297-300)
  • FidoRegistrationInputValue (555-557)
  • FidoAuthenticationInputValue (576-578)
e2e/davinci-app/components/single-value.ts (3)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/types.ts (2)
  • Updater (21-21)
  • SingleSelectCollector (48-48)
packages/davinci-client/src/lib/collector.types.ts (1)
  • SingleSelectCollector (185-185)
e2e/davinci-app/components/multi-value.ts (3)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/types.ts (2)
  • Updater (21-21)
  • MultiSelectCollector (47-47)
packages/davinci-client/src/lib/collector.types.ts (1)
  • MultiSelectCollector (260-260)
e2e/davinci-app/components/password.ts (3)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/types.ts (2)
  • Updater (21-21)
  • PasswordCollector (41-41)
packages/davinci-client/src/lib/collector.types.ts (1)
  • PasswordCollector (183-183)
e2e/davinci-app/components/text.ts (3)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/types.ts (3)
  • Updater (21-21)
  • TextCollector (42-42)
  • ValidatedTextCollector (45-45)
packages/davinci-client/src/lib/collector.types.ts (2)
  • TextCollector (184-184)
  • ValidatedTextCollector (186-186)
packages/davinci-client/src/lib/client.types.ts (2)
packages/davinci-client/src/types.ts (2)
  • CollectorValueType (22-22)
  • Updater (21-21)
packages/davinci-client/src/lib/collector.types.ts (3)
  • PhoneNumberInputValue (297-300)
  • FidoRegistrationInputValue (555-557)
  • FidoAuthenticationInputValue (576-578)
e2e/davinci-app/components/object-value.ts (3)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
packages/davinci-client/src/types.ts (4)
  • Updater (21-21)
  • DeviceRegistrationCollector (49-49)
  • DeviceAuthenticationCollector (50-50)
  • PhoneNumberCollector (51-51)
packages/davinci-client/src/lib/collector.types.ts (3)
  • DeviceRegistrationCollector (402-405)
  • DeviceAuthenticationCollector (406-409)
  • PhoneNumberCollector (410-414)
packages/davinci-client/src/types.ts (2)
packages/davinci-client/src/lib/client.store.ts (1)
  • davinci (58-454)
packages/davinci-client/src/lib/client.types.ts (2)
  • Updater (79-82)
  • CollectorValueType (37-68)
packages/davinci-client/src/lib/client.store.ts (3)
packages/davinci-client/src/lib/collector.types.ts (4)
  • SingleValueCollectors (176-181)
  • MultiSelectCollector (260-260)
  • ObjectValueCollectors (390-395)
  • AutoCollectors (647-652)
packages/davinci-client/src/types.ts (2)
  • MultiSelectCollector (47-47)
  • Updater (21-21)
packages/davinci-client/src/lib/client.types.ts (1)
  • Updater (79-82)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: pr
  • GitHub Check: Mend Code Security Check
🔇 Additional comments (9)
packages/davinci-client/src/lib/client.types.ts (1)

25-68: Generic collector value mapping and Updater look correct and backward‑compatible

The CollectorValueType<T> conditional chain matches the known collector/value pairs and correctly falls back to the legacy value union, and Updater<T> preserves previous behavior for T = unknown while enabling precise narrowing for specific collectors. This aligns well with the usages shown elsewhere in the PR.

Also applies to: 70-82

e2e/davinci-app/components/single-value.ts (1)

15-19: Updater matches usage and collector mapping

Typing updater as Updater<SingleSelectCollector> aligns with CollectorValueType<SingleSelectCollector> = string and the selectedValue: string passed from the change handler, with no runtime behavior changes.

e2e/davinci-app/components/password.ts (1)

10-14: Password updater specialization is consistent with value type

updater: Updater<PasswordCollector> is consistent with CollectorValueType<PasswordCollector> = string and the string value read from the input on blur, so the specialization is type‑safe without changing behavior.

e2e/davinci-app/components/protect.ts (1)

13-17: Union-typed Updater<TextCollector | ValidatedTextCollector> is correct

Specializing updater as Updater<TextCollector | ValidatedTextCollector> matches the string literal 'fakeprofile' passed in and the CollectorValueType mapping for both collector variants, improving type precision without affecting runtime behavior.

e2e/davinci-app/components/text.ts (1)

18-18: LGTM! Proper type narrowing for updater parameter.

The change from Updater to Updater<TextCollector | ValidatedTextCollector> correctly narrows the updater's type to match the collector parameter, leveraging the new generic Updater<T> type. This improves type safety by ensuring the updater can only accept values compatible with these specific collector types.

e2e/davinci-app/components/object-value.ts (1)

23-26: Union of function types necessitates runtime type assertions below.

The updater parameter is now a union of Updater<DeviceRegistrationCollector> | Updater<DeviceAuthenticationCollector> | Updater<PhoneNumberCollector>. When calling a union of functions in TypeScript, you can only pass arguments that satisfy all signatures in the union. Since these updaters expect different parameter types (string vs PhoneNumberInputValue), calling the updater requires type assertions (see lines 56 and 90).

packages/davinci-client/src/lib/client.store.ts (1)

237-245: Excellent type safety improvement with generic type parameter.

The addition of the generic type parameter T to the update method enables proper type narrowing: when a specific collector type is passed, the returned Updater<T> is constrained to accept only values compatible with that collector type (via CollectorValueType<T>). This provides compile-time guarantees that prevent passing incompatible values to updaters.

packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts (1)

1-297: Excellent compile-time type validation coverage.

This type test file comprehensively validates that the generic Updater<T> type correctly narrows based on collector types across various scenarios:

  • Single value collectors (Password, Text, SingleSelect, DeviceRegistration, DeviceAuthentication)
  • Multi value collectors (MultiSelect)
  • Object value collectors (PhoneNumber, FidoRegistration, FidoAuthentication)
  • Real-world usage patterns (forEach, for...of, early return)
  • Edge cases (optional index parameter, complex conditionals)

The tests ensure that TypeScript's type narrowing works as expected when discriminating on collector.type, which is critical for the type safety guarantees of this API.

packages/davinci-client/src/types.ts (1)

16-16: Appropriate expansion of public API surface.

The new exports enhance the public API by making key types available to consumers:

  • LogLevel (line 16): Enables proper logger configuration
  • Updater<T = unknown> (line 21): Generic variant for type-safe updater functions; default type parameter maintains backward compatibility
  • CollectorValueType<T> (line 22): Allows consumers to understand and work with the value types expected by different collectors
  • RequestMiddleware and ActionTypes (line 57): Enable request middleware configuration

These exports align with the PR objective of ensuring common types are re-exported.

Also applies to: 21-22, 57-57

@ryanbas21 ryanbas21 merged commit 2c52b9c into main Nov 18, 2025
8 checks passed
@ryanbas21 ryanbas21 deleted the update-type-exports branch November 18, 2025 18:42
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.

5 participants