Skip to content

feat(davinci-client): add label and validated password fields#94

Merged
ryanbas21 merged 1 commit into
mainfrom
feat_label-validated-password-support
Feb 22, 2025
Merged

feat(davinci-client): add label and validated password fields#94
ryanbas21 merged 1 commit into
mainfrom
feat_label-validated-password-support

Conversation

@cerebrl
Copy link
Copy Markdown
Collaborator

@cerebrl cerebrl commented Feb 20, 2025

JIRA Ticket

Jira ticket

Description

This adds support for the password validate and the label field component.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 20, 2025

🦋 Changeset detected

Latest commit: 34f4140

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@forgerock/davinci-client 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

@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented Feb 20, 2025

View your CI Pipeline Execution ↗ for commit 34f4140.

Command Status Duration Result
nx affected -t build typecheck lint test e2e-ci ✅ Succeeded 1m 29s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 3s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-21 23:47:08 UTC

Comment thread .husky/install.mjs Outdated
process.exit(0)
}
const husky = (await import('husky')).default
console.log(husky.install())
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 don't think we want to delete this,, right? I believe the fix is just to invoke husky() like that.

I have that fix in some other PR currently open.

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.

Ah, okay, I can put this back. I think it was just the console.log that caused the lint failure.

/**
* @method validate - Method for validating the value against validation rules
* @param {SingleValueCollector} collector - the collector to validate
* @returns {function} - an function to call for validating collector value
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.

a function right?

console.error('Argument for `collector` has no ID');
return function () {
return {
error: { message: 'Argument for `collector` has no ID', type: 'argument_error' },
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.

Note: Because we seem to be following this shape elsewhere, I wonder if we should create a function to make this error so we are consistent about it everywhere?

something like

makeError(message: string, type: union|of|error|types) => ShapeOfError

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, we can definitely do this. Not sure I want to do it now, but I think reducing redundancy in this project is going to be important.

Comment on lines +19 to +31
interface ValidationRequired {
type: 'required';
message: string;
rule: boolean;
}

interface ValidationRegex {
type: 'regex';
message: string;
rule: string;
}

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.

Not worth changing at this point, but if this is something that will "expand" as more validation types are built, This looks like a good use case for a discriminated union.

Since it's already used like that here: https://github.com/ForgeRock/ping-javascript-sdk/pull/94/files#diff-c9b63f466f9bc9b03f3122bc3f5d75531a0adb0ba81e42bec6d35ab659df1fbaR60

Again - no change at this point, but maybe worth while if we are back here again to add more validation "types"

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.

This is a good idea. I do have to say I'm not a huge fan of how much repetition these types have with each other, but that could be a good conversation in the near future.

it('handles missing authentication URL for social login', () => {
const result = returnActionCollector(mockField, 1, 'SocialLoginCollector');
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
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.

Why do we want ts-ignore here?

const field = {};
const idx = 3;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
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.

and here?

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.

Because it's a type error if removed. Since we are essentially checking runtime issues that TS would prevent.

const field = {};
const idx = 3;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
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.

same question

*/
export function returnActionCollector<CollectorType extends ActionCollectorTypes>(
field: StandardFieldValue,
field: RedirectFieldValue | StandardFieldValue,
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.

FWIW - I think this type actually fits the StandardFieldValue type because StandardFieldValue does have optional links.

Worth adding this to the StandardFieldValue union?

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.

nevermind, I see the change below.

};
}

return returnValidator(collectorToUpdate as ValidatedTextCollector);
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 seems like a code smell. We should have better inference at this point, but checking this out locally typescript says we have

(property) type: "PasswordCollector" | "SingleSelectCollector" | "SingleValueCollector" | "TextCollector"

So we must be missing something somewhere since ValidatedTextCollector isnt even in the list of possibilities but we are forcing it here

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.

Maybe this type needs to be added to the SingleValueCollector type?

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.

Oh, okay, I'll check that out.

@cerebrl cerebrl force-pushed the feat_label-validated-password-support branch 5 times, most recently from ac66297 to 080554a Compare February 21, 2025 22:55
@cerebrl cerebrl force-pushed the feat_label-validated-password-support branch from 080554a to 34f4140 Compare February 21, 2025 23:44
@github-actions
Copy link
Copy Markdown
Contributor

Deployed 87f2215 to https://ForgeRock.github.io/ping-javascript-sdk/pr-94/87f2215676c47c7deca776646f4b3ab41929b687 branch gh-pages in ForgeRock/ping-javascript-sdk

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 21, 2025

Codecov Report

❌ Patch coverage is 47.20497% with 85 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.17%. Comparing base (fa660ce) to head (34f4140).
⚠️ Report is 653 commits behind head on main.

Files with missing lines Patch % Lines
packages/davinci-client/src/lib/client.store.ts 0.00% 44 Missing ⚠️
packages/davinci-client/src/lib/collector.utils.ts 64.81% 38 Missing ⚠️
packages/davinci-client/src/lib/node.reducer.ts 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #94      +/-   ##
==========================================
+ Coverage   47.12%   54.17%   +7.05%     
==========================================
  Files          29       20       -9     
  Lines        1129     1102      -27     
  Branches      137      145       +8     
==========================================
+ Hits          532      597      +65     
+ Misses        597      505      -92     
Files with missing lines Coverage Δ
packages/davinci-client/src/lib/collector.types.ts 100.00% <100.00%> (ø)
packages/davinci-client/src/lib/davinci.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/lib/node.types.ts 100.00% <ø> (ø)
packages/davinci-client/src/types.ts 0.00% <ø> (ø)
packages/davinci-client/src/lib/node.reducer.ts 76.13% <62.50%> (-1.65%) ⬇️
packages/davinci-client/src/lib/collector.utils.ts 83.39% <64.81%> (-11.99%) ⬇️
packages/davinci-client/src/lib/client.store.ts 0.00% <0.00%> (ø)

... and 9 files with indirect coverage changes

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

@ryanbas21 ryanbas21 merged commit 5d09d04 into main Feb 22, 2025
@ryanbas21 ryanbas21 mentioned this pull request Feb 21, 2025
@SteinGabriel SteinGabriel deleted the feat_label-validated-password-support branch April 17, 2026 15:51
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