Skip to content

feat(davinci-client): add metadata collector (SDKS-5100)#727

Open
ancheetah wants to merge 1 commit into
mainfrom
SDKS-5100-metadata-collector
Open

feat(davinci-client): add metadata collector (SDKS-5100)#727
ancheetah wants to merge 1 commit into
mainfrom
SDKS-5100-metadata-collector

Conversation

@ancheetah

@ancheetah ancheetah commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

JIRA Ticket

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

Description

What

Adds MetadataCollector support to davinci-client, enabling DaVinci flows to deliver server-side metadata payloads (e.g. session tokens, user context) to client applications. The collector carries its payload in output.value and reports success or structured errors back to the server via transformActionRequest.

Why

DaVinci flows need a mechanism to push arbitrary metadata to the client and receive a status (success or error) in return, without relying on a standard form submission. This fills that gap in the collector model.

Changes

  • New types: MetadataCollector, MetadataError, MetadataField, and DaVinciRequestValueTypes (extracted from inline union in davinci.utils.ts)
  • collector.types.ts / collector.utils.ts: Added MetadataCollector type alias and returnMetadataCollector factory; updated returnObjectCollector to handle the label-less METADATA field shape
  • node.reducer.ts: Added METADATA case to build a MetadataCollector from a field; added object-type guard for MetadataCollector update values
  • node.slice.ts: Falls back to metadataCollector.output.key for client.action when no SubmitCollector is present
  • davinci.api.ts: Auto-routes to transformActionRequest when a MetadataCollector is in the collector list
  • davinci.utils.ts: transformActionRequest now collects form data from all value-bearing collectors and includes it in the request body alongside actionKey
  • client.store.ts: Exposes getMetadataError helper on the client facade for constructing structured error objects
  • Tests: Unit tests for returnMetadataCollector and reducer MetadataField handling (create, update, invalid update)
  • E2e app: Added metadataComponent demonstrating success and error paths; wired into main.ts

Summary by CodeRabbit

  • New Features

    • Added metadata collection support for capturing structured values during journeys.
    • Added standardized metadata error handling with code and message details.
    • Added public metadata types and utility exports.
    • Metadata submissions now support both success and error outcomes.
  • Bug Fixes

    • Improved request handling and state transitions for metadata collection.
  • Tests

    • Added end-to-end coverage for successful and failed metadata flows.

@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 00388a5

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

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 01aba1d5-cfbb-4322-8401-a81c1d7fe719

📥 Commits

Reviewing files that changed from the base of the PR and between a2cae19 and 00388a5.

📒 Files selected for processing (26)
  • .changeset/real-swans-leave.md
  • e2e/davinci-app/components/metadata.ts
  • e2e/davinci-app/main.ts
  • e2e/davinci-app/server-configs.ts
  • e2e/davinci-suites/src/metadata.test.ts
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/api-report/davinci-client.utils.api.md
  • packages/davinci-client/package.json
  • packages/davinci-client/src/lib/client.types.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.api.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • packages/davinci-client/src/lib/node.types.ts
  • packages/davinci-client/src/lib/utils/metadata.types.ts
  • packages/davinci-client/src/lib/utils/metadata.utils.ts
  • packages/davinci-client/src/lib/utils/utils.ts
  • packages/davinci-client/src/lib/utils/utils.types.ts
  • packages/davinci-client/src/types.ts
🚧 Files skipped from review as they are similar to previous changes (17)
  • .changeset/real-swans-leave.md
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • e2e/davinci-suites/src/metadata.test.ts
  • e2e/davinci-app/main.ts
  • packages/davinci-client/src/lib/node.types.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/collector.utils.test.ts
  • e2e/davinci-app/server-configs.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/collector.types.ts
  • packages/davinci-client/src/lib/davinci.api.ts
  • packages/davinci-client/src/lib/collector.utils.ts
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/api-report/davinci-client.api.md

📝 Walkthrough

Walkthrough

Adds a MetadataCollector type, field handling, structured metadata errors, action-request submission, reducer support, package exports, and an end-to-end success/error form flow.

Changes

Metadata collector support

Layer / File(s) Summary
Metadata contracts and public types
packages/davinci-client/src/lib/{davinci.types.ts,collector.types.ts,client.types.ts}, packages/davinci-client/src/lib/utils/*, packages/davinci-client/src/types.ts, packages/davinci-client/package.json, packages/davinci-client/api-report/*, .changeset/*
Adds MetadataField, MetadataCollector, MetadataError, metadata value typing, public utility exports, updated client/cache declarations, and a minor-release changeset.
Metadata collector construction and updates
packages/davinci-client/src/lib/collector.utils.ts, packages/davinci-client/src/lib/node.reducer.ts, packages/davinci-client/src/lib/*test*
Constructs metadata collectors from METADATA fields, copies payload configuration, validates object updates, and adds utility, reducer, and type coverage.
Metadata submission and client state
packages/davinci-client/src/lib/davinci.api.ts, packages/davinci-client/src/lib/davinci.utils.ts, packages/davinci-client/src/lib/node.slice.ts
Selects action requests for metadata collectors, transforms metadata values into request form data, and derives the client action from metadata when needed.
Metadata form interaction
e2e/davinci-app/components/metadata.ts, e2e/davinci-app/main.ts, e2e/davinci-app/server-configs.ts, e2e/davinci-suites/src/metadata.test.ts
Renders metadata success/error controls, updates and submits the collector, and verifies both result paths end to end.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: cerebrl, ryanbas21

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding metadata collector support to davinci-client.
Description check ✅ Passed The description matches the template with a JIRA ticket and detailed What, Why, and Changes sections.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch SDKS-5100-metadata-collector

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 Jul 20, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 00388a5

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

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-27 15:13:31 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/davinci-client/src/lib/client.store.ts (1)

459-471: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove commented-out code.

It looks like the isClientError property was considered but isn't part of the MetadataError type. Consider removing the dead code to keep the file clean.

♻️ Proposed refactor
     /**
      * `@method` getMetadataError - Constructs a structured error object from a code and message.
      * `@param` {{ code: string; message: string; }} errorDetails - An error code and description.
      * `@returns` {{ code: string; message: string }} The structured error object.
      */
-    getMetadataError: (errorDetails: MetadataError): MetadataError => {
-      return {
-        code: errorDetails.code,
-        message: errorDetails.message,
-        // isClientError: true,
-      };
-    },
+    getMetadataError: (errorDetails: MetadataError): MetadataError => ({
+      code: errorDetails.code,
+      message: errorDetails.message,
+    }),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/davinci-client/src/lib/client.store.ts` around lines 459 - 471,
Remove the commented-out isClientError line from getMetadataError while
preserving the existing MetadataError fields and return behavior.
packages/davinci-client/src/lib/node.slice.ts (1)

195-198: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer find over filter()[0].

Using find is slightly more efficient and idiomatic since it avoids allocating an intermediate array and stops iterating once a match is found.

♻️ Proposed refactor
-      const metadataCollector = collectors.filter(
+      const metadataCollector = collectors.find(
         (collector): collector is MetadataCollector => collector.type === 'MetadataCollector',
-      )[0];
+      );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/davinci-client/src/lib/node.slice.ts` around lines 195 - 198, Update
the metadata collector lookup in the surrounding node slice logic to use find
with the existing MetadataCollector type guard instead of filter()[0]. Preserve
the current result, including undefined when no matching collector exists.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/davinci-client/src/lib/client.types.ts`:
- Around line 47-48: Update the CollectorValueTypes union in client.types.ts to
include Record<string, unknown> alongside MetadataError and the existing value
types, allowing standard object payloads for MetadataCollector updates.

In `@packages/davinci-client/src/lib/node.reducer.ts`:
- Around line 341-347: Update the MetadataCollector validation in the reducer to
explicitly reject null values in addition to non-objects and arrays before
assigning collector.input.value. Also harden the PhoneNumberCollector and
FidoRegistrationCollector validation paths against null before using the in
operator, preserving their existing validation behavior for valid objects.

---

Nitpick comments:
In `@packages/davinci-client/src/lib/client.store.ts`:
- Around line 459-471: Remove the commented-out isClientError line from
getMetadataError while preserving the existing MetadataError fields and return
behavior.

In `@packages/davinci-client/src/lib/node.slice.ts`:
- Around line 195-198: Update the metadata collector lookup in the surrounding
node slice logic to use find with the existing MetadataCollector type guard
instead of filter()[0]. Preserve the current result, including undefined when no
matching collector exists.
🪄 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: e7a845e5-8d09-49fc-ae39-e9e2f576e8e7

📥 Commits

Reviewing files that changed from the base of the PR and between 9549894 and d076641.

📒 Files selected for processing (17)
  • e2e/davinci-app/components/metadata.ts
  • e2e/davinci-app/main.ts
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/client.types.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.api.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • packages/davinci-client/src/lib/node.types.ts

Comment on lines +47 to +48
| FidoAuthenticationInputValue
| MetadataError;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add Record<string, unknown> to CollectorValueTypes.

The CollectorValueTypes union defines the acceptable payloads for the updateCollectorValues action. Since the new MetadataCollector stores input values typed as Record<string, unknown>, this type must be explicitly included in the union alongside MetadataError. Without it, dispatching updates for a metadata collector using a standard object payload can result in TypeScript compilation errors.

💻 Proposed fix
-  | FidoAuthenticationInputValue
-  | MetadataError;
+  | FidoAuthenticationInputValue
+  | MetadataError
+  | Record<string, unknown>;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| FidoAuthenticationInputValue
| MetadataError;
| FidoAuthenticationInputValue
| MetadataError
| Record<string, unknown>;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/davinci-client/src/lib/client.types.ts` around lines 47 - 48, Update
the CollectorValueTypes union in client.types.ts to include Record<string,
unknown> alongside MetadataError and the existing value types, allowing standard
object payloads for MetadataCollector updates.

Comment thread packages/davinci-client/src/lib/node.reducer.ts

@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.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud is proposing a fix for your failed CI:

We updated the transformActionRequest test to include formData: {} in the expected request payload, matching the new behavior introduced by this PR. The PR modified transformActionRequest in davinci.utils.ts to reduce non-action collectors into a formData object and include it in the request, but the test's expected value was not updated accordingly. This fix aligns the test with the current implementation so the assertion passes correctly.

Tip

We verified this fix by re-running @forgerock/davinci-client:test.

diff --git a/packages/davinci-client/src/lib/davinci.utils.test.ts b/packages/davinci-client/src/lib/davinci.utils.test.ts
index 094d4d9..f2f36eb 100644
--- a/packages/davinci-client/src/lib/davinci.utils.test.ts
+++ b/packages/davinci-client/src/lib/davinci.utils.test.ts
@@ -243,6 +243,7 @@ describe('transformActionRequest', () => {
         eventType: 'action',
         data: {
           actionKey: 'TEST_ACTION',
+          formData: {},
         },
       },
     };

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally nPN3-s8Wg

Apply fix locally with your editor ↗   View interactive diff ↗



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

@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from d076641 to b8c285f Compare July 20, 2026 20:06
@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

@forgerock/davinci-client

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

@forgerock/device-client

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

@forgerock/journey-client

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

@forgerock/oidc-client

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

@forgerock/protect

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

@forgerock/sdk-types

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

@forgerock/sdk-utilities

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

@forgerock/iframe-manager

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

@forgerock/sdk-logger

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

@forgerock/sdk-oidc

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

@forgerock/sdk-request-middleware

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

@forgerock/storage

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

commit: 00388a5

@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.51282% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.26%. Comparing base (eafe277) to head (00388a5).
⚠️ Report is 48 commits behind head on main.

Files with missing lines Patch % Lines
packages/davinci-client/src/lib/davinci.utils.ts 50.00% 8 Missing ⚠️
packages/davinci-client/src/lib/davinci.api.ts 0.00% 6 Missing ⚠️
...ges/davinci-client/src/lib/utils/metadata.utils.ts 14.28% 6 Missing ⚠️
packages/davinci-client/src/lib/utils/utils.ts 50.00% 1 Missing ⚠️
...ckages/davinci-client/src/lib/utils/utils.types.ts 50.00% 1 Missing ⚠️
packages/davinci-client/src/types.ts 50.00% 1 Missing ⚠️

❌ Your project status has failed because the head coverage (23.26%) 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     #727      +/-   ##
==========================================
+ Coverage   18.07%   23.26%   +5.19%     
==========================================
  Files         155      165      +10     
  Lines       24398    25674    +1276     
  Branches     1203     1630     +427     
==========================================
+ Hits         4410     5974    +1564     
+ Misses      19988    19700     -288     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/client.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/collector.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/collector.utils.ts 87.13% <100.00%> (+1.98%) ⬆️
packages/davinci-client/src/lib/davinci.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/node.reducer.ts 74.20% <100.00%> (+3.72%) ⬆️
packages/davinci-client/src/lib/node.slice.ts 76.95% <100.00%> (+0.25%) ⬆️
packages/davinci-client/src/lib/node.types.ts 100.00% <ø> (ø)
...ges/davinci-client/src/lib/utils/metadata.types.ts 100.00% <100.00%> (ø)
packages/davinci-client/src/lib/utils/utils.ts 50.00% <50.00%> (ø)
...ckages/davinci-client/src/lib/utils/utils.types.ts 50.00% <50.00%> (ø)
... and 4 more

... and 14 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 Jul 20, 2026

Copy link
Copy Markdown
Contributor

Deployed b015428 to https://ForgeRock.github.io/ping-javascript-sdk/pr-727/b0154288625c365329d5318da3ccc689ebb70513 branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔺 @forgerock/davinci-client - 56.7 KB (+2.4 KB, +4.3%)

🆕 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)

➖ 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

@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch 2 times, most recently from fdb36d4 to 82986b0 Compare July 21, 2026 15:13
Comment thread packages/davinci-client/src/lib/davinci.api.ts Outdated
Comment thread packages/davinci-client/src/lib/davinci.utils.ts Outdated
Comment thread packages/davinci-client/src/lib/davinci.api.ts Outdated
Comment thread packages/davinci-client/src/lib/davinci.api.ts Outdated
@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from 82986b0 to c3b91d2 Compare July 21, 2026 20:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/davinci-client/src/lib/client.types.ts`:
- Around line 54-63: Add Record<string, unknown> to the DaVinciRequestValueTypes
union in packages/davinci-client/src/lib/client.types.ts (lines 54-63) so
metadata object values are supported. Regenerate the API report at
packages/davinci-client/api-report/davinci-client.types.api.md (lines 642-643)
to reflect the updated public type.
🪄 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: 1b3d99c0-9fb5-4548-b70b-079d37d802fd

📥 Commits

Reviewing files that changed from the base of the PR and between fdb36d4 and c3b91d2.

📒 Files selected for processing (18)
  • .changeset/real-swans-leave.md
  • e2e/davinci-app/components/metadata.ts
  • e2e/davinci-app/main.ts
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/client.types.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.api.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • packages/davinci-client/src/lib/node.types.ts
🚧 Files skipped from review as they are similar to previous changes (12)
  • .changeset/real-swans-leave.md
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • e2e/davinci-app/main.ts
  • packages/davinci-client/src/lib/node.types.ts
  • packages/davinci-client/src/lib/davinci.api.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/api-report/davinci-client.api.md

Comment thread packages/davinci-client/src/lib/client.types.ts
@ancheetah

Copy link
Copy Markdown
Collaborator Author

Moved MetadataCollector interface from ObjectValueCollector to ObjectValueAutoCollector category

@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from c3b91d2 to 8693a1d Compare July 21, 2026 21:03
Comment on lines +102 to +107
const formData = collectors?.reduce<{
[key: string]: DaVinciRequestValueTypes | Record<string, unknown>;
}>((acc, collector) => {
acc[collector.input.key] = collector.input.value;
return acc;
}, {});

@ancheetah ancheetah Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Besides the MetadataCollector, an action request really shouldn't have any data that is collected but including this here just in case.

data: {
actionKey: action,
actionKey: action || node.client?.action || '',
...(Object.keys(formData ?? {}).length && { formData: formData }),

@ancheetah ancheetah Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note that in the FIDO error PR coming up this will be updated to formData: formData ?? {} to align with the contract. Native always sends an empty object for all action requests so this should be harmless.
#728

@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from 8693a1d to a2cae19 Compare July 23, 2026 21:05
@ancheetah

Copy link
Copy Markdown
Collaborator Author

Added e2e tests

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/davinci-app/components/metadata.ts`:
- Around line 26-35: Update the successBtn.onclick and errorBtn.onclick handlers
to catch rejected submitForm() promises and route the failure through the
example app’s existing error handling or reporting mechanism, while preserving
their current updater calls and submission behavior.
🪄 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 Plus

Run ID: 959fa4f0-82c6-459f-8a41-f8926820dcad

📥 Commits

Reviewing files that changed from the base of the PR and between c3b91d2 and a2cae19.

📒 Files selected for processing (20)
  • .changeset/real-swans-leave.md
  • e2e/davinci-app/components/metadata.ts
  • e2e/davinci-app/main.ts
  • e2e/davinci-app/server-configs.ts
  • e2e/davinci-suites/src/metadata.test.ts
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/client.types.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.api.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • packages/davinci-client/src/lib/node.types.ts
🚧 Files skipped from review as they are similar to previous changes (17)
  • .changeset/real-swans-leave.md
  • packages/davinci-client/src/lib/node.types.test-d.ts
  • packages/davinci-client/src/lib/node.reducer.test.ts
  • packages/davinci-client/src/lib/node.slice.ts
  • packages/davinci-client/src/lib/davinci.api.ts
  • packages/davinci-client/src/lib/node.types.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/collector.types.ts
  • e2e/davinci-app/main.ts
  • packages/davinci-client/src/lib/collector.utils.test.ts
  • packages/davinci-client/src/lib/client.store.ts
  • packages/davinci-client/src/lib/collector.utils.ts
  • packages/davinci-client/src/lib/node.reducer.ts
  • packages/davinci-client/src/lib/davinci.utils.ts
  • packages/davinci-client/src/lib/client.types.ts
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md

Comment on lines +26 to +35
successBtn.onclick = async () => {
updater({ status: 'succeeded' });
await submitForm();
};

errorBtn.onclick = async () => {
const metadataError = getMetadataError({ code: 'ERROR_CODE', message: 'Operation cancelled' });
updater(metadataError);
await submitForm();
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Handle rejected submission promises.

If submitForm() rejects, both async event handlers produce an unhandled promise rejection, leaving the UI without an error path. Catch the failure and route it through the example app’s existing error handling or reporting mechanism.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/davinci-app/components/metadata.ts` around lines 26 - 35, Update the
successBtn.onclick and errorBtn.onclick handlers to catch rejected submitForm()
promises and route the failure through the example app’s existing error handling
or reporting mechanism, while preserving their current updater calls and
submission behavior.

@cerebrl cerebrl 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.

This looks good. I just have the one question about the error method.

* @param {MetadataError} errorDetails - An error code and description.
* @returns {MetadataError} The structured error object.
*/
getMetadataError: (errorDetails: MetadataError): MetadataError => {

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.

Are we exposing this in order for the app to conveniently construct the expected error shape if there's a client error? I'm quite hesitant to attach this to the Client store as it's not "interacting" with the store in any meaningful way.

If we want to provide such utility functions, I'd rather export them separately as just functions under a different directory. Maybe something like this:

import { someUtilFn } from '@forgerock/davinci-client/utils';

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah it's a little silly but idk how else the consumer is supposed to know what shape the error needs to be. I wasn't sure where to put this but I can certainly move it to utils.

@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from a2cae19 to 00388a5 Compare July 27, 2026 15:08
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