Skip to content

Commit db80c05

Browse files
committed
fix(davinci-client): fix collector value types and simplify node reducer imports
1 parent 9f93d5e commit db80c05

9 files changed

Lines changed: 150 additions & 492 deletions

File tree

‎.changeset/little-lamps-float.md‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@forgerock/davinci-client': patch
3+
---
4+
5+
Fixed collector value types and simplified node reducer imports
6+
7+
### `client.types.ts`
8+
9+
- Added `CollectorValueTypes` union type; replaces inline unions in `updateCollectorValues` action payload (`node.reducer.ts`) and the `update` method return closure (`client.store.ts`).
10+
11+
- Rewrote `CollectorValueType<T>` conditional type: grouped branches by return type (string, boolean, string[], specialized, category catch-alls), added `never` for `ActionCollector` and `NoValueCollector`, and added a `SingleValueAutoCollector` catch-all.
12+
13+
### `node.reducer.ts` / `client.store.ts`
14+
15+
- 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.

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ GEMINI.md
100100

101101
# Polaris
102102
.polaris-setup-progress.json
103+
.playwright-mcp
104+
.polaris/

‎packages/davinci-client/api-report/davinci-client.api.md‎

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ export interface CollectorErrors {
177177
target: string;
178178
}
179179

180-
// @public (undocumented)
181-
export type CollectorInputTypes = string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
182-
183180
// @public
184181
export interface CollectorRichContent {
185182
// (undocumented)
@@ -194,8 +191,18 @@ export type Collectors = FlowCollector | PasswordCollector | ValidatedPasswordCo
194191
// @public
195192
export type CollectorValueType<T> = T extends {
196193
type: 'PasswordCollector';
197-
} ? string : T extends {
194+
} | {
198195
type: 'ValidatedPasswordCollector';
196+
} | {
197+
type: 'SingleSelectCollector';
198+
} | {
199+
type: 'DeviceRegistrationCollector';
200+
} | {
201+
type: 'DeviceAuthenticationCollector';
202+
} | {
203+
type: 'ProtectCollector';
204+
} | {
205+
type: 'PollingCollector';
199206
} ? string : T extends {
200207
type: 'TextCollector';
201208
category: 'SingleValueCollector';
@@ -205,14 +212,8 @@ export type CollectorValueType<T> = T extends {
205212
} ? string : T extends {
206213
type: 'ValidatedBooleanCollector';
207214
} ? boolean : T extends {
208-
type: 'SingleSelectCollector';
209-
} ? string : T extends {
210215
type: 'MultiSelectCollector';
211216
} ? string[] : T extends {
212-
type: 'DeviceRegistrationCollector';
213-
} ? string : T extends {
214-
type: 'DeviceAuthenticationCollector';
215-
} ? string : T extends {
216217
type: 'PhoneNumberCollector';
217218
} ? PhoneNumberInputValue : T extends {
218219
type: 'PhoneNumberExtensionCollector';
@@ -224,9 +225,18 @@ export type CollectorValueType<T> = T extends {
224225
category: 'SingleValueCollector';
225226
} ? string : T extends {
226227
category: 'ValidatedSingleValueCollector';
228+
} ? string : T extends {
229+
category: 'SingleValueAutoCollector';
227230
} ? string : T extends {
228231
category: 'MultiValueCollector';
229-
} ? string[] : CollectorInputTypes;
232+
} ? string[] : T extends {
233+
category: 'ActionCollector';
234+
} ? never : T extends {
235+
category: 'NoValueCollector';
236+
} ? never : CollectorValueTypes;
237+
238+
// @public (undocumented)
239+
export type CollectorValueTypes = string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
230240

231241
// @public (undocumented)
232242
export type ComplexValueFields = DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField | PhoneNumberExtensionField | FidoRegistrationField | FidoAuthenticationField | PollingField;
@@ -316,15 +326,15 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
316326
getErrorCollectors: () => CollectorErrors[];
317327
getNode: () => ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode;
318328
getServer: () => {
319-
status: "start";
320-
} | {
321329
_links?: Links;
322330
id?: string;
323331
interactionId?: string;
324332
interactionToken?: string;
325333
href?: string;
326334
eventName?: string;
327335
status: "continue";
336+
} | {
337+
status: "start";
328338
} | {
329339
_links?: Links;
330340
eventName?: string;
@@ -382,14 +392,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
382392
} & Omit<{
383393
requestId: string;
384394
data?: unknown;
385-
error?: SerializedError | FetchBaseQueryError | undefined;
395+
error?: FetchBaseQueryError | SerializedError | undefined;
386396
endpointName: string;
387397
startedTimeStamp: number;
388398
fulfilledTimeStamp?: number;
389399
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
390400
requestId: string;
391401
data?: unknown;
392-
error?: SerializedError | FetchBaseQueryError | undefined;
402+
error?: FetchBaseQueryError | SerializedError | undefined;
393403
endpointName: string;
394404
startedTimeStamp: number;
395405
fulfilledTimeStamp?: number;
@@ -406,7 +416,7 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
406416
} & {
407417
requestId: string;
408418
data?: unknown;
409-
error?: SerializedError | FetchBaseQueryError | undefined;
419+
error?: FetchBaseQueryError | SerializedError | undefined;
410420
endpointName: string;
411421
startedTimeStamp: number;
412422
fulfilledTimeStamp?: number;
@@ -423,14 +433,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
423433
} & Omit<{
424434
requestId: string;
425435
data?: unknown;
426-
error?: SerializedError | FetchBaseQueryError | undefined;
436+
error?: FetchBaseQueryError | SerializedError | undefined;
427437
endpointName: string;
428438
startedTimeStamp: number;
429439
fulfilledTimeStamp?: number;
430440
}, "error"> & Required<Pick<{
431441
requestId: string;
432442
data?: unknown;
433-
error?: SerializedError | FetchBaseQueryError | undefined;
443+
error?: FetchBaseQueryError | SerializedError | undefined;
434444
endpointName: string;
435445
startedTimeStamp: number;
436446
fulfilledTimeStamp?: number;
@@ -477,14 +487,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
477487
} & Omit<{
478488
requestId: string;
479489
data?: unknown;
480-
error?: SerializedError | FetchBaseQueryError | undefined;
490+
error?: FetchBaseQueryError | SerializedError | undefined;
481491
endpointName: string;
482492
startedTimeStamp: number;
483493
fulfilledTimeStamp?: number;
484494
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
485495
requestId: string;
486496
data?: unknown;
487-
error?: SerializedError | FetchBaseQueryError | undefined;
497+
error?: FetchBaseQueryError | SerializedError | undefined;
488498
endpointName: string;
489499
startedTimeStamp: number;
490500
fulfilledTimeStamp?: number;
@@ -501,7 +511,7 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
501511
} & {
502512
requestId: string;
503513
data?: unknown;
504-
error?: SerializedError | FetchBaseQueryError | undefined;
514+
error?: FetchBaseQueryError | SerializedError | undefined;
505515
endpointName: string;
506516
startedTimeStamp: number;
507517
fulfilledTimeStamp?: number;
@@ -518,14 +528,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
518528
} & Omit<{
519529
requestId: string;
520530
data?: unknown;
521-
error?: SerializedError | FetchBaseQueryError | undefined;
531+
error?: FetchBaseQueryError | SerializedError | undefined;
522532
endpointName: string;
523533
startedTimeStamp: number;
524534
fulfilledTimeStamp?: number;
525535
}, "error"> & Required<Pick<{
526536
requestId: string;
527537
data?: unknown;
528-
error?: SerializedError | FetchBaseQueryError | undefined;
538+
error?: FetchBaseQueryError | SerializedError | undefined;
529539
endpointName: string;
530540
startedTimeStamp: number;
531541
fulfilledTimeStamp?: number;
@@ -1187,8 +1197,8 @@ value: Record<string, unknown>;
11871197
}, string>;
11881198

11891199
// @public
1190-
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)[]> & {
1191-
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)[];
1200+
export const nodeCollectorReducer: Reducer<Collectors[]> & {
1201+
getInitialState: () => Collectors[];
11921202
};
11931203

11941204
// @public (undocumented)
@@ -1918,7 +1928,7 @@ export type UnknownField = Record<string, unknown>;
19181928
// @public (undocumented)
19191929
export const updateCollectorValues: ActionCreatorWithPayload< {
19201930
id: string;
1921-
value: string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
1931+
value: CollectorValueTypes;
19221932
index?: number;
19231933
}, string>;
19241934

‎packages/davinci-client/api-report/davinci-client.types.api.md‎

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,6 @@ export interface CollectorErrors {
177177
target: string;
178178
}
179179

180-
// @public (undocumented)
181-
export type CollectorInputTypes = string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
182-
183180
// @public
184181
export interface CollectorRichContent {
185182
// (undocumented)
@@ -194,8 +191,18 @@ export type Collectors = FlowCollector | PasswordCollector | ValidatedPasswordCo
194191
// @public
195192
export type CollectorValueType<T> = T extends {
196193
type: 'PasswordCollector';
197-
} ? string : T extends {
194+
} | {
198195
type: 'ValidatedPasswordCollector';
196+
} | {
197+
type: 'SingleSelectCollector';
198+
} | {
199+
type: 'DeviceRegistrationCollector';
200+
} | {
201+
type: 'DeviceAuthenticationCollector';
202+
} | {
203+
type: 'ProtectCollector';
204+
} | {
205+
type: 'PollingCollector';
199206
} ? string : T extends {
200207
type: 'TextCollector';
201208
category: 'SingleValueCollector';
@@ -205,14 +212,8 @@ export type CollectorValueType<T> = T extends {
205212
} ? string : T extends {
206213
type: 'ValidatedBooleanCollector';
207214
} ? boolean : T extends {
208-
type: 'SingleSelectCollector';
209-
} ? string : T extends {
210215
type: 'MultiSelectCollector';
211216
} ? string[] : T extends {
212-
type: 'DeviceRegistrationCollector';
213-
} ? string : T extends {
214-
type: 'DeviceAuthenticationCollector';
215-
} ? string : T extends {
216217
type: 'PhoneNumberCollector';
217218
} ? PhoneNumberInputValue : T extends {
218219
type: 'PhoneNumberExtensionCollector';
@@ -224,9 +225,18 @@ export type CollectorValueType<T> = T extends {
224225
category: 'SingleValueCollector';
225226
} ? string : T extends {
226227
category: 'ValidatedSingleValueCollector';
228+
} ? string : T extends {
229+
category: 'SingleValueAutoCollector';
227230
} ? string : T extends {
228231
category: 'MultiValueCollector';
229-
} ? string[] : CollectorInputTypes;
232+
} ? string[] : T extends {
233+
category: 'ActionCollector';
234+
} ? never : T extends {
235+
category: 'NoValueCollector';
236+
} ? never : CollectorValueTypes;
237+
238+
// @public (undocumented)
239+
export type CollectorValueTypes = string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
230240

231241
// @public (undocumented)
232242
export type ComplexValueFields = DeviceAuthenticationField | DeviceRegistrationField | PhoneNumberField | PhoneNumberExtensionField | FidoRegistrationField | FidoAuthenticationField | PollingField;
@@ -316,15 +326,15 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
316326
getErrorCollectors: () => CollectorErrors[];
317327
getNode: () => ContinueNode | ErrorNode | StartNode | SuccessNode | FailureNode;
318328
getServer: () => {
319-
status: "start";
320-
} | {
321329
_links?: Links;
322330
id?: string;
323331
interactionId?: string;
324332
interactionToken?: string;
325333
href?: string;
326334
eventName?: string;
327335
status: "continue";
336+
} | {
337+
status: "start";
328338
} | {
329339
_links?: Links;
330340
eventName?: string;
@@ -382,14 +392,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
382392
} & Omit<{
383393
requestId: string;
384394
data?: unknown;
385-
error?: SerializedError | FetchBaseQueryError | undefined;
395+
error?: FetchBaseQueryError | SerializedError | undefined;
386396
endpointName: string;
387397
startedTimeStamp: number;
388398
fulfilledTimeStamp?: number;
389399
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
390400
requestId: string;
391401
data?: unknown;
392-
error?: SerializedError | FetchBaseQueryError | undefined;
402+
error?: FetchBaseQueryError | SerializedError | undefined;
393403
endpointName: string;
394404
startedTimeStamp: number;
395405
fulfilledTimeStamp?: number;
@@ -406,7 +416,7 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
406416
} & {
407417
requestId: string;
408418
data?: unknown;
409-
error?: SerializedError | FetchBaseQueryError | undefined;
419+
error?: FetchBaseQueryError | SerializedError | undefined;
410420
endpointName: string;
411421
startedTimeStamp: number;
412422
fulfilledTimeStamp?: number;
@@ -423,14 +433,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
423433
} & Omit<{
424434
requestId: string;
425435
data?: unknown;
426-
error?: SerializedError | FetchBaseQueryError | undefined;
436+
error?: FetchBaseQueryError | SerializedError | undefined;
427437
endpointName: string;
428438
startedTimeStamp: number;
429439
fulfilledTimeStamp?: number;
430440
}, "error"> & Required<Pick<{
431441
requestId: string;
432442
data?: unknown;
433-
error?: SerializedError | FetchBaseQueryError | undefined;
443+
error?: FetchBaseQueryError | SerializedError | undefined;
434444
endpointName: string;
435445
startedTimeStamp: number;
436446
fulfilledTimeStamp?: number;
@@ -477,14 +487,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
477487
} & Omit<{
478488
requestId: string;
479489
data?: unknown;
480-
error?: SerializedError | FetchBaseQueryError | undefined;
490+
error?: FetchBaseQueryError | SerializedError | undefined;
481491
endpointName: string;
482492
startedTimeStamp: number;
483493
fulfilledTimeStamp?: number;
484494
}, "data" | "fulfilledTimeStamp"> & Required<Pick<{
485495
requestId: string;
486496
data?: unknown;
487-
error?: SerializedError | FetchBaseQueryError | undefined;
497+
error?: FetchBaseQueryError | SerializedError | undefined;
488498
endpointName: string;
489499
startedTimeStamp: number;
490500
fulfilledTimeStamp?: number;
@@ -501,7 +511,7 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
501511
} & {
502512
requestId: string;
503513
data?: unknown;
504-
error?: SerializedError | FetchBaseQueryError | undefined;
514+
error?: FetchBaseQueryError | SerializedError | undefined;
505515
endpointName: string;
506516
startedTimeStamp: number;
507517
fulfilledTimeStamp?: number;
@@ -518,14 +528,14 @@ export function davinci<ActionType extends ActionTypes = ActionTypes>(input: {
518528
} & Omit<{
519529
requestId: string;
520530
data?: unknown;
521-
error?: SerializedError | FetchBaseQueryError | undefined;
531+
error?: FetchBaseQueryError | SerializedError | undefined;
522532
endpointName: string;
523533
startedTimeStamp: number;
524534
fulfilledTimeStamp?: number;
525535
}, "error"> & Required<Pick<{
526536
requestId: string;
527537
data?: unknown;
528-
error?: SerializedError | FetchBaseQueryError | undefined;
538+
error?: FetchBaseQueryError | SerializedError | undefined;
529539
endpointName: string;
530540
startedTimeStamp: number;
531541
fulfilledTimeStamp?: number;
@@ -1184,8 +1194,8 @@ value: Record<string, unknown>;
11841194
}, string>;
11851195

11861196
// @public
1187-
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)[]> & {
1188-
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)[];
1197+
export const nodeCollectorReducer: Reducer<Collectors[]> & {
1198+
getInitialState: () => Collectors[];
11891199
};
11901200

11911201
// @public (undocumented)
@@ -1915,7 +1925,7 @@ export type UnknownField = Record<string, unknown>;
19151925
// @public (undocumented)
19161926
export const updateCollectorValues: ActionCreatorWithPayload< {
19171927
id: string;
1918-
value: string | string[] | boolean | PhoneNumberInputValue | PhoneNumberExtensionInputValue | FidoRegistrationInputValue | FidoAuthenticationInputValue;
1928+
value: CollectorValueTypes;
19191929
index?: number;
19201930
}, string>;
19211931

0 commit comments

Comments
 (0)