-
Notifications
You must be signed in to change notification settings - Fork 3
fix(davinci-client): fix collector value types and simplify node reducer imports #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| '@forgerock/davinci-client': patch | ||
| --- | ||
|
|
||
| Fixed collector value types and simplified node reducer imports | ||
|
|
||
| ### `client.types.ts` | ||
|
|
||
| - Renamed `CollectorInputTypes` → `CollectorValueTypes` and added `DeviceValue` to the union. | ||
| - Rewrote `CollectorValueType<T>` conditional type: grouped branches by return type (string, boolean, string[], specialized, category catch-alls), fixed `DeviceAuthenticationCollector` to return `DeviceValue` instead of `string`, added `never` for `ActionCollector` and `NoValueCollector`, and added a `SingleValueAutoCollector` catch-all. | ||
|
|
||
| ### `node.reducer.ts` / `client.store.ts` | ||
|
|
||
| - Replaced ~30 individual collector type imports with `Collectors` (from `node.types`) and `CollectorValueTypes` (from `client.types`), collapsing verbose inline union annotations to single-type references. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,3 +100,5 @@ GEMINI.md | |
|
|
||
| # Polaris | ||
| .polaris-setup-progress.json | ||
|
|
||
| .polaris/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,9 +177,6 @@ export interface CollectorErrors { | |
| target: string; | ||
| } | ||
|
|
||
| // @public (undocumented) | ||
| export type CollectorInputTypes = string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, this would be a breaking change, no? |
||
|
|
||
| // @public | ||
| export interface CollectorRichContent { | ||
| // (undocumented) | ||
|
|
@@ -194,8 +191,16 @@ export type Collectors = FlowCollector | PasswordCollector | ValidatedPasswordCo | |
| // @public | ||
| export type CollectorValueType<T> = T extends { | ||
| type: 'PasswordCollector'; | ||
| } ? string : T extends { | ||
| } | { | ||
| type: 'ValidatedPasswordCollector'; | ||
| } | { | ||
| type: 'SingleSelectCollector'; | ||
| } | { | ||
| type: 'DeviceRegistrationCollector'; | ||
| } | { | ||
| type: 'ProtectCollector'; | ||
| } | { | ||
| type: 'PollingCollector'; | ||
| } ? string : T extends { | ||
| type: 'TextCollector'; | ||
| category: 'SingleValueCollector'; | ||
|
|
@@ -205,14 +210,10 @@ export type CollectorValueType<T> = T extends { | |
| } ? string : T extends { | ||
| type: 'ValidatedBooleanCollector'; | ||
| } ? boolean : T extends { | ||
| type: 'SingleSelectCollector'; | ||
| } ? string : T extends { | ||
| type: 'MultiSelectCollector'; | ||
| } ? string[] : T extends { | ||
| type: 'DeviceRegistrationCollector'; | ||
| } ? string : T extends { | ||
| type: 'DeviceAuthenticationCollector'; | ||
| } ? string : T extends { | ||
| } ? DeviceValue : T extends { | ||
| type: 'PhoneNumberCollector'; | ||
| } ? PhoneNumberInputValue : T extends { | ||
| type: 'PhoneNumberExtensionCollector'; | ||
|
|
@@ -224,9 +225,18 @@ export type CollectorValueType<T> = T extends { | |
| category: 'SingleValueCollector'; | ||
| } ? string : T extends { | ||
| category: 'ValidatedSingleValueCollector'; | ||
| } ? string : T extends { | ||
| category: 'SingleValueAutoCollector'; | ||
| } ? string : T extends { | ||
| category: 'MultiValueCollector'; | ||
| } ? string[] : CollectorInputTypes; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also seems to have been removed here? |
||
| } ? string[] : T extends { | ||
| category: 'ActionCollector'; | ||
| } ? never : T extends { | ||
| category: 'NoValueCollector'; | ||
| } ? never : CollectorValueTypes; | ||
|
|
||
| // @public (undocumented) | ||
| export type CollectorValueTypes = string | string[] | boolean | DeviceValue | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue; | ||
|
|
||
| // @public (undocumented) | ||
| export type ComplexValueFields = DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField | PhoneNumberExtensionField | FidoRegistrationField | FidoAuthenticationField | PollingField; | ||
|
|
@@ -1187,8 +1197,8 @@ value: Record<string, unknown>; | |
| }, string>; | ||
|
|
||
| // @public | ||
| export const nodeCollectorReducer: Reducer<(ValidatedTextCollector | ValidatedBooleanCollector | ValidatedPasswordCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | PhoneNumberExtensionCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | TextCollector | PasswordCollector | SingleSelectCollector | UnknownCollector | IdpCollector | FlowCollector | SubmitCollector | ReadOnlyCollector | RichTextCollector | QrCodeCollector | AgreementCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector"> | MultiSelectCollector)[]> & { | ||
| getInitialState: () => (ValidatedTextCollector | ValidatedBooleanCollector | ValidatedPasswordCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | PhoneNumberExtensionCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | TextCollector | PasswordCollector | SingleSelectCollector | UnknownCollector | IdpCollector | FlowCollector | SubmitCollector | ReadOnlyCollector | RichTextCollector | QrCodeCollector | AgreementCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector"> | MultiSelectCollector)[]; | ||
| export const nodeCollectorReducer: Reducer<Collectors[]> & { | ||
| getInitialState: () => Collectors[]; | ||
| }; | ||
|
|
||
| // @public (undocumented) | ||
|
|
@@ -1918,7 +1928,7 @@ export type UnknownField = Record<string, unknown>; | |
| // @public (undocumented) | ||
| export const updateCollectorValues: ActionCreatorWithPayload< { | ||
| id: string; | ||
| value: string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue; | ||
| value: CollectorValueTypes; | ||
| index?: number; | ||
| }, string>; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,9 +177,6 @@ export interface CollectorErrors { | |
| target: string; | ||
| } | ||
|
|
||
| // @public (undocumented) | ||
| export type CollectorInputTypes = string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also removed here? |
||
|
|
||
| // @public | ||
| export interface CollectorRichContent { | ||
| // (undocumented) | ||
|
|
@@ -194,8 +191,16 @@ export type Collectors = FlowCollector | PasswordCollector | ValidatedPasswordCo | |
| // @public | ||
| export type CollectorValueType<T> = T extends { | ||
| type: 'PasswordCollector'; | ||
| } ? string : T extends { | ||
| } | { | ||
| type: 'ValidatedPasswordCollector'; | ||
| } | { | ||
| type: 'SingleSelectCollector'; | ||
| } | { | ||
| type: 'DeviceRegistrationCollector'; | ||
| } | { | ||
| type: 'ProtectCollector'; | ||
| } | { | ||
| type: 'PollingCollector'; | ||
| } ? string : T extends { | ||
| type: 'TextCollector'; | ||
| category: 'SingleValueCollector'; | ||
|
|
@@ -205,14 +210,10 @@ export type CollectorValueType<T> = T extends { | |
| } ? string : T extends { | ||
| type: 'ValidatedBooleanCollector'; | ||
| } ? boolean : T extends { | ||
| type: 'SingleSelectCollector'; | ||
| } ? string : T extends { | ||
| type: 'MultiSelectCollector'; | ||
| } ? string[] : T extends { | ||
| type: 'DeviceRegistrationCollector'; | ||
| } ? string : T extends { | ||
| type: 'DeviceAuthenticationCollector'; | ||
| } ? string : T extends { | ||
| } ? DeviceValue : T extends { | ||
| type: 'PhoneNumberCollector'; | ||
| } ? PhoneNumberInputValue : T extends { | ||
| type: 'PhoneNumberExtensionCollector'; | ||
|
|
@@ -224,9 +225,18 @@ export type CollectorValueType<T> = T extends { | |
| category: 'SingleValueCollector'; | ||
| } ? string : T extends { | ||
| category: 'ValidatedSingleValueCollector'; | ||
| } ? string : T extends { | ||
| category: 'SingleValueAutoCollector'; | ||
| } ? string : T extends { | ||
| category: 'MultiValueCollector'; | ||
| } ? string[] : CollectorInputTypes; | ||
| } ? string[] : T extends { | ||
| category: 'ActionCollector'; | ||
| } ? never : T extends { | ||
| category: 'NoValueCollector'; | ||
| } ? never : CollectorValueTypes; | ||
|
|
||
| // @public (undocumented) | ||
| export type CollectorValueTypes = string | string[] | boolean | DeviceValue | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue; | ||
|
|
||
| // @public (undocumented) | ||
| export type ComplexValueFields = DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField | PhoneNumberExtensionField | FidoRegistrationField | FidoAuthenticationField | PollingField; | ||
|
|
@@ -1184,8 +1194,8 @@ value: Record<string, unknown>; | |
| }, string>; | ||
|
|
||
| // @public | ||
| export const nodeCollectorReducer: Reducer<(ValidatedTextCollector | ValidatedBooleanCollector | ValidatedPasswordCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | PhoneNumberExtensionCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | TextCollector | PasswordCollector | SingleSelectCollector | UnknownCollector | IdpCollector | FlowCollector | SubmitCollector | ReadOnlyCollector | RichTextCollector | QrCodeCollector | AgreementCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector"> | MultiSelectCollector)[]> & { | ||
| getInitialState: () => (ValidatedTextCollector | ValidatedBooleanCollector | ValidatedPasswordCollector | DeviceAuthenticationCollector | DeviceRegistrationCollector | PhoneNumberCollector | PhoneNumberExtensionCollector | ProtectCollector | FidoRegistrationCollector | FidoAuthenticationCollector | PollingCollector | TextCollector | PasswordCollector | SingleSelectCollector | UnknownCollector | IdpCollector | FlowCollector | SubmitCollector | ReadOnlyCollector | RichTextCollector | QrCodeCollector | AgreementCollector | ActionCollector<"ActionCollector"> | SingleValueCollector<"SingleValueCollector"> | MultiSelectCollector)[]; | ||
| export const nodeCollectorReducer: Reducer<Collectors[]> & { | ||
| getInitialState: () => Collectors[]; | ||
| }; | ||
|
|
||
| // @public (undocumented) | ||
|
|
@@ -1915,7 +1925,7 @@ export type UnknownField = Record<string, unknown>; | |
| // @public (undocumented) | ||
| export const updateCollectorValues: ActionCreatorWithPayload< { | ||
| id: string; | ||
| value: string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue; | ||
| value: CollectorValueTypes; | ||
| index?: number; | ||
| }, string>; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import type { | |
| FidoAuthenticationInputValue, | ||
| PhoneNumberInputValue, | ||
| PhoneNumberExtensionInputValue, | ||
| DeviceValue, | ||
| AutoCollectors, | ||
| MultiValueCollectors, | ||
| ObjectValueCollectors, | ||
|
|
@@ -29,14 +30,16 @@ export interface InternalErrorResponse { | |
|
|
||
| export type InitFlow = () => Promise<FlowNode | InternalErrorResponse>; | ||
|
|
||
| export type CollectorInputTypes = | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could also be breaking? |
||
| export type CollectorValueTypes = | ||
| | string | ||
| | string[] | ||
| | boolean | ||
| | DeviceValue | ||
| | PhoneNumberInputValue | ||
| | PhoneNumberExtensionInputValue | ||
| | FidoRegistrationInputValue | ||
| | FidoAuthenticationInputValue; | ||
|
|
||
| /** | ||
| * Maps collector types to the specific value type they accept. | ||
| * This enables type narrowing when using the update method with specific collector types. | ||
|
|
@@ -49,39 +52,52 @@ export type CollectorInputTypes = | |
| * } | ||
| * ``` | ||
| */ | ||
| export type CollectorValueType<T> = T extends { type: 'PasswordCollector' } | ||
| ? string | ||
| : T extends { type: 'ValidatedPasswordCollector' } | ||
| export type CollectorValueType<T> = | ||
| // string input types | ||
| T extends | ||
| | { type: 'PasswordCollector' } | ||
| | { type: 'ValidatedPasswordCollector' } | ||
| | { type: 'SingleSelectCollector' } | ||
| | { type: 'DeviceRegistrationCollector' } | ||
| | { type: 'ProtectCollector' } | ||
| | { type: 'PollingCollector' } | ||
| ? string | ||
| : T extends { type: 'TextCollector'; category: 'SingleValueCollector' } | ||
| : // TextCollector branches must remain compound — category is the only discriminant | ||
| T extends { type: 'TextCollector'; category: 'SingleValueCollector' } | ||
| ? string | ||
| : T extends { type: 'TextCollector'; category: 'ValidatedSingleValueCollector' } | ||
| ? string | ||
| : T extends { type: 'ValidatedBooleanCollector' } | ||
| : // boolean input types | ||
| T extends { type: 'ValidatedBooleanCollector' } | ||
| ? boolean | ||
| : T extends { type: 'SingleSelectCollector' } | ||
| ? string | ||
| : T extends { type: 'MultiSelectCollector' } | ||
| ? string[] | ||
| : T extends { type: 'DeviceRegistrationCollector' } | ||
| ? string | ||
| : T extends { type: 'DeviceAuthenticationCollector' } | ||
| ? string | ||
| : T extends { type: 'PhoneNumberCollector' } | ||
| ? PhoneNumberInputValue | ||
| : T extends { type: 'PhoneNumberExtensionCollector' } | ||
| ? PhoneNumberExtensionInputValue | ||
| : T extends { type: 'FidoRegistrationCollector' } | ||
| ? FidoRegistrationInputValue | ||
| : T extends { type: 'FidoAuthenticationCollector' } | ||
| ? FidoAuthenticationInputValue | ||
| : T extends { category: 'SingleValueCollector' } | ||
| : // string[] input types | ||
| T extends { type: 'MultiSelectCollector' } | ||
| ? string[] | ||
| : // specialized input types | ||
| T extends { type: 'DeviceAuthenticationCollector' } | ||
| ? DeviceValue | ||
| : T extends { type: 'PhoneNumberCollector' } | ||
| ? PhoneNumberInputValue | ||
| : T extends { type: 'PhoneNumberExtensionCollector' } | ||
| ? PhoneNumberExtensionInputValue | ||
| : T extends { type: 'FidoRegistrationCollector' } | ||
| ? FidoRegistrationInputValue | ||
| : T extends { type: 'FidoAuthenticationCollector' } | ||
| ? FidoAuthenticationInputValue | ||
| : // category catch-alls | ||
| T extends { category: 'SingleValueCollector' } | ||
| ? string | ||
| : T extends { category: 'ValidatedSingleValueCollector' } | ||
| ? string | ||
| : T extends { category: 'SingleValueAutoCollector' } | ||
| ? string | ||
| : T extends { category: 'ValidatedSingleValueCollector' } | ||
| ? string | ||
| : T extends { category: 'MultiValueCollector' } | ||
| ? string[] | ||
| : CollectorInputTypes; | ||
| : T extends { category: 'MultiValueCollector' } | ||
| ? string[] | ||
| : T extends { category: 'ActionCollector' } | ||
| ? never | ||
| : T extends { category: 'NoValueCollector' } | ||
| ? never | ||
| : CollectorValueTypes; | ||
|
|
||
| /** | ||
| * A function type that updates a collector's value. Accepts values appropriate for the collector type. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a breaking-change bump for this release.
Line 2 sets this as a patch, but this PR removes/renames a public exported type (
CollectorInputTypes→CollectorValueTypes). That is a compile-time breaking API change for TypeScript consumers.Suggested changeset fix
📝 Committable suggestion
🤖 Prompt for AI Agents