Skip to content

feat(davinci-client): rich-text-collector#568

Open
ryanbas21 wants to merge 3 commits intomainfrom
rich-content-links
Open

feat(davinci-client): rich-text-collector#568
ryanbas21 wants to merge 3 commits intomainfrom
rich-content-links

Conversation

@ryanbas21
Copy link
Copy Markdown
Collaborator

@ryanbas21 ryanbas21 commented Apr 13, 2026

JIRA Ticket

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

Description

  • Add support for links from Translatable Rich Text in PingOne Forms (DV-19096)
  • Pass through richContent structure (template + validated replacements array) on ReadOnlyCollector
  • Validate href protocols against allowlist (OWASP A03)
  • Pure functional implementation — no throws, discriminated result types throughout

Changes

  • API Types: RichContentReplacement, RichContent (with optional replacements)
  • Collector Types: RichContentLink, ValidatedReplacement (extensible union), CollectorRichContent, ReadOnlyCollectorBase
  • Validation: validateReplacements() — validates hrefs, converts Record to array with key field
  • Collector: returnReadOnlyCollector()output.content is plain text string, output.richContent is always present with template and validated replacements array
  • Security: href validation rejects javascript:, data:, and other unsafe URI schemes (allowlist: http:, https: only)

Collector Output Shape

output: {
  key: "rich-text-0",
  label: "This is a link...",          // plain text
  type: "LABEL",
  content: "This is a link...",     
  richContent: {                        // always present
    content: "This is a {{link1}}...", // template
    replacements: [                     // validated array, [] if none/error
      { key: "link1", type: "link", value: "link", href: "https://...", target: "_blank" }
    ]
  }
}
Screenshot 2026-04-22 at 2 08 38 PM

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

Warning

Rate limit exceeded

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

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 34 minutes and 47 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 99eeaec8-4e14-43cd-933b-b0bdb930826d

📥 Commits

Reviewing files that changed from the base of the PR and between 9088443 and 01d04e3.

📒 Files selected for processing (11)
  • .changeset/rich-content-links.md
  • .nxignore
  • e2e/davinci-app/components/label.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/collector.richcontent.test-d.ts
  • packages/davinci-client/src/lib/collector.types.ts
  • packages/davinci-client/src/lib/collector.utils.test.ts
  • packages/davinci-client/src/lib/collector.utils.ts
  • packages/davinci-client/src/lib/davinci.types.ts
  • packages/davinci-client/src/lib/mock-data/mock-form-fields.data.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rich-content-links

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Apr 13, 2026

View your CI Pipeline Execution ↗ for commit 01d04e3

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

☁️ Nx Cloud last updated this comment at 2026-04-22 20:22:14 UTC

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: 01d04e3

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

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 15.89%. Comparing base (5d6747a) to head (01d04e3).
⚠️ Report is 35 commits behind head on main.

❌ Your project status has failed because the head coverage (15.89%) 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     #568       +/-   ##
===========================================
- Coverage   70.90%   15.89%   -55.01%     
===========================================
  Files          53      154      +101     
  Lines        2021    26737    +24716     
  Branches      377     1148      +771     
===========================================
+ Hits         1433     4251     +2818     
- Misses        588    22486    +21898     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/collector.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/collector.utils.ts 84.11% <100.00%> (ø)
packages/davinci-client/src/lib/davinci.types.ts 100.00% <ø> (ø)

... and 98 files with indirect coverage changes

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 13, 2026

Open in StackBlitz

@forgerock/davinci-client

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

@forgerock/device-client

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

@forgerock/journey-client

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

@forgerock/oidc-client

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

@forgerock/protect

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

@forgerock/sdk-types

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

@forgerock/sdk-utilities

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

@forgerock/iframe-manager

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

@forgerock/sdk-logger

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

@forgerock/sdk-oidc

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

@forgerock/sdk-request-middleware

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

@forgerock/storage

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

commit: 01d04e3

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

Deployed 6506bae to https://ForgeRock.github.io/ping-javascript-sdk/pr-568/6506bae0960df0a3795c31723065c11af2cf03af branch gh-pages in ForgeRock/ping-javascript-sdk

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 13, 2026

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔻 @forgerock/device-client - 0.0 KB (-9.9 KB, -100.0%)
🔺 @forgerock/davinci-client - 49.4 KB (+1.4 KB, +3.0%)
🔻 @forgerock/journey-client - 0.0 KB (-89.9 KB, -100.0%)

📊 Minor Changes

📉 @forgerock/device-client - 9.9 KB (-0.0 KB)

➖ No Changes

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

@ryanbas21 ryanbas21 force-pushed the rich-content-links branch 4 times, most recently from 3e5d66d to d6223eb Compare April 15, 2026 15:51
Copy link
Copy Markdown
Contributor

@nx-cloud nx-cloud Bot left a comment

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 fix three lint errors introduced by the richContent feature: a Prettier formatting violation on long expectTypeOf chains in the type-test file, an inline object that exceeded Prettier's print width in the unit test, and an unused CollectorRichContent import in collector.utils.ts. These changes bring the code into compliance with the workspace's ESLint and Prettier rules without altering any runtime or type-level behaviour.

Tip

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

Suggested Fix changes
diff --git a/packages/davinci-client/src/lib/collector.richcontent.test-d.ts b/packages/davinci-client/src/lib/collector.richcontent.test-d.ts
index f671329c3..6142ef232 100644
--- a/packages/davinci-client/src/lib/collector.richcontent.test-d.ts
+++ b/packages/davinci-client/src/lib/collector.richcontent.test-d.ts
@@ -72,12 +72,18 @@ describe('Rich Content Types', () => {
     });
 
     it('should have required richContent with CollectorRichContent shape', () => {
-      expectTypeOf<ReadOnlyCollectorBase['output']['richContent']>().toEqualTypeOf<CollectorRichContent>();
+      expectTypeOf<
+        ReadOnlyCollectorBase['output']['richContent']
+      >().toEqualTypeOf<CollectorRichContent>();
     });
 
     it('should have standard collector fields', () => {
-      expectTypeOf<ReadOnlyCollectorBase>().toHaveProperty('category').toEqualTypeOf<'NoValueCollector'>();
-      expectTypeOf<ReadOnlyCollectorBase>().toHaveProperty('type').toEqualTypeOf<'ReadOnlyCollector'>();
+      expectTypeOf<ReadOnlyCollectorBase>()
+        .toHaveProperty('category')
+        .toEqualTypeOf<'NoValueCollector'>();
+      expectTypeOf<ReadOnlyCollectorBase>()
+        .toHaveProperty('type')
+        .toEqualTypeOf<'ReadOnlyCollector'>();
       expectTypeOf<ReadOnlyCollectorBase>().toHaveProperty('error').toEqualTypeOf<string | null>();
     });
   });
diff --git a/packages/davinci-client/src/lib/collector.utils.test.ts b/packages/davinci-client/src/lib/collector.utils.test.ts
index 67316ca25..9ff5804b6 100644
--- a/packages/davinci-client/src/lib/collector.utils.test.ts
+++ b/packages/davinci-client/src/lib/collector.utils.test.ts
@@ -1273,7 +1273,13 @@ describe('validateReplacements', () => {
     expect(result).toEqual({
       ok: true,
       replacements: [
-        { key: 'link1', type: 'link', value: 'terms', href: 'https://example.com', target: '_blank' },
+        {
+          key: 'link1',
+          type: 'link',
+          value: 'terms',
+          href: 'https://example.com',
+          target: '_blank',
+        },
         { key: 'link2', type: 'link', value: 'policy', href: 'https://xyz.com', target: '_self' },
       ],
     });
@@ -1292,9 +1298,7 @@ describe('validateReplacements', () => {
 
     expect(result).toEqual({
       ok: true,
-      replacements: [
-        { key: 'link', type: 'link', value: 'here', href: 'https://example.com' },
-      ],
+      replacements: [{ key: 'link', type: 'link', value: 'here', href: 'https://example.com' }],
     });
   });
 
diff --git a/packages/davinci-client/src/lib/collector.utils.ts b/packages/davinci-client/src/lib/collector.utils.ts
index 757f88b92..17994836e 100644
--- a/packages/davinci-client/src/lib/collector.utils.ts
+++ b/packages/davinci-client/src/lib/collector.utils.ts
@@ -32,7 +32,6 @@ import type {
   QrCodeCollectorBase,
   ValidatedReplacement,
   ValidateReplacementsResult,
-  CollectorRichContent,
   ReadOnlyCollectorBase,
 } from './collector.types.js';
 import type {

Apply fix via Nx Cloud  Reject fix via Nx Cloud


Or Apply changes locally with:

npx nx-cloud apply-locally 5kUe-VYSS

Apply fix locally with your editor ↗   View interactive diff ↗



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

@ryanbas21 ryanbas21 force-pushed the rich-content-links branch 2 times, most recently from 24490a2 to 9e2532b Compare April 16, 2026 18:49
Support RichContent link types by creating a NoValueCollector for it
@ryanbas21 ryanbas21 force-pushed the rich-content-links branch from 9e2532b to 0b3a34e Compare April 16, 2026 19:53
@ryanbas21 ryanbas21 marked this pull request as ready for review April 22, 2026 20:09
@ryanbas21 ryanbas21 changed the title Rich content links feat(davinci-client): rich-text-collector Apr 22, 2026
- Add .nxignore to exclude vendored .opensource/ clone from Nx project
  graph (was causing duplicate-project errors vs forgerock-verdaccio).
- Render authored line breaks in ReadOnlyCollector rich text via
  white-space: pre-line on the rendered <p>.
Copy link
Copy Markdown
Collaborator

@cerebrl cerebrl left a comment

Choose a reason for hiding this comment

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

From initial scan.

label: string;
type: string;
content: string;
richContent: CollectorRichContent;
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.

Rather than adding more properties to the base collector, can we just add a new collector type for this rich content collector? This new collector can just extent the base collector adding the new property on the output. Does that make sense?

Comment on lines +736 to +738
if (!['https:', 'http:'].includes(href.protocol)) {
return { ok: false, error: `Unsafe href protocol for key: ${key}` };
}
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.

What are we preventing here? I see we're rejecting URLs without a protocol, but I'm not aware of what this prevents.

Comment on lines +820 to +831
// Validate that all {{key}} references in the template have corresponding replacements
const templateKeys = [...field.richContent.content.matchAll(/\{\{(\w+)\}\}/g)].map((m) => m[1]);
const apiReplacements = field.richContent.replacements ?? {};
const missingKeys = templateKeys.filter((k) => !(k in apiReplacements));
const templateErrors = missingKeys.map((k) => `Missing replacement for key: {{${k}}}`);

const validationResult =
templateErrors.length === 0 ? validateReplacements(apiReplacements) : null;

const replacements = validationResult?.ok ? validationResult.replacements : [];
const validationErrors = validationResult && !validationResult.ok ? [validationResult.error] : [];
const errors = [...fieldErrors, ...templateErrors, ...validationErrors];
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 think this is a cool idea, but I'm unsure if we are the right ones to do this validation. I feel like DaVinci should be the one to validate all of this as they are the source. If this type of error exists within this data structure, the implementing application would pick it up without our help. Right? Or, am I missing something?

Comment on lines +803 to +817
const errors = fieldErrors;
return {
category: 'NoValueCollector',
error: errors.length > 0 ? errors.join(' ') : null,
type: 'ReadOnlyCollector',
id,
name: id,
output: {
key: id,
label: field.content,
type: field.type,
content: field.content,
richContent: { content: field.content, replacements: [] },
},
};
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.

Is there a reason we don't just call the same function we called before this change: returnNoValueCollector?

Copy link
Copy Markdown
Contributor

@vatsalparikh vatsalparikh left a comment

Choose a reason for hiding this comment

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

Looks good overall, suggested minor changes

CollectorRichContent,
ValidateReplacementsResult,
NoValueCollector,
} from './collector.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.

Since we're importing from collectory types file, we should just move this stuff into collector.types.test-d.ts file so that collector types are all in one place. A file like collector.richcontent looks confusing and stands out.

target: string;
}

// @public (undocumented)
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.

We should add jsdoc comments to types and interfaces to remove this undocumented label

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.

4 participants