Skip to content

chore: use-either-for-composable-branching - #621

Draft
ryanbas21 wants to merge 2 commits into
mainfrom
either-refactor
Draft

chore: use-either-for-composable-branching#621
ryanbas21 wants to merge 2 commits into
mainfrom
either-refactor

Conversation

@ryanbas21

Copy link
Copy Markdown
Collaborator

JIRA Ticket

n/s

Description

look at what some either refactors could look like

@changeset-bot

changeset-bot Bot commented Apr 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fe83454

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

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 12a9d142-1e7c-4e6d-9c01-5d527e09f34e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch either-refactor

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.

@nx-cloud

nx-cloud Bot commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit fe83454

Command Status Duration Result
nx affected -t build lint test typecheck e2e-ci ❌ Failed 2m 39s View ↗

💡 Dealing with memory or CPU issues? See memory and CPU details with the resource usage add-on ↗.


☁️ Nx Cloud last updated this comment at 2026-07-30 17:26:07 UTC

nx-cloud[bot]

This comment was marked as outdated.

nx-cloud[bot]

This comment was marked as outdated.

@pkg-pr-new

pkg-pr-new Bot commented May 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/@forgerock/davinci-client@621

@forgerock/device-client

pnpm add https://pkg.pr.new/@forgerock/device-client@621

@forgerock/journey-client

pnpm add https://pkg.pr.new/@forgerock/journey-client@621

@forgerock/oidc-client

pnpm add https://pkg.pr.new/@forgerock/oidc-client@621

@forgerock/protect

pnpm add https://pkg.pr.new/@forgerock/protect@621

@forgerock/sdk-types

pnpm add https://pkg.pr.new/@forgerock/sdk-types@621

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/@forgerock/sdk-utilities@621

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/@forgerock/iframe-manager@621

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/@forgerock/sdk-logger@621

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/@forgerock/sdk-oidc@621

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/@forgerock/sdk-request-middleware@621

@forgerock/storage

pnpm add https://pkg.pr.new/@forgerock/storage@621

commit: ba9740b

@codecov-commenter

codecov-commenter commented May 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.07048% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.38%. Comparing base (eafe277) to head (ba9740b).
⚠️ Report is 50 commits behind head on main.

Files with missing lines Patch % Lines
packages/davinci-client/src/lib/davinci.utils.ts 91.19% 14 Missing ⚠️
...ges/davinci-client/src/lib/client.store.effects.ts 94.11% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #621       +/-   ##
===========================================
+ Coverage   18.07%   67.38%   +49.30%     
===========================================
  Files         155       23      -132     
  Lines       24398     2836    -21562     
  Branches     1203      500      -703     
===========================================
- Hits         4410     1911     -2499     
+ Misses      19988      925    -19063     
Files with missing lines Coverage Δ
...ges/davinci-client/src/lib/client.store.effects.ts 71.28% <94.11%> (+21.54%) ⬆️
packages/davinci-client/src/lib/davinci.utils.ts 90.20% <91.19%> (+0.26%) ⬆️

... and 137 files with indirect coverage changes

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

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

Deployed a0bc070 to https://ForgeRock.github.io/ping-javascript-sdk/pr-621/a0bc070f379af776506d56d7942ac87590a075de branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🆕 New Packages

🆕 @forgerock/journey-client - 92.6 KB (new)
🆕 @forgerock/journey-client - 0.0 KB (new)
🆕 @forgerock/device-client - 10.0 KB (new)
🆕 @forgerock/device-client - 0.0 KB (new)

📊 Minor Changes

📉 @forgerock/davinci-client - 55.1 KB (-0.1 KB)

➖ No Changes

@forgerock/sdk-types - 9.1 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/iframe-manager - 3.2 KB
@forgerock/sdk-oidc - 5.7 KB
@forgerock/storage - 1.5 KB
@forgerock/sdk-request-middleware - 4.6 KB
@forgerock/sdk-utilities - 18.6 KB
@forgerock/oidc-client - 35.3 KB
@forgerock/protect - 144.6 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

nx-cloud[bot]

This comment was marked as outdated.

@ancheetah ancheetah left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In some places, I can see that Either helps make the code more functional. But in other places I don't see the benefit of using Either over a simple Micro fail/succeed. When is it appropriate to use one over the other?

@ryanbas21
ryanbas21 force-pushed the either-refactor branch 2 times, most recently from cd1eada to 3f447f6 Compare June 17, 2026 16:03
@ryanbas21
ryanbas21 force-pushed the either-refactor branch 6 times, most recently from 9f7726a to cd2d932 Compare June 27, 2026 00:00
@ryanbas21
ryanbas21 force-pushed the either-refactor branch 3 times, most recently from a74b40f to c1dd76e Compare July 7, 2026 19:00
@ryanbas21
ryanbas21 force-pushed the either-refactor branch 2 times, most recently from 11254d6 to 3f746e2 Compare July 13, 2026 19:00
@ryanbas21
ryanbas21 force-pushed the either-refactor branch 2 times, most recently from 1fbfd4b to c377172 Compare July 17, 2026 20:12

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nx Cloud is proposing a fix for your failed CI:

We updated the type-level test assertions in updater-narrowing.types.test-d.ts to align with the PR's intentional Either pattern, where Fido collector updaters accept FidoRegistrationInputValue | GenericError and FidoAuthenticationInputValue | GenericError. The missing GenericError import was also added. This fixes the three toEqualTypeOf failures in the typecheck and test tasks.

Tip

We verified this fix by re-running @forgerock/davinci-client:test, @forgerock/davinci-client:typecheck, @forgerock/davinci-suites:e2e-ci--src/phone-number-field.test.ts.

Suggested Fix changes
diff --git a/packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts b/packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts
index 587f367..2037602 100644
--- a/packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts
+++ b/packages/davinci-client/src/lib/updater-narrowing.types.test-d.ts
@@ -7,6 +7,8 @@
 /* eslint-disable @typescript-eslint/no-unused-vars */
 import { describe, expectTypeOf, it } from 'vitest';
 
+import type { GenericError } from '@forgerock/sdk-types';
+
 import type { Updater } from './client.types.js';
 import type {
   PasswordCollector,
@@ -193,8 +195,10 @@ describe('Updater Type Narrowing with Real Usage Pattern', () => {
         const updater = mockUpdate(collector);
         expectTypeOf(updater).toEqualTypeOf<Updater<FidoRegistrationCollector>>();
 
-        // 3. The updater parameter should accept FidoRegistrationInputValue
-        expectTypeOf(updater).parameter(0).toEqualTypeOf<FidoRegistrationInputValue>();
+        // 3. The updater parameter should accept FidoRegistrationInputValue | GenericError (Either)
+        expectTypeOf(updater)
+          .parameter(0)
+          .toEqualTypeOf<FidoRegistrationInputValue | GenericError>();
       }
     });
 
@@ -209,8 +213,10 @@ describe('Updater Type Narrowing with Real Usage Pattern', () => {
         const updater = mockUpdate(collector);
         expectTypeOf(updater).toEqualTypeOf<Updater<FidoAuthenticationCollector>>();
 
-        // 3. The updater parameter should accept FidoAuthenticationInputValue
-        expectTypeOf(updater).parameter(0).toEqualTypeOf<FidoAuthenticationInputValue>();
+        // 3. The updater parameter should accept FidoAuthenticationInputValue | GenericError (Either)
+        expectTypeOf(updater)
+          .parameter(0)
+          .toEqualTypeOf<FidoAuthenticationInputValue | GenericError>();
       }
     });
   });
@@ -308,7 +314,9 @@ describe('Updater Type Narrowing with Real Usage Pattern', () => {
         expectTypeOf(collector).toEqualTypeOf<FidoRegistrationCollector>();
         const updater = mockUpdate(collector);
         expectTypeOf(updater).toEqualTypeOf<Updater<FidoRegistrationCollector>>();
-        expectTypeOf(updater).parameter(0).toEqualTypeOf<FidoRegistrationInputValue>();
+        expectTypeOf(updater)
+          .parameter(0)
+          .toEqualTypeOf<FidoRegistrationInputValue | GenericError>();
       }
     });
   });

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally WLP0-Akmg

Apply fix locally with your editor ↗   View interactive diff ↗



🎓 Learn more about Self-Healing CI on nx.dev

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.

3 participants