Skip to content

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

Merged
ancheetah merged 1 commit into
mainfrom
SDKS-5100-metadata-collector
Jul 29, 2026
Merged

feat(davinci-client): add metadata collector (SDKS-5100)#727
ancheetah merged 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: fc0caf2

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
📝 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 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 44abe1c

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 39s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-07-28 20:08:27 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[bot]

This comment was marked as outdated.

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

@codecov-commenter

codecov-commenter commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.46154% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 23.26%. Comparing base (eafe277) to head (fc0caf2).
⚠️ 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 ⚠️

❌ 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.18%     
==========================================
  Files         155      161       +6     
  Lines       24398    25661    +1263     
  Branches     1203     1626     +423     
==========================================
+ Hits         4410     5970    +1560     
+ Misses      19988    19691     -297     
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% <ø> (ø)
packages/davinci-client/src/types.ts 12.50% <100.00%> (ø)
packages/davinci-client/src/lib/davinci.api.ts 29.54% <0.00%> (+17.57%) ⬆️
packages/davinci-client/src/lib/davinci.utils.ts 86.41% <50.00%> (-3.53%) ⬇️

... 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 e7bf2cf to https://ForgeRock.github.io/ping-javascript-sdk/pr-727/e7bf2cf489baa697bd08ebd2a115c3f77f51d71d 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

🆕 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.2 KB (+0.8 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

@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 Outdated
@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
Comment on lines +459 to +470
/**
* @method getMetadataError - Constructs a structured error object from a code and message.
* @param {MetadataError} errorDetails - An error code and description.
* @returns {MetadataError} The structured error object.
*/
getMetadataError: (errorDetails: MetadataError): MetadataError => {
return {
code: errorDetails.code,
message: errorDetails.message,
};
},

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.

I would expect this to be on the collector itself, and not part of the public api.

Is there a reason we decided to add it here?

input: {
key: field.key,
value: defaultValue,
value: field.type !== 'METADATA' ? defaultValue : {},

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.

Do we need this here if we are mutating defaultValue on lines 875/876?

I think we can choose one?

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.

I think you may have reviewed this before I moved the collector to AutoCollectors. This is outdated.

Comment on lines +15 to +19
export function getMetadataError(errorDetails: MetadataError): MetadataError {
return {
code: errorDetails.code,
message: errorDetails.message,
};

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.

I spoke with AJ about this. My feeling is that we are creating an API, and a new API surface in general, to do dot notation.

We are already asking the consumer to transform their error shape into a MetadataError and then we are saying we will look up code and message for you.

I don't really understand this abstraction since they've already done the transformation.

It could be a type but then AJ brought up "what if they don't use typescript" which is a fair point, but then the same question arises with how do they know how to get their error shape to MetadataError.

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

Just one major comment about exposing DaVinciRequestValueTypes as public API, rest are very minor comments

* of the MIT license. See the LICENSE file for details.
*/

export interface MetadataError {

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.

Is it better to move this to the collector.types.ts or types.ts file or really any other existing types file? Because this is a collector related type, I am wondering the need for a new file here.

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.

Once we move MetadataError to collector.types.ts file, both utils.ts here and the utils.types.ts files are redundant

/**
* Allowed value types for DaVinci formData request bodies. This differs from `CollectorValueTypes` because input values may be transformed for DaVinci.
*/
export type DaVinciRequestValueTypes =

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.

My understanding is that client.types.ts is for public API, is that correct? This is a type that sends a request to davinci, right? Why is this a public API? Does it belong ing davinci.types.ts file or somewhere non-public?

Comment thread packages/davinci-client/src/types.ts Outdated
export type { FidoClient } from './lib/fido/fido.js';

// Utility types
export * from './lib/utils/utils.types.js';

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.

And this can be removed as well, once the file is gone.

Comment thread packages/davinci-client/package.json Outdated
".": "./dist/src/index.js",
"./types": "./dist/src/types.d.ts"
"./types": "./dist/src/types.d.ts",
"./utils": "./dist/src/lib/utils/utils.js"

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.

This will be unnecessary too once we remove the utils.ts file

@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from 00388a5 to 44abe1c Compare July 28, 2026 19:55
@ancheetah
ancheetah force-pushed the SDKS-5100-metadata-collector branch from 44abe1c to fc0caf2 Compare July 28, 2026 20:03
@ancheetah

Copy link
Copy Markdown
Collaborator Author

Removed metadata utils. Ready for review again.

@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 has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

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


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

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

Code looks good now! Less files and no public API additions!

Checked the e2e app and both success and failure cases echo back the info!

@ancheetah
ancheetah merged commit f705d4d into main Jul 29, 2026
7 of 8 checks passed
@ancheetah
ancheetah deleted the SDKS-5100-metadata-collector branch July 29, 2026 21:05
@ryanbas21 ryanbas21 mentioned this pull request Jul 29, 2026
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.

6 participants