@wise/dynamic-flow-client 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/build/main.js +482 -593
  2. package/build/main.mjs +482 -593
  3. package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +5 -7
  4. package/build/types/revamp/domain/components/DateInputComponent.d.ts +5 -7
  5. package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +5 -7
  6. package/build/types/revamp/domain/components/MultiSelectInputComponent.d.ts +2 -2
  7. package/build/types/revamp/domain/components/NumberInputComponent.d.ts +5 -7
  8. package/build/types/revamp/domain/components/PersistAsyncComponent.d.ts +18 -0
  9. package/build/types/revamp/domain/components/SelectInputComponent.d.ts +3 -3
  10. package/build/types/revamp/domain/components/TextInputComponent.d.ts +5 -7
  11. package/build/types/revamp/domain/components/UploadInputComponent.d.ts +6 -8
  12. package/build/types/revamp/domain/features/persistAsync/getComponentMultiPersistAsync.d.ts +9 -0
  13. package/build/types/revamp/domain/features/schema-on-change/getDebouncedSchemaOnChange.d.ts +10 -0
  14. package/build/types/revamp/domain/features/schema-on-change/getSchemaOnChange.d.ts +7 -0
  15. package/build/types/revamp/domain/mappers/schema/arraySchemaToComponent/arraySchemaToMultiUploadComponent.d.ts +1 -1
  16. package/build/types/revamp/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts +6 -0
  17. package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +1 -0
  18. package/build/types/revamp/domain/mappers/schema/types.d.ts +1 -0
  19. package/build/types/revamp/domain/mappers/schema/utils/getPerformPersistAsyncFn.d.ts +4 -0
  20. package/build/types/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.d.ts +1 -0
  21. package/build/types/revamp/domain/mappers/utils/behavior-utils.d.ts +1 -0
  22. package/build/types/revamp/domain/types.d.ts +9 -3
  23. package/build/types/revamp/flow/executeRefresh.d.ts +2 -2
  24. package/build/types/revamp/renderers/mappers/persistAsyncComponentToProps.d.ts +3 -0
  25. package/build/types/revamp/utils/type-utils.d.ts +1 -2
  26. package/package.json +16 -16
  27. package/build/types/revamp/domain/features/persistAsync/getComponentPersistAsync.d.ts +0 -21
  28. package/build/types/revamp/domain/features/refresh/getPerformRefresh.d.ts +0 -12
  29. package/build/types/revamp/domain/mappers/schema/utils/getPersistAsyncInitialState.d.ts +0 -5
@@ -1,17 +1,15 @@
1
- import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
2
- import type { PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
3
2
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
4
- import type { BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary, UpdateComponent, ValidationAsyncState } from '../types';
3
+ import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, UpdateComponent, ValidationAsyncState } from '../types';
5
4
  export type BooleanInputComponent = BaseInputComponent<boolean> & {
6
5
  type: 'boolean';
7
- persistedState: PersistedState;
8
6
  validationAsyncState: ValidationAsyncState;
9
7
  onChange: (value: boolean) => void;
10
8
  };
11
- export declare const createBooleanInputComponent: (booleanInputProps: Pick<BooleanInputComponent, "uid" | "id" | "analyticsId" | "alert" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "icon" | "image" | "persistedState" | "required" | "title" | "value" | "validationAsyncState"> & {
12
- performPersistAsync: PerformPersistAsync | undefined;
13
- performRefresh: PerformRefresh | undefined;
9
+ export declare const createBooleanInputComponent: (booleanInputProps: Pick<BooleanInputComponent, "uid" | "id" | "analyticsId" | "alert" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "icon" | "image" | "required" | "title" | "value" | "validationAsyncState"> & {
10
+ schemaOnChange: SchemaOnChange | undefined;
14
11
  performValidationAsync: PerformValidationAsync | undefined;
15
12
  summariser: (value: boolean) => RepeatableSummary;
16
13
  onValueChange: OnValueChange;
14
+ onPersistAsync: OnPersistAsync | undefined;
17
15
  }, updateComponent: UpdateComponent) => BooleanInputComponent;
@@ -1,22 +1,20 @@
1
- import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
2
- import type { PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
3
2
  import type { IsInvalidCheck } from '../features/validation/value-checks';
4
3
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
5
- import type { BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary, Suggestions, UpdateComponent, ValidationAsyncState } from '../types';
4
+ import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, Suggestions, UpdateComponent, ValidationAsyncState } from '../types';
6
5
  export type DateInputComponent = BaseInputComponent<string | null> & {
7
6
  type: 'date';
8
7
  minimumDate?: string;
9
8
  maximumDate?: string;
10
- persistedState: PersistedState;
11
9
  suggestions?: Suggestions;
12
10
  validationAsyncState: ValidationAsyncState;
13
11
  onChange: (value: string | null) => void;
14
12
  };
15
- export declare const createDateInputComponent: (textInputProps: Pick<DateInputComponent, "uid" | "id" | "analyticsId" | "alert" | "autoComplete" | "control" | "errors" | "description" | "disabled" | "help" | "hidden" | "icon" | "image" | "minimumDate" | "maximumDate" | "persistedState" | "placeholder" | "required" | "suggestions" | "title" | "value" | "validationAsyncState"> & {
13
+ export declare const createDateInputComponent: (textInputProps: Pick<DateInputComponent, "uid" | "id" | "analyticsId" | "alert" | "autoComplete" | "control" | "errors" | "description" | "disabled" | "help" | "hidden" | "icon" | "image" | "minimumDate" | "maximumDate" | "placeholder" | "required" | "suggestions" | "title" | "value" | "validationAsyncState"> & {
16
14
  checks: IsInvalidCheck<string | null>[];
17
- performPersistAsync: PerformPersistAsync | undefined;
18
- performRefresh: PerformRefresh | undefined;
15
+ schemaOnChange: SchemaOnChange | undefined;
19
16
  performValidationAsync: PerformValidationAsync | undefined;
20
17
  onValueChange: OnValueChange;
18
+ onPersistAsync: OnPersistAsync | undefined;
21
19
  summariser: (value: string | null) => RepeatableSummary;
22
20
  }, updateComponent: UpdateComponent) => DateInputComponent;
@@ -1,21 +1,19 @@
1
- import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
2
- import { type PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
3
2
  import type { IsInvalidCheck } from '../features/validation/value-checks';
4
3
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
5
- import type { BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary, UpdateComponent, ValidationAsyncState } from '../types';
4
+ import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, UpdateComponent, ValidationAsyncState } from '../types';
6
5
  export type IntegerInputComponent = BaseInputComponent<number | null> & {
7
6
  type: 'integer';
8
7
  maximum?: number;
9
8
  minimum?: number;
10
- persistedState: PersistedState;
11
9
  validationAsyncState: ValidationAsyncState;
12
10
  onChange: (value: number | null) => void;
13
11
  };
14
- export declare const createIntegerInputComponent: (integerInputProps: Pick<IntegerInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "alert" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "icon" | "image" | "maximum" | "minimum" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationAsyncState"> & {
12
+ export declare const createIntegerInputComponent: (integerInputProps: Pick<IntegerInputComponent, "uid" | "id" | "analyticsId" | "autoComplete" | "alert" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "icon" | "image" | "maximum" | "minimum" | "placeholder" | "required" | "title" | "value" | "validationAsyncState"> & {
15
13
  checks: IsInvalidCheck<number | null>[];
16
- performPersistAsync: PerformPersistAsync | undefined;
17
- performRefresh: PerformRefresh | undefined;
14
+ schemaOnChange: SchemaOnChange | undefined;
18
15
  performValidationAsync: PerformValidationAsync | undefined;
19
16
  onValueChange: OnValueChange;
17
+ onPersistAsync: OnPersistAsync | undefined;
20
18
  summariser: (value: number | null) => RepeatableSummary;
21
19
  }, updateComponent: UpdateComponent) => IntegerInputComponent;
@@ -1,4 +1,4 @@
1
- import type { PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
2
2
  import type { IsInvalidCheck } from '../features/validation/value-checks';
3
3
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
4
4
  import type { BaseInputComponent, LocalValue, LocalValueArray, OnValueChange, SchemaComponent, UpdateComponent, ValidationAsyncState } from '../types';
@@ -22,6 +22,6 @@ export declare const createMultiSelectComponent: (multiSelectProps: Pick<MultiSe
22
22
  component: SchemaComponent;
23
23
  })[];
24
24
  performValidationAsync: PerformValidationAsync | undefined;
25
- performRefresh: PerformRefresh | undefined;
25
+ schemaOnChange: SchemaOnChange | undefined;
26
26
  onValueChange: OnValueChange;
27
27
  }, updateComponent: UpdateComponent) => MultiSelectComponent;
@@ -1,21 +1,19 @@
1
- import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
2
- import { type PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
3
2
  import type { IsInvalidCheck } from '../features/validation/value-checks';
4
3
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
5
- import type { BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary, UpdateComponent, ValidationAsyncState } from '../types';
4
+ import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, UpdateComponent, ValidationAsyncState } from '../types';
6
5
  export type NumberInputComponent = BaseInputComponent<number | null> & {
7
6
  type: 'number';
8
7
  maximum?: number;
9
8
  minimum?: number;
10
- persistedState: PersistedState;
11
9
  validationAsyncState: ValidationAsyncState;
12
10
  onChange: (value: number | null) => void;
13
11
  };
14
- export declare const createNumberInputComponent: (numberInputProps: Pick<NumberInputComponent, "uid" | "id" | "analyticsId" | "alert" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "icon" | "image" | "maximum" | "minimum" | "persistedState" | "placeholder" | "required" | "title" | "value" | "validationAsyncState"> & {
12
+ export declare const createNumberInputComponent: (numberInputProps: Pick<NumberInputComponent, "uid" | "id" | "analyticsId" | "alert" | "autoComplete" | "control" | "description" | "disabled" | "errors" | "help" | "hidden" | "icon" | "image" | "maximum" | "minimum" | "placeholder" | "required" | "title" | "value" | "validationAsyncState"> & {
15
13
  checks: IsInvalidCheck<number | null>[];
16
- performPersistAsync: PerformPersistAsync | undefined;
17
- performRefresh: PerformRefresh | undefined;
14
+ schemaOnChange: SchemaOnChange | undefined;
18
15
  performValidationAsync: PerformValidationAsync | undefined;
19
16
  onValueChange: OnValueChange;
17
+ onPersistAsync: OnPersistAsync | undefined;
20
18
  summariser: (value: number | null) => RepeatableSummary;
21
19
  }, updateComponent: UpdateComponent) => NumberInputComponent;
@@ -0,0 +1,18 @@
1
+ import { JsonElement } from '@wise/dynamic-flow-types/build/next';
2
+ import { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
3
+ import type { BaseSchemaComponent, LocalValue, SchemaComponent, UpdateComponent } from '../types';
4
+ import { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
5
+ export type PersistAsyncComponent = BaseSchemaComponent<LocalValue> & {
6
+ type: 'persist-async';
7
+ component: SchemaComponent;
8
+ abortController: AbortController;
9
+ submission: Promise<JsonElement>;
10
+ lastSubmitted: LocalValue;
11
+ lastResponse: JsonElement;
12
+ errors: string[];
13
+ persist: () => Promise<JsonElement>;
14
+ };
15
+ export declare const createPersistAsyncComponent: (props: Pick<PersistAsyncComponent, "uid" | "schemaId" | "component" | "hidden"> & {
16
+ model?: JsonElement | null;
17
+ localValue?: LocalValue | null;
18
+ }, performPersistAsync: PerformPersistAsync, schemaOnChange: SchemaOnChange | undefined, updateComponent: UpdateComponent) => PersistAsyncComponent;
@@ -1,8 +1,8 @@
1
1
  import type { Icon, Model } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { AnalyticsEventDispatcher } from '../features/events';
3
- import type { PerformRefresh } from '../features/refresh/getPerformRefresh';
3
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
4
4
  import type { IsInvalidCheck } from '../features/validation/value-checks';
5
- import type { BaseInputComponent, Image, SchemaComponent, LocalValue, OnValueChange, RepeatableSummary, UpdateComponent } from '../types';
5
+ import type { BaseInputComponent, Image, LocalValue, OnValueChange, RepeatableSummary, SchemaComponent, UpdateComponent } from '../types';
6
6
  export type SelectInputComponent = BaseInputComponent<LocalValue | null> & {
7
7
  type: 'select';
8
8
  selectedIndex: number | null;
@@ -27,7 +27,7 @@ export declare const createSelectInputComponent: (selectProps: Pick<SelectInputC
27
27
  component: SchemaComponent;
28
28
  })[];
29
29
  checks: IsInvalidCheck<LocalValue>[];
30
- performRefresh?: PerformRefresh | undefined;
30
+ schemaOnChange: SchemaOnChange | undefined;
31
31
  summariser: (value: LocalValue | null) => RepeatableSummary;
32
32
  onValueChange: OnValueChange;
33
33
  trackEvent: AnalyticsEventDispatcher;
@@ -1,24 +1,22 @@
1
- import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
2
- import { type PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
3
2
  import type { IsInvalidCheck } from '../features/validation/value-checks';
4
3
  import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
5
- import type { Autocapitalization, BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary, Suggestions, UpdateComponent, ValidationAsyncState } from '../types';
4
+ import type { Autocapitalization, BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, Suggestions, UpdateComponent, ValidationAsyncState } from '../types';
6
5
  export type TextInputComponent = BaseInputComponent<string | null> & {
7
6
  type: 'text';
8
7
  autocapitalization?: Autocapitalization;
9
8
  displayFormat?: string;
10
9
  maxLength?: number;
11
10
  minLength?: number;
12
- persistedState: PersistedState;
13
11
  suggestions?: Suggestions;
14
12
  validationAsyncState: ValidationAsyncState;
15
13
  onChange: (value: string | null) => void;
16
14
  };
17
- export declare const createTextInputComponent: (textInputProps: Pick<TextInputComponent, "uid" | "id" | "analyticsId" | "alert" | "autocapitalization" | "autoComplete" | "control" | "errors" | "description" | "disabled" | "displayFormat" | "help" | "hidden" | "icon" | "image" | "maxLength" | "minLength" | "persistedState" | "placeholder" | "required" | "suggestions" | "title" | "value" | "validationAsyncState"> & {
15
+ export declare const createTextInputComponent: (textInputProps: Pick<TextInputComponent, "uid" | "id" | "analyticsId" | "alert" | "autocapitalization" | "autoComplete" | "control" | "errors" | "description" | "disabled" | "displayFormat" | "help" | "hidden" | "icon" | "image" | "maxLength" | "minLength" | "placeholder" | "required" | "suggestions" | "title" | "value" | "validationAsyncState"> & {
18
16
  checks: IsInvalidCheck<string | null>[];
19
- performPersistAsync: PerformPersistAsync | undefined;
20
17
  performValidationAsync: PerformValidationAsync | undefined;
21
- performRefresh: PerformRefresh | undefined;
18
+ schemaOnChange: SchemaOnChange | undefined;
22
19
  onValueChange: OnValueChange;
20
+ onPersistAsync: OnPersistAsync | undefined;
23
21
  summariser: (value: string | null) => RepeatableSummary;
24
22
  }, updateComponent: UpdateComponent) => TextInputComponent;
@@ -1,23 +1,21 @@
1
- import { JsonElement } from '@wise/dynamic-flow-types/build/next';
2
- import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
3
- import type { PerformRefresh } from '../features/refresh/getPerformRefresh';
1
+ import type { JsonElement } from '@wise/dynamic-flow-types/build/next';
2
+ import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
4
3
  import type { IsInvalidCheck } from '../features/validation/value-checks';
5
- import type { BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary, UpdateComponent, UploadSource } from '../types';
4
+ import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, UpdateComponent, UploadSource } from '../types';
6
5
  export type UploadInputComponent = BaseInputComponent<File | null> & {
7
6
  type: 'upload';
8
7
  format: 'blob' | 'base64';
9
8
  cameraConfig?: JsonElement;
10
9
  maxSize?: number;
11
10
  accepts?: string[];
12
- persistedState: PersistedState;
13
11
  source?: UploadSource;
14
12
  validationAsyncState?: undefined;
15
13
  onUpload: (value: File | null) => Promise<void>;
16
14
  };
17
- export declare const createUploadInputComponent: (uploadInputProps: Pick<UploadInputComponent, "uid" | "id" | "accepts" | "analyticsId" | "alert" | "autoComplete" | "cameraConfig" | "control" | "errors" | "description" | "disabled" | "format" | "help" | "hidden" | "icon" | "image" | "maxSize" | "persistedState" | "placeholder" | "required" | "source" | "title" | "value"> & {
15
+ export declare const createUploadInputComponent: (uploadInputProps: Pick<UploadInputComponent, "uid" | "id" | "accepts" | "analyticsId" | "alert" | "autoComplete" | "cameraConfig" | "control" | "errors" | "description" | "disabled" | "format" | "help" | "hidden" | "icon" | "image" | "maxSize" | "placeholder" | "required" | "source" | "title" | "value"> & {
18
16
  checks: IsInvalidCheck<File | null>[];
19
- performPersistAsync: PerformPersistAsync | undefined;
20
- performRefresh?: PerformRefresh | undefined;
17
+ schemaOnChange: SchemaOnChange | undefined;
21
18
  onValueChange: OnValueChange;
19
+ onPersistAsync: OnPersistAsync | undefined;
22
20
  summariser: (value: string | null) => RepeatableSummary;
23
21
  }, updateComponent: UpdateComponent) => UploadInputComponent;
@@ -0,0 +1,9 @@
1
+ import type { MultiUploadInputComponent } from '../../components/MultiUploadInputComponent';
2
+ import type { LocalValue } from '../../types';
3
+ import type { PerformPersistAsync } from './getPerformPersistAsync';
4
+ type UpdateMultiUploadInputComponent = (component: MultiUploadInputComponent, updateFn: (component: MultiUploadInputComponent) => void) => void;
5
+ /**
6
+ * Creates an onPersistAsync handler for a component.
7
+ */
8
+ export declare const getComponentMultiPersistAsync: (update: UpdateMultiUploadInputComponent, performPersistAsync: PerformPersistAsync) => (component: MultiUploadInputComponent, index: number, value: LocalValue) => Promise<string | number | boolean | import("@wise/dynamic-flow-types/build/next").JsonObject | import("@wise/dynamic-flow-types/build/next").JsonArray | null>;
9
+ export {};
@@ -0,0 +1,10 @@
1
+ import { LocalValue } from '../../types';
2
+ import { SchemaOnChange } from './getSchemaOnChange';
3
+ type DebouncedSchemaOnChange<V extends LocalValue> = {
4
+ (prevValue: V, updatedValue: V): void;
5
+ cancel: () => void;
6
+ flush: () => void;
7
+ isPending: () => boolean;
8
+ };
9
+ export declare const getDebouncedSchemaOnChange: <V extends LocalValue>(onChange: SchemaOnChange | undefined, getValidationErrors: (value: V) => string[]) => DebouncedSchemaOnChange<V> | undefined;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ import { Schema } from '@wise/dynamic-flow-types/build/next';
2
+ import { Behavior, OnBehavior } from '../../types';
3
+ export type SchemaOnChange = {
4
+ (): void;
5
+ behaviorType: Behavior['type'];
6
+ };
7
+ export declare const getSchemaOnChange: (schema: Schema, onBehavior: OnBehavior) => SchemaOnChange | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { ArraySchemaList, Model } from '@wise/dynamic-flow-types/build/next';
2
- import type { MapperProps, SchemaMapperProps } from '../types';
3
2
  import { type PersistAsyncWithUploadSchema, type StringSchemaWithUpload } from '../../../../utils/type-utils';
3
+ import type { MapperProps, SchemaMapperProps } from '../types';
4
4
  export declare const arraySchemaToMultiUploadComponent: (schemaMapperProps: SchemaMapperProps & {
5
5
  schema: ArraySchemaList & {
6
6
  items: PersistAsyncWithUploadSchema | StringSchemaWithUpload;
@@ -0,0 +1,6 @@
1
+ import { SchemaWithPersistAsync } from '../../../utils/type-utils';
2
+ import { SchemaComponent } from '../../types';
3
+ import { MapperProps, SchemaMapperProps } from './types';
4
+ export declare const persistAsyncSchemaToComponent: (schemaMapperProps: SchemaMapperProps & {
5
+ schema: SchemaWithPersistAsync;
6
+ }, mapperProps: MapperProps) => SchemaComponent;
@@ -27,6 +27,7 @@ export declare const getMockSchemaMapperProps: <S extends Schema>(schemaMapperPr
27
27
  required: boolean;
28
28
  validationErrors: import("@wise/dynamic-flow-types/build/next").ValidationError;
29
29
  persistAsyncConfig?: import("../../types").PersistAsyncConfig | undefined;
30
+ onPersistAsync?: (() => void) | undefined;
30
31
  };
31
32
  export declare const getMockRendererMapperProps: () => RendererMapperProps;
32
33
  export declare const mockUpdateFunction: <C extends DomainComponent>(draftComponent: C) => jest.Mock<any, any, any>;
@@ -23,4 +23,5 @@ export type SchemaMapperProps = {
23
23
  required?: boolean;
24
24
  validationErrors?: ValidationError;
25
25
  persistAsyncConfig?: PersistAsyncConfig;
26
+ onPersistAsync?: () => void;
26
27
  };
@@ -0,0 +1,4 @@
1
+ import type { Schema } from '@wise/dynamic-flow-types/build/next';
2
+ import type { MapperProps } from '../types';
3
+ import { PersistAsyncConfig } from '../../types';
4
+ export declare const getPerformPersistAsyncFn: (schema: Schema, persistAsyncConfig: PersistAsyncConfig, mapperProps: MapperProps) => import("../../../features/persistAsync/getPerformPersistAsync").PerformPersistAsync;
@@ -17,5 +17,6 @@ export declare const mapCommonSchemaProps: (schemaMapperProps: SchemaMapperProps
17
17
  keywords: string[] | undefined;
18
18
  required: boolean;
19
19
  title: string | undefined;
20
+ onPersistAsync: (() => void) | undefined;
20
21
  summariser: (value: import("../../../types").LocalValue | null) => import("../../../types").RepeatableSummary;
21
22
  };
@@ -5,4 +5,5 @@ export declare const getDomainLayerBehavior: ({ action, behavior, }: {
5
5
  behavior?: SpecBehavior;
6
6
  }, stepActions: Action[]) => Behavior;
7
7
  export declare const skipValidation: (behavior: Behavior) => Behavior;
8
+ export declare const normaliseBehavior: (behavior: SpecBehavior, stepActions: Action[]) => Behavior;
8
9
  export declare const inlineAction: (action: Action, stepActions?: Action[]) => Action;
@@ -25,6 +25,7 @@ import type { MultiUploadInputComponent } from './components/MultiUploadInputCom
25
25
  import type { NumberInputComponent } from './components/NumberInputComponent';
26
26
  import type { ObjectComponent } from './components/ObjectComponent';
27
27
  import type { ParagraphComponent } from './components/ParagraphComponent';
28
+ import { PersistAsyncComponent } from './components/PersistAsyncComponent';
28
29
  import type { RepeatableComponent } from './components/RepeatableComponent';
29
30
  import type { ReviewComponent } from './components/ReviewComponent';
30
31
  import type { RootDomainComponent } from './components/RootDomainComponent';
@@ -38,7 +39,7 @@ import type { TextInputComponent } from './components/TextInputComponent';
38
39
  import type { TupleComponent } from './components/TupleComponent';
39
40
  import type { UploadInputComponent } from './components/UploadInputComponent';
40
41
  export type DomainComponent = SchemaComponent | LayoutComponent | RootDomainComponent | StepDomainComponent;
41
- export type SchemaComponent = AllOfComponent | BooleanInputComponent | ConstComponent | DateInputComponent | IntegerInputComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | RepeatableComponent | SelectInputComponent | TextInputComponent | TupleComponent | UploadInputComponent;
42
+ export type SchemaComponent = PersistAsyncComponent | AllOfComponent | BooleanInputComponent | ConstComponent | DateInputComponent | IntegerInputComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | RepeatableComponent | SelectInputComponent | TextInputComponent | TupleComponent | UploadInputComponent;
42
43
  export type LayoutComponent = AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | ContainerComponent | DecisionComponent | DividerComponent | ExternalConfirmationComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalComponent | ModalContentComponent | ParagraphComponent | ReviewComponent | SearchComponent | SectionComponent | StatusListComponent;
43
44
  export type LocalValue = LocalValuePrimitive | LocalValueObject | LocalValueArray;
44
45
  export type LocalValuePrimitive = string | number | boolean | File | null;
@@ -58,12 +59,13 @@ export type CallToAction = {
58
59
  href: string;
59
60
  onClick: () => void;
60
61
  };
61
- export type Behavior = ActionBehavior | RefreshBehavior | LinkBehavior | ModalBehavior | DismissBehavior | {
62
+ export type Behavior = (ActionBehavior | RefreshBehavior | LinkBehavior | ModalBehavior | DismissBehavior | {
62
63
  type: 'none';
64
+ }) & {
65
+ analytics?: Record<string, unknown>;
63
66
  };
64
67
  type RefreshBehavior = {
65
68
  type: 'refresh';
66
- schemaId?: string;
67
69
  url?: string;
68
70
  };
69
71
  export type BaseComponent = {
@@ -79,6 +81,9 @@ export type Image = {
79
81
  uri: string;
80
82
  accessibilityDescription?: string;
81
83
  };
84
+ export type PersistableComponent = {
85
+ onPersistAsync: () => void;
86
+ };
82
87
  export type BaseSchemaComponent<LV extends LocalValue> = BaseComponent & {
83
88
  schemaId?: string;
84
89
  isSchemaReferencedInStep?: boolean;
@@ -116,6 +121,7 @@ export type OnAction = (action: Action) => Promise<void>;
116
121
  export type OnPoll = (url: string, errorBehavior: Behavior, signal: AbortSignal) => Promise<boolean>;
117
122
  export type OnLink = (url: string) => boolean;
118
123
  export type OnValueChange = () => void;
124
+ export type OnPersistAsync = () => void;
119
125
  export type Align = 'start' | 'center' | 'end';
120
126
  export type Autocapitalization = 'none' | 'sentences' | 'words' | 'characters';
121
127
  export type Bias = 'none' | 'start' | 'end';
@@ -1,4 +1,4 @@
1
- import type { Model, Step, ErrorResponseBody } from '@wise/dynamic-flow-types/build/next';
1
+ import type { ErrorResponseBody, Model, Step } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
3
3
  type Command = {
4
4
  type: 'refresh-step';
@@ -15,8 +15,8 @@ export declare const executeRefresh: (props: {
15
15
  abortSignal: AbortSignal;
16
16
  url: string;
17
17
  model: Model;
18
- schemaId?: string;
19
18
  etag: string | null;
19
+ analytics?: Record<string, unknown>;
20
20
  httpClient: typeof fetch;
21
21
  trackEvent: AnalyticsEventDispatcher;
22
22
  logEvent: LoggingEventDispatcher;
@@ -0,0 +1,3 @@
1
+ import type { PersistAsyncComponent } from '../../domain/components/PersistAsyncComponent';
2
+ import { type RendererMapperProps } from './componentToRendererProps';
3
+ export declare const persistAsyncComponentToProps: (component: PersistAsyncComponent, rendererMapperProps: RendererMapperProps) => import("@wise/dynamic-flow-types/build/renderers").RendererProps;
@@ -1,7 +1,7 @@
1
1
  import type { AllOfSchema, ArraySchema, ArraySchemaList, ArraySchemaTuple, BlobSchema, BooleanSchema, ConstSchema, IntegerSchema, Model, NumberSchema, ObjectSchema, OneOfSchema, Schema, StringSchema } from '@wise/dynamic-flow-types/build/next';
2
2
  import type { PersistAsync } from '@wise/dynamic-flow-types/build/next/feature/PersistAsync';
3
3
  import type { DomainComponent, LocalValue, LocalValueArray, LocalValueObject } from '../domain/types';
4
- type SchemaWithPersistAsync = (ArraySchemaList | ArraySchemaTuple | BooleanSchema | IntegerSchema | NumberSchema | StringSchema) & {
4
+ export type SchemaWithPersistAsync = (ArraySchemaList | ArraySchemaTuple | BooleanSchema | IntegerSchema | NumberSchema | StringSchema) & {
5
5
  persistAsync: PersistAsync;
6
6
  };
7
7
  export type StringSchemaWithUpload = Omit<StringSchema & {
@@ -36,4 +36,3 @@ export declare const isArrayTupleSchema: (schema: Schema) => schema is ArraySche
36
36
  export declare const isStringSchema: (schema: Schema) => schema is StringSchema;
37
37
  export declare const isStringSchemaWithUpload: (schema: Schema) => schema is StringSchemaWithUpload;
38
38
  export declare const isSchemaWithPersistAsync: (schema: Schema) => schema is SchemaWithPersistAsync;
39
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.js",
@@ -30,18 +30,18 @@
30
30
  "url": "git+https://github.com/transferwise/dynamic-flow.git"
31
31
  },
32
32
  "devDependencies": {
33
- "@babel/core": "7.27.3",
33
+ "@babel/core": "7.27.4",
34
34
  "@babel/plugin-syntax-flow": "7.27.1",
35
35
  "@babel/plugin-transform-react-jsx": "7.27.1",
36
36
  "@babel/preset-env": "7.27.2",
37
37
  "@babel/preset-react": "7.27.1",
38
38
  "@babel/preset-typescript": "7.27.1",
39
39
  "@chromatic-com/storybook": "4.0.0",
40
- "@formatjs/cli": "^6.7.1",
41
- "@storybook/addon-a11y": "^9.0.4",
42
- "@storybook/addon-docs": "^9.0.4",
43
- "@storybook/addon-links": "^9.0.4",
44
- "@storybook/react-vite": "9.0.4",
40
+ "@formatjs/cli": "^6.7.2",
41
+ "@storybook/addon-a11y": "^9.0.10",
42
+ "@storybook/addon-docs": "^9.0.10",
43
+ "@storybook/addon-links": "^9.0.10",
44
+ "@storybook/react-vite": "9.0.10",
45
45
  "@testing-library/dom": "10.4.0",
46
46
  "@testing-library/jest-dom": "6.6.3",
47
47
  "@testing-library/react": "16.3.0",
@@ -51,7 +51,7 @@
51
51
  "@transferwise/icons": "3.22.0",
52
52
  "@transferwise/neptune-css": "14.24.4",
53
53
  "@types/jest": "29.5.14",
54
- "@types/node": "22.15.23",
54
+ "@types/node": "22.15.31",
55
55
  "@types/react": "18.3.23",
56
56
  "@types/react-dom": "18.3.7",
57
57
  "@types/react-intl": "3.0.0",
@@ -59,27 +59,27 @@
59
59
  "@wise/components-theming": "^1.6.3",
60
60
  "babel-jest": "29.7.0",
61
61
  "esbuild": "0.25.5",
62
- "eslint-plugin-storybook": "9.0.4",
62
+ "eslint-plugin-storybook": "9.0.10",
63
63
  "jest": "29.7.0",
64
64
  "jest-environment-jsdom": "29.7.0",
65
65
  "jest-fetch-mock": "^3.0.3",
66
66
  "jest-watch-typeahead": "^2.2.2",
67
67
  "npm-run-all2": "7.0.2",
68
- "postcss": "^8.5.3",
68
+ "postcss": "^8.5.5",
69
69
  "postcss-cli": "^11.0.1",
70
70
  "postcss-import": "^16.1.0",
71
71
  "react": "18.3.1",
72
72
  "react-dom": "18.3.1",
73
73
  "react-intl": "6.8.9",
74
- "storybook": "^9.0.4",
75
- "stylelint": "16.19.1",
74
+ "storybook": "^9.0.10",
75
+ "stylelint": "16.20.0",
76
76
  "stylelint-config-standard": "36.0.1",
77
77
  "stylelint-no-unsupported-browser-features": "8.0.4",
78
78
  "stylelint-value-no-unknown-custom-properties": "6.0.1",
79
- "tsx": "4.19.4",
79
+ "tsx": "4.20.3",
80
80
  "typescript": "5.8.3",
81
- "@wise/dynamic-flow-fixtures": "0.0.1",
82
- "@wise/dynamic-flow-renderers": "0.0.0"
81
+ "@wise/dynamic-flow-renderers": "0.0.0",
82
+ "@wise/dynamic-flow-fixtures": "0.0.1"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@transferwise/components": "^46.92.0",
@@ -95,7 +95,7 @@
95
95
  "classnames": "2.5.1",
96
96
  "react-webcam": "^7.2.0",
97
97
  "screenfull": "^5.2.0",
98
- "@wise/dynamic-flow-types": "3.4.0"
98
+ "@wise/dynamic-flow-types": "3.5.0"
99
99
  },
100
100
  "scripts": {
101
101
  "dev": "pnpm build:visual-tests && storybook dev -p 3003",
@@ -1,21 +0,0 @@
1
- import type { BooleanInputComponent } from '../../components/BooleanInputComponent';
2
- import type { DateInputComponent } from '../../components/DateInputComponent';
3
- import type { IntegerInputComponent } from '../../components/IntegerInputComponent';
4
- import type { MultiUploadInputComponent } from '../../components/MultiUploadInputComponent';
5
- import type { NumberInputComponent } from '../../components/NumberInputComponent';
6
- import type { TextInputComponent } from '../../components/TextInputComponent';
7
- import type { UploadInputComponent } from '../../components/UploadInputComponent';
8
- import type { LocalValue } from '../../types';
9
- import type { PerformPersistAsync } from './getPerformPersistAsync';
10
- type Persistable = BooleanInputComponent | DateInputComponent | IntegerInputComponent | NumberInputComponent | TextInputComponent | UploadInputComponent;
11
- type Update<C extends Persistable> = (component: C, updateFn: (component: C) => void) => void;
12
- /**
13
- * Creates an onPersistAsync handler for a component.
14
- */
15
- export declare const getComponentPersistAsync: <C extends Persistable>(update: Update<C>, performPersistAsync: PerformPersistAsync) => (component: C, currentValue: LocalValue) => Promise<import("@wise/dynamic-flow-types/build/next").JsonElement>;
16
- type UpdateMultiUploadInputComponent = (component: MultiUploadInputComponent, updateFn: (component: MultiUploadInputComponent) => void) => void;
17
- /**
18
- * Creates an onPersistAsync handler for a component.
19
- */
20
- export declare const getComponentMultiPersistAsync: (update: UpdateMultiUploadInputComponent, performPersistAsync: PerformPersistAsync) => (component: MultiUploadInputComponent, index: number, value: LocalValue) => Promise<string | number | boolean | import("@wise/dynamic-flow-types/build/next").JsonObject | import("@wise/dynamic-flow-types/build/next").JsonArray | null>;
21
- export {};
@@ -1,12 +0,0 @@
1
- import type { Schema } from '@wise/dynamic-flow-types/build/next';
2
- import type { LocalValue, OnBehavior } from '../../types';
3
- export type PerformRefresh = () => void;
4
- export declare const getPerformRefresh: (schema: Schema, onBehavior: OnBehavior) => PerformRefresh | undefined;
5
- type DebouncedPerformRefresh<V extends LocalValue> = {
6
- (prevValue: V, updatedValue: V): void;
7
- cancel: () => void;
8
- flush: () => void;
9
- isPending: () => boolean;
10
- };
11
- export declare const getDebouncedPerformRefresh: <V extends LocalValue>(performRefresh: PerformRefresh | undefined, getValidationErrors: (value: V) => string[]) => DebouncedPerformRefresh<V> | undefined;
12
- export {};
@@ -1,5 +0,0 @@
1
- import type { MapperProps, SchemaMapperProps } from '../types';
2
- export declare const getPersistAsyncInitialState: (schemaMapperProps: SchemaMapperProps, mapperProps: MapperProps) => {
3
- performPersistAsync: import("../../../features/persistAsync/getPerformPersistAsync").PerformPersistAsync | undefined;
4
- persistedState: import("../../../types").PersistedState;
5
- };