@wise/dynamic-flow-client 5.3.0 → 5.4.1-experimental-ede02d2
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.
- package/build/main.css +6 -0
- package/build/main.js +6479 -6125
- package/build/main.mjs +6464 -6110
- package/build/types/controller/FlowController.d.ts +18 -0
- package/build/types/controller/executeRequest.d.ts +39 -0
- package/build/types/controller/executeSubmission.d.ts +15 -0
- package/build/types/controller/getRequestAbortController.d.ts +4 -0
- package/build/types/{flow → controller}/getResponseType.d.ts +1 -1
- package/build/types/controller/getSafeHttpClient.d.ts +1 -0
- package/build/types/controller/getStepCounter.d.ts +9 -0
- package/build/types/controller/handleErrorResponse.d.ts +3 -0
- package/build/types/{flow → controller}/response-utils.d.ts +2 -1
- package/build/types/domain/components/BooleanInputComponent.d.ts +2 -2
- package/build/types/domain/components/DateInputComponent.d.ts +2 -2
- package/build/types/domain/components/FormattedValueComponent.d.ts +2 -2
- package/build/types/domain/components/IntegerInputComponent.d.ts +2 -2
- package/build/types/domain/components/ModalComponent.d.ts +2 -2
- package/build/types/domain/components/MoneyInputComponent.d.ts +2 -2
- package/build/types/domain/components/MultiSelectInputComponent.d.ts +2 -2
- package/build/types/domain/components/MultiUploadInputComponent.d.ts +2 -2
- package/build/types/domain/components/NumberInputComponent.d.ts +2 -2
- package/build/types/domain/components/PersistAsyncComponent.d.ts +2 -2
- package/build/types/domain/components/RepeatableComponent.d.ts +2 -2
- package/build/types/domain/components/RootDomainComponent.d.ts +13 -9
- package/build/types/domain/components/SelectInputComponent.d.ts +2 -3
- package/build/types/domain/components/SubflowDomainComponent.d.ts +16 -0
- package/build/types/domain/components/TextInputComponent.d.ts +2 -2
- package/build/types/domain/components/UploadInputComponent.d.ts +2 -2
- package/build/types/domain/components/searchComponent/SearchComponent.d.ts +2 -2
- package/build/types/domain/components/step/ExternalConfirmationComponent.d.ts +2 -2
- package/build/types/domain/components/step/StepDomainComponent.d.ts +5 -5
- package/build/types/domain/components/utils/component-utils.d.ts +4 -4
- package/build/types/domain/features/eventNames.d.ts +1 -0
- package/build/types/domain/features/events.d.ts +2 -1
- package/build/types/domain/mappers/mapStepToComponent.d.ts +2 -0
- package/build/types/domain/mappers/schema/types.d.ts +2 -2
- package/build/types/domain/prefetching/request-cache.d.ts +7 -7
- package/build/types/domain/types.d.ts +18 -4
- package/build/types/getSubflowCallbacks.d.ts +14 -0
- package/build/types/index.d.ts +4 -0
- package/build/types/renderers/mappers/subflowComponentToRendererProps.d.ts +4 -0
- package/build/types/test-utils/DynamicFlowWiseModal.d.ts +12 -0
- package/build/types/test-utils/getMergedTestRenderers.d.ts +2 -0
- package/build/types/types.d.ts +2 -0
- package/build/types/useDynamicFlowModal.d.ts +16 -0
- package/package.json +14 -14
- package/build/types/flow/executeSubmission.d.ts +0 -42
- package/build/types/flow/makeSubmissionRequest.d.ts +0 -3
- package/build/types/useDynamicFlowController.d.ts +0 -15
- /package/build/types/{flow → controller}/executePoll.d.ts +0 -0
- /package/build/types/{flow → controller}/executeRefresh.d.ts +0 -0
- /package/build/types/{flow → controller}/getErrorMessage.d.ts +0 -0
- /package/build/types/{flow → controller}/makeSafeHttpClient.d.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BackConfig } from '../domain/components/RootDomainComponent';
|
|
2
|
+
import { GetErrorMessageFunctions } from '../domain/mappers/types';
|
|
3
|
+
import { FeatureFlags } from '../domain/mappers/utils/FeatureFlags';
|
|
4
|
+
import { OnValueChange, ScrollToTop } from '../domain/types';
|
|
5
|
+
import { DynamicFlowCoreProps } from '../types';
|
|
6
|
+
export type FlowControllerProps = Omit<DynamicFlowCoreProps, 'renderers' | 'features'> & {
|
|
7
|
+
backConfig: BackConfig;
|
|
8
|
+
features: FeatureFlags;
|
|
9
|
+
getErrorMessageFunctions: GetErrorMessageFunctions;
|
|
10
|
+
onChange: () => void;
|
|
11
|
+
onValueChange: OnValueChange;
|
|
12
|
+
scrollToTop: ScrollToTop;
|
|
13
|
+
onLink: (url: string) => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const createFlowController: (props: FlowControllerProps) => {
|
|
16
|
+
rootComponent: import("../domain/components/RootDomainComponent").RootDomainComponent;
|
|
17
|
+
cancel: () => void;
|
|
18
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ErrorResponseBody, Model, Request, Step } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
|
|
3
|
+
import { RequestCache } from '../domain/prefetching/request-cache';
|
|
4
|
+
import { Behavior } from '../domain/types';
|
|
5
|
+
export type Command = {
|
|
6
|
+
type: 'complete';
|
|
7
|
+
result: Model;
|
|
8
|
+
} | {
|
|
9
|
+
type: 'replace-step';
|
|
10
|
+
step: Step;
|
|
11
|
+
etag: string | null;
|
|
12
|
+
} | {
|
|
13
|
+
type: 'error';
|
|
14
|
+
body?: {
|
|
15
|
+
analytics?: ErrorResponseBody['analytics'];
|
|
16
|
+
errors?: Step['errors'];
|
|
17
|
+
};
|
|
18
|
+
httpError?: {
|
|
19
|
+
message?: string;
|
|
20
|
+
statusCode?: number;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
type: 'refresh';
|
|
24
|
+
body: {
|
|
25
|
+
refreshUrl: string;
|
|
26
|
+
errors?: Step['errors'];
|
|
27
|
+
};
|
|
28
|
+
} | {
|
|
29
|
+
type: 'behavior';
|
|
30
|
+
behavior: Behavior;
|
|
31
|
+
};
|
|
32
|
+
export declare const executeRequest: (props: {
|
|
33
|
+
exit?: boolean;
|
|
34
|
+
request: Request;
|
|
35
|
+
requestCache: RequestCache;
|
|
36
|
+
httpClient: typeof fetch;
|
|
37
|
+
trackEvent: AnalyticsEventDispatcher<string>;
|
|
38
|
+
logEvent: LoggingEventDispatcher;
|
|
39
|
+
}) => Promise<Command>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Action, Model, Request } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
|
|
3
|
+
import { RequestCache } from '../domain/prefetching/request-cache';
|
|
4
|
+
import { HttpClient } from '../types';
|
|
5
|
+
import { Command } from './executeRequest';
|
|
6
|
+
export declare const executeSubmission: (props: {
|
|
7
|
+
action: Action;
|
|
8
|
+
model: Model;
|
|
9
|
+
isInitial: boolean;
|
|
10
|
+
requestCache: RequestCache;
|
|
11
|
+
httpClient: HttpClient;
|
|
12
|
+
trackEvent: AnalyticsEventDispatcher<string>;
|
|
13
|
+
logEvent: LoggingEventDispatcher;
|
|
14
|
+
}) => Promise<Command>;
|
|
15
|
+
export declare const createRequestFromAction: (action: Action, model: Model) => Request;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const responseTypes: readonly ["step", "action", "exit", "modal"];
|
|
1
|
+
declare const responseTypes: readonly ["step", "action", "exit", "modal", "subflow"];
|
|
2
2
|
export type ResponseType = (typeof responseTypes)[number];
|
|
3
3
|
/**
|
|
4
4
|
* Returns either 'step', 'action', or 'exit' based on the response headers and body.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSafeHttpClient: (httpClient: typeof fetch) => (input: Parameters<typeof fetch>[0], init?: Parameters<typeof fetch>[1]) => Promise<Response | null>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* To ensure there are no uid collisions between consecutive steps, we use a
|
|
3
|
+
* counter that is appended to the step id. This means that even steps with the
|
|
4
|
+
* same structure and ids will not have the same component uids.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getStepCounter: () => {
|
|
7
|
+
increment(): void;
|
|
8
|
+
readonly current: number;
|
|
9
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { ActionResponseBody, ErrorResponseBody, JsonElement, ModalBehavior, Step } from '@wise/dynamic-flow-types/spec';
|
|
1
|
+
import type { ActionResponseBody, ErrorResponseBody, JsonElement, ModalBehavior, Step, SubflowResponseBody } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
export declare const assertResponseIsValid: (response: unknown) => void;
|
|
3
3
|
export declare const parseResponseBodyAsJsonElement: (response: Response) => Promise<JsonElement>;
|
|
4
4
|
export declare const parseResponseBodyAsText: (response: Response) => Promise<string | null>;
|
|
5
5
|
export declare function isActionResponseBody(body: unknown): body is ActionResponseBody;
|
|
6
6
|
export declare function assertActionResponseBody(body: unknown): asserts body is ActionResponseBody;
|
|
7
7
|
export declare function assertModalResponseBody(body: unknown): asserts body is Omit<ModalBehavior, 'type'>;
|
|
8
|
+
export declare function assertSubflowResponseBody(body: unknown): asserts body is SubflowResponseBody;
|
|
8
9
|
export declare function isErrorResponseBody(body: unknown): body is ErrorResponseBody;
|
|
9
10
|
export declare function assertErrorResponseBody(body: unknown): asserts body is ErrorResponseBody;
|
|
10
11
|
export declare function assertStepResponseBody(body: unknown): asserts body is Step;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
2
2
|
import type { PerformValidationAsync } from '../features/validationAsync/getPerformValidationAsync';
|
|
3
|
-
import type { BaseInputComponent, InlineAlert, OnPersistAsync, OnValueChange, RepeatableSummary,
|
|
3
|
+
import type { BaseInputComponent, InlineAlert, OnComponentUpdate, OnPersistAsync, OnValueChange, RepeatableSummary, SupportingValues, ValidationAsyncState } from '../types';
|
|
4
4
|
export type BooleanInputComponent = BaseInputComponent<boolean> & {
|
|
5
5
|
type: 'boolean';
|
|
6
6
|
kind: 'input';
|
|
@@ -16,4 +16,4 @@ export declare const createBooleanInputComponent: (booleanInputProps: Pick<Boole
|
|
|
16
16
|
summariser: (value: boolean) => RepeatableSummary;
|
|
17
17
|
onValueChange: OnValueChange;
|
|
18
18
|
onPersistAsync: OnPersistAsync | undefined;
|
|
19
|
-
},
|
|
19
|
+
}, onComponentUpdate: OnComponentUpdate) => BooleanInputComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, Suggestions,
|
|
4
|
+
import type { BaseInputComponent, OnComponentUpdate, OnPersistAsync, OnValueChange, RepeatableSummary, Suggestions, ValidationAsyncState } from '../types';
|
|
5
5
|
export type DateInputComponent = BaseInputComponent<string | null> & {
|
|
6
6
|
type: 'date';
|
|
7
7
|
kind: 'input';
|
|
@@ -18,4 +18,4 @@ export declare const createDateInputComponent: (textInputProps: Pick<DateInputCo
|
|
|
18
18
|
onValueChange: OnValueChange;
|
|
19
19
|
onPersistAsync: OnPersistAsync | undefined;
|
|
20
20
|
summariser: (value: string | null) => RepeatableSummary;
|
|
21
|
-
},
|
|
21
|
+
}, onComponentUpdate: OnComponentUpdate) => DateInputComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
3
|
-
import type { BaseSchemaComponent, InlineAlert, LocalValue,
|
|
3
|
+
import type { BaseSchemaComponent, InlineAlert, LocalValue, OnComponentUpdate, RepeatableSummary } from '../types';
|
|
4
4
|
export type FormattedValueComponent = BaseSchemaComponent<JsonElement> & {
|
|
5
5
|
type: 'formatted-value';
|
|
6
6
|
kind: 'input';
|
|
@@ -13,4 +13,4 @@ export type FormattedValueComponent = BaseSchemaComponent<JsonElement> & {
|
|
|
13
13
|
export declare const createFormattedValueComponent: (props: Pick<FormattedValueComponent, "uid" | "schemaId" | "analyticsId" | "alert" | "control" | "description" | "errors" | "format" | "help" | "hidden" | "media" | "title" | "tags" | "value"> & {
|
|
14
14
|
summariser: (value: LocalValue | null) => RepeatableSummary;
|
|
15
15
|
schemaOnChange: SchemaOnChange | undefined;
|
|
16
|
-
},
|
|
16
|
+
}, onComponentUpdate: OnComponentUpdate) => FormattedValueComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary,
|
|
4
|
+
import type { BaseInputComponent, OnComponentUpdate, OnPersistAsync, OnValueChange, RepeatableSummary, ValidationAsyncState } from '../types';
|
|
5
5
|
export type IntegerInputComponent = BaseInputComponent<number | null> & {
|
|
6
6
|
type: 'integer';
|
|
7
7
|
kind: 'input';
|
|
@@ -17,4 +17,4 @@ export declare const createIntegerInputComponent: (integerInputProps: Pick<Integ
|
|
|
17
17
|
onValueChange: OnValueChange;
|
|
18
18
|
onPersistAsync: OnPersistAsync | undefined;
|
|
19
19
|
summariser: (value: number | null) => RepeatableSummary;
|
|
20
|
-
},
|
|
20
|
+
}, onComponentUpdate: OnComponentUpdate) => IntegerInputComponent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseComponent, DomainComponent,
|
|
1
|
+
import type { BaseComponent, DomainComponent, OnComponentUpdate } from '../types';
|
|
2
2
|
export type ModalComponent = BaseComponent & {
|
|
3
3
|
type: 'modal';
|
|
4
4
|
kind: 'layout';
|
|
@@ -9,4 +9,4 @@ export type ModalComponent = BaseComponent & {
|
|
|
9
9
|
getChildren: () => DomainComponent[];
|
|
10
10
|
close: () => void;
|
|
11
11
|
};
|
|
12
|
-
export declare const createModalContentComponent: (modalProps: Pick<ModalComponent, "uid" | "analyticsId" | "components" | "tags" | "title">,
|
|
12
|
+
export declare const createModalContentComponent: (modalProps: Pick<ModalComponent, "uid" | "analyticsId" | "components" | "tags" | "title">, onComponentUpdate: OnComponentUpdate) => ModalComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JsonObject } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import { IsInvalidCheck } from '../features/validation/value-checks';
|
|
3
|
-
import { BaseInputComponent, LocalValue, LocalValueObject,
|
|
3
|
+
import { BaseInputComponent, LocalValue, LocalValueObject, OnComponentUpdate, RepeatableSummary } from '../types';
|
|
4
4
|
import { SelectInputComponent } from './SelectInputComponent';
|
|
5
5
|
import { TextInputComponent } from './TextInputComponent';
|
|
6
6
|
export type MoneyInputComponent = BaseInputComponent<LocalValueObject> & {
|
|
@@ -19,4 +19,4 @@ export declare const createMoneyInputComponent: (moneyInputProps: Pick<MoneyInpu
|
|
|
19
19
|
extraValues: JsonObject;
|
|
20
20
|
checks: IsInvalidCheck<string | null>[];
|
|
21
21
|
summariser: (value: LocalValue | null) => RepeatableSummary;
|
|
22
|
-
},
|
|
22
|
+
}, onComponentUpdate: OnComponentUpdate) => MoneyInputComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import type { BaseInputComponent, LocalValue, LocalValueArray, OnValueChange, SchemaComponent,
|
|
4
|
+
import type { BaseInputComponent, LocalValue, LocalValueArray, OnValueChange, SchemaComponent, OnComponentUpdate, ValidationAsyncState } from '../types';
|
|
5
5
|
import type { SelectInputOption } from './SelectInputComponent';
|
|
6
6
|
export type MultiSelectComponent = BaseInputComponent<LocalValueArray | null> & {
|
|
7
7
|
type: 'multi-select';
|
|
@@ -25,4 +25,4 @@ export declare const createMultiSelectComponent: (multiSelectProps: Pick<MultiSe
|
|
|
25
25
|
performValidationAsync: PerformValidationAsync | undefined;
|
|
26
26
|
schemaOnChange: SchemaOnChange | undefined;
|
|
27
27
|
onValueChange: OnValueChange;
|
|
28
|
-
},
|
|
28
|
+
}, onComponentUpdate: OnComponentUpdate) => MultiSelectComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import type { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
|
|
3
3
|
import type { IsInvalidCheck } from '../features/validation/value-checks';
|
|
4
|
-
import type { BaseInputComponent, OnValueChange, PersistedState, RepeatableSummary,
|
|
4
|
+
import type { BaseInputComponent, OnComponentUpdate, OnValueChange, PersistedState, RepeatableSummary, UploadSource } from '../types';
|
|
5
5
|
export type MultiUploadInputComponent = BaseInputComponent<File[]> & {
|
|
6
6
|
type: 'multi-upload';
|
|
7
7
|
kind: 'input';
|
|
@@ -30,4 +30,4 @@ export declare const createMultiUploadInputComponent: (uploadInputProps: Pick<Mu
|
|
|
30
30
|
performPersistAsync: PerformPersistAsync | undefined;
|
|
31
31
|
onValueChange: OnValueChange;
|
|
32
32
|
summariser: (value: string[]) => RepeatableSummary;
|
|
33
|
-
},
|
|
33
|
+
}, onComponentUpdate: OnComponentUpdate) => MultiUploadInputComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary,
|
|
4
|
+
import type { BaseInputComponent, OnComponentUpdate, OnPersistAsync, OnValueChange, RepeatableSummary, ValidationAsyncState } from '../types';
|
|
5
5
|
export type NumberInputComponent = BaseInputComponent<number | null> & {
|
|
6
6
|
type: 'number';
|
|
7
7
|
kind: 'input';
|
|
@@ -17,4 +17,4 @@ export declare const createNumberInputComponent: (numberInputProps: Pick<NumberI
|
|
|
17
17
|
onValueChange: OnValueChange;
|
|
18
18
|
onPersistAsync: OnPersistAsync | undefined;
|
|
19
19
|
summariser: (value: number | null) => RepeatableSummary;
|
|
20
|
-
},
|
|
20
|
+
}, onComponentUpdate: OnComponentUpdate) => NumberInputComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import { PerformPersistAsync } from '../features/persistAsync/getPerformPersistAsync';
|
|
3
3
|
import { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
4
|
-
import type { BaseSchemaComponent, LocalValue,
|
|
4
|
+
import type { BaseSchemaComponent, LocalValue, OnComponentUpdate, SchemaComponent } from '../types';
|
|
5
5
|
export type PersistAsyncComponent = BaseSchemaComponent<LocalValue> & {
|
|
6
6
|
type: 'persist-async';
|
|
7
7
|
kind: 'input';
|
|
@@ -16,4 +16,4 @@ export type PersistAsyncComponent = BaseSchemaComponent<LocalValue> & {
|
|
|
16
16
|
export declare const createPersistAsyncComponent: (props: Pick<PersistAsyncComponent, "uid" | "analyticsId" | "schemaId" | "component" | "hidden" | "tags"> & {
|
|
17
17
|
model?: JsonElement | null;
|
|
18
18
|
localValue?: LocalValue | null;
|
|
19
|
-
}, performPersistAsync: PerformPersistAsync, schemaOnChange: SchemaOnChange | undefined,
|
|
19
|
+
}, performPersistAsync: PerformPersistAsync, schemaOnChange: SchemaOnChange | undefined, onComponentUpdate: OnComponentUpdate) => PersistAsyncComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IsInvalidCheck } from '../features/validation/value-checks';
|
|
2
|
-
import type { BaseSchemaComponent, InlineAlert, LocalValue, LocalValueArray, Media, OnValueChange, RepeatableSummary, SchemaComponent
|
|
2
|
+
import type { BaseSchemaComponent, InlineAlert, LocalValue, LocalValueArray, Media, OnComponentUpdate, OnValueChange, RepeatableSummary, SchemaComponent } from '../types';
|
|
3
3
|
export type RepeatableComponent = BaseSchemaComponent<LocalValueArray> & {
|
|
4
4
|
type: 'repeatable';
|
|
5
5
|
kind: 'input';
|
|
@@ -34,5 +34,5 @@ export declare const createRepeatableComponent: (repeatableProps: Pick<Repeatabl
|
|
|
34
34
|
summariser: (value: LocalValueArray | null) => RepeatableSummary;
|
|
35
35
|
onValueChange: OnValueChange;
|
|
36
36
|
createEditableComponent: (value: LocalValue) => SchemaComponent;
|
|
37
|
-
},
|
|
37
|
+
}, onComponentUpdate: OnComponentUpdate) => RepeatableComponent;
|
|
38
38
|
export {};
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { Model } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import { AnalyticsEventDispatcher } from '../features/events';
|
|
3
|
-
import { BaseComponent, DomainComponent, LoadingState, LocalValue, SchemaComponent, ScrollToTop,
|
|
3
|
+
import { BaseComponent, DomainComponent, LoadingState, LocalValue, SchemaComponent, ScrollToTop, OnComponentUpdate } from '../types';
|
|
4
4
|
import { ModalComponent } from './ModalComponent';
|
|
5
5
|
import { StepDomainComponent } from './step/StepDomainComponent';
|
|
6
|
+
import { SubflowDomainComponent } from './SubflowDomainComponent';
|
|
7
|
+
import { RequestCache } from '../prefetching/request-cache';
|
|
8
|
+
export type BackConfig = {
|
|
9
|
+
isNativeBackEnabled: boolean;
|
|
10
|
+
isFlowCancellable: boolean;
|
|
11
|
+
};
|
|
6
12
|
export type RootDomainComponent = BaseComponent & {
|
|
7
13
|
type: 'root';
|
|
8
14
|
kind: 'step';
|
|
9
15
|
stepComponent: StepDomainComponent | null;
|
|
10
16
|
stepStack: StepDomainComponent[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
17
|
+
subflow: SubflowDomainComponent | null;
|
|
18
|
+
backConfig: BackConfig;
|
|
19
|
+
requestCache: RequestCache;
|
|
15
20
|
canPerformBack: () => boolean;
|
|
16
21
|
dismissAllModals: () => void;
|
|
17
22
|
dismissModal: () => void;
|
|
@@ -35,8 +40,7 @@ export type RootDomainComponent = BaseComponent & {
|
|
|
35
40
|
clearStack: () => void;
|
|
36
41
|
navigateBack: () => void;
|
|
37
42
|
getRefreshUrl: () => string | null;
|
|
43
|
+
addSubflow: (subflow: SubflowDomainComponent) => void;
|
|
44
|
+
closeSubflow: () => void;
|
|
38
45
|
};
|
|
39
|
-
export declare const createRootDomainComponent: (
|
|
40
|
-
isNativeBackEnabled: boolean;
|
|
41
|
-
isFlowCancellable: boolean;
|
|
42
|
-
}) => RootDomainComponent;
|
|
46
|
+
export declare const createRootDomainComponent: (onComponentUpdate: OnComponentUpdate, scrollToTop: ScrollToTop, backConfig: BackConfig, requestCache: RequestCache) => RootDomainComponent;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Model } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import type { AnalyticsEventDispatcher } from '../features/events';
|
|
3
3
|
import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
4
|
-
import type { InlineAlert, SupportingValues } from '../types';
|
|
5
4
|
import type { IsInvalidCheck } from '../features/validation/value-checks';
|
|
6
|
-
import type { BaseInputComponent, LocalValue, Media, OnValueChange, RepeatableSummary, SchemaComponent,
|
|
5
|
+
import type { BaseInputComponent, InlineAlert, LocalValue, Media, OnComponentUpdate, OnValueChange, RepeatableSummary, SchemaComponent, SupportingValues } from '../types';
|
|
7
6
|
export type SelectInputComponent = BaseInputComponent<LocalValue | null> & {
|
|
8
7
|
type: 'select';
|
|
9
8
|
kind: 'input';
|
|
@@ -37,4 +36,4 @@ export declare const createSelectInputComponent: (selectProps: Pick<SelectInputC
|
|
|
37
36
|
summariser: (value: LocalValue | null) => RepeatableSummary;
|
|
38
37
|
onValueChange: OnValueChange;
|
|
39
38
|
trackEvent: AnalyticsEventDispatcher;
|
|
40
|
-
},
|
|
39
|
+
}, onComponentUpdate: OnComponentUpdate) => SelectInputComponent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonElement, Request } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import { AnalyticsEventDispatcher } from '../features/events';
|
|
3
|
+
import { RequestCache } from '../prefetching/request-cache';
|
|
4
|
+
import { BaseComponent, OnComponentUpdate, Presentation } from '../types';
|
|
5
|
+
export type SubflowDomainComponent = BaseComponent & {
|
|
6
|
+
kind: 'layout';
|
|
7
|
+
type: 'subflow';
|
|
8
|
+
presentation: Presentation;
|
|
9
|
+
initialRequest: Request;
|
|
10
|
+
requestCache: RequestCache;
|
|
11
|
+
onCancellation: () => void;
|
|
12
|
+
onCompletion: (result: JsonElement) => void;
|
|
13
|
+
onEvent: AnalyticsEventDispatcher<string>;
|
|
14
|
+
onError: (error: unknown, status?: number) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const createSubflowDomainComponent: (subflowProps: Pick<SubflowDomainComponent, "initialRequest" | "presentation" | "requestCache" | "onCompletion" | "onCancellation" | "onError" | "onEvent">, onComponentUpdate: OnComponentUpdate) => SubflowDomainComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
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
|
-
import type { Autocapitalization, BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary, Suggestions,
|
|
4
|
+
import type { Autocapitalization, BaseInputComponent, OnComponentUpdate, OnPersistAsync, OnValueChange, RepeatableSummary, Suggestions, ValidationAsyncState } from '../types';
|
|
5
5
|
export type TextInputComponent = BaseInputComponent<string | null> & {
|
|
6
6
|
type: 'text';
|
|
7
7
|
kind: 'input';
|
|
@@ -20,4 +20,4 @@ export declare const createTextInputComponent: (textInputProps: Pick<TextInputCo
|
|
|
20
20
|
onValueChange: OnValueChange;
|
|
21
21
|
onPersistAsync: OnPersistAsync | undefined;
|
|
22
22
|
summariser: (value: string | null) => RepeatableSummary;
|
|
23
|
-
},
|
|
23
|
+
}, onComponentUpdate: OnComponentUpdate) => TextInputComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import type { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
3
3
|
import type { IsInvalidCheck } from '../features/validation/value-checks';
|
|
4
|
-
import type { BaseInputComponent, OnPersistAsync, OnValueChange, RepeatableSummary,
|
|
4
|
+
import type { BaseInputComponent, OnComponentUpdate, OnPersistAsync, OnValueChange, RepeatableSummary, UploadSource } from '../types';
|
|
5
5
|
export type UploadInputComponent = BaseInputComponent<File | null> & {
|
|
6
6
|
type: 'upload';
|
|
7
7
|
kind: 'input';
|
|
@@ -20,4 +20,4 @@ export declare const createUploadInputComponent: (uploadInputProps: Pick<UploadI
|
|
|
20
20
|
onValueChange: OnValueChange;
|
|
21
21
|
onPersistAsync: OnPersistAsync | undefined;
|
|
22
22
|
summariser: (value: string | null) => RepeatableSummary;
|
|
23
|
-
},
|
|
23
|
+
}, onComponentUpdate: OnComponentUpdate) => UploadInputComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SearchResult } from '@wise/dynamic-flow-types/spec';
|
|
2
|
-
import type { BaseLayoutComponent, OnBehavior,
|
|
2
|
+
import type { BaseLayoutComponent, OnBehavior, OnComponentUpdate } from '../../types';
|
|
3
3
|
export type SearchConfig = {
|
|
4
4
|
method: string;
|
|
5
5
|
param: string;
|
|
@@ -23,4 +23,4 @@ export type SearchComponent = BaseLayoutComponent & {
|
|
|
23
23
|
onChange: (query: string) => void;
|
|
24
24
|
onSelect: (result: SearchResult) => void;
|
|
25
25
|
};
|
|
26
|
-
export declare const createSearchComponent: (searchProps: Pick<SearchComponent, "uid" | "analyticsId" | "control" | "emptyMessage" | "margin" | "tags" | "title">, performSearch: PerformSearch, onBehavior: OnBehavior,
|
|
26
|
+
export declare const createSearchComponent: (searchProps: Pick<SearchComponent, "uid" | "analyticsId" | "control" | "emptyMessage" | "margin" | "tags" | "title">, performSearch: PerformSearch, onBehavior: OnBehavior, onComponentUpdate: OnComponentUpdate) => SearchComponent;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseComponent,
|
|
1
|
+
import { BaseComponent, OnComponentUpdate } from '../../types';
|
|
2
2
|
export type ExternalConfirmationComponent = BaseComponent & {
|
|
3
3
|
type: 'external-confirmation';
|
|
4
4
|
kind: 'layout';
|
|
@@ -9,4 +9,4 @@ export type ExternalConfirmationComponent = BaseComponent & {
|
|
|
9
9
|
onFailure: () => void;
|
|
10
10
|
onCancel: () => void;
|
|
11
11
|
};
|
|
12
|
-
export declare const createExternalConfirmation: (uid: string, url: string,
|
|
12
|
+
export declare const createExternalConfirmation: (uid: string, url: string, onComponentUpdate: OnComponentUpdate) => ExternalConfirmationComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BaseComponent, DomainComponent, LayoutComponent, LoadingState, LocalValue, OnBehavior, SchemaComponent,
|
|
1
|
+
import type { BaseComponent, DomainComponent, LayoutComponent, LoadingState, LocalValue, OnBehavior, SchemaComponent, OnComponentUpdate } from '../../types';
|
|
2
2
|
import type { NavigationStackBehavior, Step } from '@wise/dynamic-flow-types/spec';
|
|
3
3
|
import { Model } from '@wise/dynamic-flow-types/spec';
|
|
4
|
-
import {
|
|
4
|
+
import { RequestCache } from '../../prefetching/request-cache';
|
|
5
5
|
import type { AnalyticsEventDispatcher } from '../../features/events';
|
|
6
6
|
import type { StepPolling } from '../../features/polling/getStepPolling';
|
|
7
7
|
import { StepRefreshAfter } from '../../features/refreshAfter/getStepRefreshAfter';
|
|
@@ -27,7 +27,7 @@ export type StepDomainComponent = BaseComponent & {
|
|
|
27
27
|
title?: string;
|
|
28
28
|
modals: ModalComponent[];
|
|
29
29
|
tags?: string[];
|
|
30
|
-
|
|
30
|
+
requestCache: RequestCache;
|
|
31
31
|
dismissModal: () => void;
|
|
32
32
|
dismissAllModals: () => void;
|
|
33
33
|
showModal: (modal: ModalComponent) => void;
|
|
@@ -47,8 +47,8 @@ export type BackNavigation = {
|
|
|
47
47
|
title?: string;
|
|
48
48
|
onClick: () => void;
|
|
49
49
|
};
|
|
50
|
-
export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "uid" | "back" | "toolbar" | "layoutComponents" | "schemaComponents" | "footerComponents" | "control" | "description" | "error" | "externalConfirmation" | "loadingState" | "stackBehavior" | "etag" | "step" | "title" | "tags" | "
|
|
50
|
+
export declare const createStepComponent: (stepProps: Pick<StepDomainComponent, "uid" | "back" | "toolbar" | "layoutComponents" | "schemaComponents" | "footerComponents" | "control" | "description" | "error" | "externalConfirmation" | "loadingState" | "stackBehavior" | "etag" | "step" | "title" | "tags" | "requestCache" | "trackEvent" | "onBehavior"> & {
|
|
51
51
|
stepPolling?: StepPolling;
|
|
52
52
|
stepRefreshAfter?: StepRefreshAfter;
|
|
53
|
-
|
|
53
|
+
onComponentUpdate: OnComponentUpdate;
|
|
54
54
|
}) => StepDomainComponent;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { DomainComponent,
|
|
1
|
+
import type { DomainComponent, OnComponentUpdate } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Helper function to update a component.
|
|
4
4
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @returns a function that
|
|
5
|
+
* @param onComponentUpdate the function that will notify the view layer that something has changed in the domain layer
|
|
6
|
+
* @returns a function that can be used to update components without the linter shouting at us.
|
|
7
7
|
*/
|
|
8
|
-
export declare const getInputUpdateFunction: <C extends DomainComponent>(
|
|
8
|
+
export declare const getInputUpdateFunction: <C extends DomainComponent>(onComponentUpdate: OnComponentUpdate) => (component: C, updateFn: (component: C) => void) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const eventNames: readonly ["Initiated", "Succeeded", "Failed", "Cancelled", "Step Shown", "Action Triggered", "Action Succeeded", "Action Aborted", "Action Failed", "Refresh Triggered", "Refresh Succeeded", "Refresh Aborted", "Refresh Failed", "OneOf Selected", "OneOf Option Selected", "PersistAsync Triggered", "PersistAsync Succeeded", "PersistAsync Failed", "Polling Failed", "ValidationAsync Triggered", "ValidationAsync Succeeded", "ValidationAsync Failed"];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { eventNames } from './eventNames';
|
|
1
2
|
export type AnalyticsEventHandler = (eventName: string, properties?: Record<string, unknown>) => void;
|
|
2
3
|
export type AnalyticsEventDispatcher<E extends string = EventName> = (eventName: E, properties?: Record<string, unknown>) => void;
|
|
3
|
-
export type EventName =
|
|
4
|
+
export type EventName = (typeof eventNames)[number];
|
|
4
5
|
export type LogLevel = 'info' | 'warning' | 'error';
|
|
5
6
|
export type LoggingEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
|
|
6
7
|
export type LoggingEventDispatcher = (level: LogLevel, message: string, extra?: Record<string, unknown>) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AnalyticsEventDispatcher } from '../features/events';
|
|
2
|
+
import { RequestCache } from '../prefetching/request-cache';
|
|
2
3
|
import type { LoadingState, OnPoll } from '../types';
|
|
3
4
|
import type { MapperProps } from './schema/types';
|
|
4
5
|
import { FeatureFlags } from './utils/FeatureFlags';
|
|
@@ -8,6 +9,7 @@ export type StepMapperProps = Omit<MapperProps, 'trackEvent' | 'registerSubmissi
|
|
|
8
9
|
loadingState: LoadingState;
|
|
9
10
|
trackEvent: AnalyticsEventDispatcher<string>;
|
|
10
11
|
features: FeatureFlags;
|
|
12
|
+
flowRequestCache: RequestCache;
|
|
11
13
|
onPoll: OnPoll;
|
|
12
14
|
};
|
|
13
15
|
export declare const mapStepToComponent: ({ uid: rootUid, loadingState, features, trackEvent, onPoll, onBehavior, ...restProps }: StepMapperProps) => import("../components/step/StepDomainComponent").StepDomainComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Step as DFStep, Model, Schema, ValidationError } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import type { HttpClient } from '../../../types';
|
|
3
3
|
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../../features/events';
|
|
4
|
-
import type { Behavior, LocalValue, OnBehavior, OnPersistAsync, OnValueChange,
|
|
4
|
+
import type { Behavior, LocalValue, OnBehavior, OnPersistAsync, OnValueChange, OnComponentUpdate } from '../../types';
|
|
5
5
|
import type { GetErrorMessageFunctions, PersistAsyncConfig } from '../types';
|
|
6
6
|
export type MapperProps = {
|
|
7
7
|
stepLocalValue: LocalValue;
|
|
@@ -10,7 +10,7 @@ export type MapperProps = {
|
|
|
10
10
|
httpClient: HttpClient;
|
|
11
11
|
onBehavior: OnBehavior;
|
|
12
12
|
onValueChange: OnValueChange;
|
|
13
|
-
|
|
13
|
+
onComponentUpdate: OnComponentUpdate;
|
|
14
14
|
trackEvent: AnalyticsEventDispatcher;
|
|
15
15
|
logEvent: LoggingEventDispatcher;
|
|
16
16
|
registerSubmissionBehavior: (behavior: Behavior) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { HttpClient } from '../../types';
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
delete: (...requestParams: Parameters<HttpClient>) => boolean;
|
|
6
|
-
set: (...[input, init, response]: [...Parameters<HttpClient>, Promise<Response | null>]) => void;
|
|
7
|
-
clear: () => void;
|
|
2
|
+
export type RequestCache = {
|
|
3
|
+
get: (requestParams: Parameters<HttpClient>) => Promise<Response | null> | undefined;
|
|
4
|
+
set: (requestParams: Parameters<HttpClient>, responsePromise: Promise<Response | null>) => void;
|
|
8
5
|
};
|
|
9
|
-
export
|
|
6
|
+
export type RequestCacheEntries = readonly [Parameters<HttpClient>, Promise<Response | null>][];
|
|
7
|
+
export declare const makeRequestCacheWithParent: (parent: RequestCache | undefined) => RequestCache;
|
|
8
|
+
export declare const makeRequestCache: (initialValues?: RequestCacheEntries) => RequestCache;
|
|
9
|
+
export declare const normaliseRequestCache: (cache: RequestCache | RequestCacheEntries | undefined) => RequestCache;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Action, ActionBehavior, CopyBehavior, DismissBehavior, Icon, JsonElement, LinkBehavior, Margin, ModalBehavior, Model } from '@wise/dynamic-flow-types/spec';
|
|
1
|
+
import type { Action, ActionBehavior, CopyBehavior, DismissBehavior, Icon, JsonElement, LaunchConfig, LinkBehavior, Margin, ModalBehavior, Model } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import type { AlertComponent } from './components/AlertComponent';
|
|
3
3
|
import type { AllOfComponent } from './components/AllOfComponent';
|
|
4
4
|
import type { BooleanInputComponent } from './components/BooleanInputComponent';
|
|
@@ -42,7 +42,8 @@ import type { TabsComponent } from './components/TabsComponent';
|
|
|
42
42
|
import type { TextInputComponent } from './components/TextInputComponent';
|
|
43
43
|
import type { TupleComponent } from './components/TupleComponent';
|
|
44
44
|
import type { UploadInputComponent } from './components/UploadInputComponent';
|
|
45
|
-
|
|
45
|
+
import type { SubflowDomainComponent } from './components/SubflowDomainComponent';
|
|
46
|
+
export type DomainComponent = RootDomainComponent | StepDomainComponent | PersistAsyncComponent | AllOfComponent | BooleanInputComponent | ConstComponent | DateInputComponent | IntegerInputComponent | MultiSelectComponent | MultiUploadInputComponent | NumberInputComponent | ObjectComponent | RepeatableComponent | SelectInputComponent | TextInputComponent | TupleComponent | UploadInputComponent | AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | ContainerComponent | DecisionComponent | DividerComponent | ExternalConfirmationComponent | FormattedValueComponent | FormComponent | HeadingComponent | ImageComponent | InstructionsComponent | ListComponent | LoadingIndicatorComponent | MarkdownComponent | ModalLayoutComponent | ModalComponent | MoneyInputComponent | ParagraphComponent | ProgressComponent | ReviewComponent | SearchComponent | SectionComponent | StatusListComponent | SubflowDomainComponent | TabsComponent;
|
|
46
47
|
export type SchemaComponent = DomainComponent & {
|
|
47
48
|
kind: 'input';
|
|
48
49
|
};
|
|
@@ -67,9 +68,14 @@ export type CallToAction = {
|
|
|
67
68
|
href: string;
|
|
68
69
|
onClick: () => void;
|
|
69
70
|
};
|
|
70
|
-
export type Behavior = (ActionBehavior | CopyBehavior | DismissBehavior | LinkBehavior | ModalBehavior | NonMergingActionBehaviour | NullBehavior | RefreshBehavior | BackBehaviour) & {
|
|
71
|
+
export type Behavior = (ActionBehavior | CopyBehavior | DismissBehavior | LinkBehavior | ModalBehavior | NonMergingActionBehaviour | NullBehavior | RefreshBehavior | BackBehaviour | SubflowBehavior) & {
|
|
71
72
|
analytics?: Record<string, unknown>;
|
|
72
73
|
};
|
|
74
|
+
export type Presentation = {
|
|
75
|
+
type: 'modal';
|
|
76
|
+
} | {
|
|
77
|
+
type: 'push';
|
|
78
|
+
};
|
|
73
79
|
type NonMergingActionBehaviour = Omit<ActionBehavior, 'type'> & {
|
|
74
80
|
type: 'non-merging-action';
|
|
75
81
|
};
|
|
@@ -84,6 +90,14 @@ type RefreshBehavior = {
|
|
|
84
90
|
type: 'refresh';
|
|
85
91
|
url?: string;
|
|
86
92
|
};
|
|
93
|
+
export type SubflowBehavior = {
|
|
94
|
+
type: 'subflow';
|
|
95
|
+
referrerId: string;
|
|
96
|
+
launchConfig: LaunchConfig;
|
|
97
|
+
resultKey?: string;
|
|
98
|
+
onCompletion?: Behavior;
|
|
99
|
+
onError?: Behavior;
|
|
100
|
+
};
|
|
87
101
|
export type BaseComponent = {
|
|
88
102
|
kind: 'step' | 'input' | 'layout';
|
|
89
103
|
type: string;
|
|
@@ -160,7 +174,7 @@ export type BaseInputComponent<LV extends LocalValue> = BaseSchemaComponent<LV>
|
|
|
160
174
|
onBlur: () => void;
|
|
161
175
|
onFocus: () => void;
|
|
162
176
|
};
|
|
163
|
-
export type
|
|
177
|
+
export type OnComponentUpdate = () => void;
|
|
164
178
|
export type ScrollToTop = (behavior: ScrollBehavior) => void;
|
|
165
179
|
export type OnBehavior = (behavior: Behavior) => Promise<BehaviorController>;
|
|
166
180
|
export type BehaviorController = {
|