@wise/dynamic-flow-client 5.2.0 → 5.4.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.
- package/build/main.css +16 -2
- package/build/main.js +816 -440
- package/build/main.mjs +821 -445
- package/build/types/domain/components/FormattedValueComponent.d.ts +16 -0
- package/build/types/domain/components/RootDomainComponent.d.ts +11 -3
- package/build/types/domain/components/SelectInputComponent.d.ts +1 -2
- package/build/types/domain/components/SubflowDomainComponent.d.ts +16 -0
- package/build/types/domain/components/step/StepDomainComponent.d.ts +3 -3
- 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/objectSchemaToComponent/objectSchemaToFormattedValueComponent.d.ts +7 -0
- package/build/types/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts +25 -0
- package/build/types/domain/mappers/schema/persistAsyncSchemaToComponent.d.ts +25 -0
- package/build/types/domain/prefetching/request-cache.d.ts +7 -7
- package/build/types/domain/types.d.ts +18 -3
- package/build/types/flow/executeRequest.d.ts +39 -0
- package/build/types/flow/executeSubmission.d.ts +6 -33
- package/build/types/flow/getResponseType.d.ts +1 -1
- package/build/types/flow/getSafeHttpClient.d.ts +1 -0
- package/build/types/flow/handleErrorResponse.d.ts +3 -0
- package/build/types/flow/response-utils.d.ts +2 -1
- package/build/types/getSubflowCallbacks.d.ts +14 -0
- package/build/types/index.d.ts +7 -3
- package/build/types/renderers/mappers/formattedValueComponentToProps.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 +3 -11
- package/build/types/useDynamicFlow.d.ts +12 -0
- package/build/types/{useDynamicFlowCore.d.ts → useDynamicFlowController.d.ts} +3 -2
- package/build/types/useDynamicFlowModal.d.ts +16 -0
- package/build/types/utils/{scrollToTop.d.ts → getScrollToTop.d.ts} +1 -1
- package/package.json +22 -22
- package/build/types/DynamicFormCore.d.ts +0 -11
- package/build/types/flow/makeSubmissionRequest.d.ts +0 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import { SchemaOnChange } from '../features/schema-on-change/getSchemaOnChange';
|
|
3
|
+
import type { BaseSchemaComponent, InlineAlert, LocalValue, RepeatableSummary, UpdateComponent } from '../types';
|
|
4
|
+
export type FormattedValueComponent = BaseSchemaComponent<JsonElement> & {
|
|
5
|
+
type: 'formatted-value';
|
|
6
|
+
kind: 'input';
|
|
7
|
+
format: string;
|
|
8
|
+
alert?: InlineAlert;
|
|
9
|
+
errors: string[] | undefined;
|
|
10
|
+
value: JsonElement;
|
|
11
|
+
onChange: (newValue: JsonElement) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const createFormattedValueComponent: (props: Pick<FormattedValueComponent, "uid" | "schemaId" | "analyticsId" | "alert" | "control" | "description" | "errors" | "format" | "help" | "hidden" | "media" | "title" | "tags" | "value"> & {
|
|
14
|
+
summariser: (value: LocalValue | null) => RepeatableSummary;
|
|
15
|
+
schemaOnChange: SchemaOnChange | undefined;
|
|
16
|
+
}, updateComponent: UpdateComponent) => FormattedValueComponent;
|
|
@@ -3,13 +3,19 @@ import { AnalyticsEventDispatcher } from '../features/events';
|
|
|
3
3
|
import { BaseComponent, DomainComponent, LoadingState, LocalValue, SchemaComponent, ScrollToTop, UpdateComponent } 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';
|
|
6
8
|
export type RootDomainComponent = BaseComponent & {
|
|
7
9
|
type: 'root';
|
|
8
10
|
kind: 'step';
|
|
9
11
|
stepComponent: StepDomainComponent | null;
|
|
10
12
|
stepStack: StepDomainComponent[];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
subflow: SubflowDomainComponent | null;
|
|
14
|
+
backConfig: {
|
|
15
|
+
isNativeBackEnabled: boolean;
|
|
16
|
+
isFlowCancellable: boolean;
|
|
17
|
+
};
|
|
18
|
+
requestCache: RequestCache;
|
|
13
19
|
canPerformBack: () => boolean;
|
|
14
20
|
dismissAllModals: () => void;
|
|
15
21
|
dismissModal: () => void;
|
|
@@ -33,8 +39,10 @@ export type RootDomainComponent = BaseComponent & {
|
|
|
33
39
|
clearStack: () => void;
|
|
34
40
|
navigateBack: () => void;
|
|
35
41
|
getRefreshUrl: () => string | null;
|
|
42
|
+
addSubflow: (subflow: SubflowDomainComponent) => void;
|
|
43
|
+
closeSubflow: () => void;
|
|
36
44
|
};
|
|
37
45
|
export declare const createRootDomainComponent: (updateComponent: UpdateComponent, scrollToTop: ScrollToTop, backConfig: {
|
|
38
46
|
isNativeBackEnabled: boolean;
|
|
39
47
|
isFlowCancellable: boolean;
|
|
40
|
-
}) => RootDomainComponent;
|
|
48
|
+
}, 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';
|
|
4
|
+
import type { InlineAlert, SupportingValues, BaseInputComponent, LocalValue, Media, OnValueChange, RepeatableSummary, SchemaComponent, UpdateComponent } from '../types';
|
|
5
5
|
import type { IsInvalidCheck } from '../features/validation/value-checks';
|
|
6
|
-
import type { BaseInputComponent, LocalValue, Media, OnValueChange, RepeatableSummary, SchemaComponent, UpdateComponent } from '../types';
|
|
7
6
|
export type SelectInputComponent = BaseInputComponent<LocalValue | null> & {
|
|
8
7
|
type: 'select';
|
|
9
8
|
kind: 'input';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonElement, Request } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import { BaseComponent, UpdateComponent, Presentation } from '../types';
|
|
3
|
+
import { AnalyticsEventDispatcher } from '../features/events';
|
|
4
|
+
import { RequestCache } from '../prefetching/request-cache';
|
|
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">, updateComponent: UpdateComponent) => SubflowDomainComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BaseComponent, DomainComponent, LayoutComponent, LoadingState, LocalValue, OnBehavior, SchemaComponent, UpdateComponent } 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,7 +47,7 @@ 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
|
updateComponent: UpdateComponent;
|
|
@@ -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;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ObjectSchema } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import type { MapperProps, SchemaMapperProps } from '../types';
|
|
3
|
+
export declare const objectSchemaToFormattedValueComponent: (schemaMapperProps: SchemaMapperProps & {
|
|
4
|
+
schema: ObjectSchema & {
|
|
5
|
+
format: string;
|
|
6
|
+
};
|
|
7
|
+
}, mapperProps: MapperProps) => import("../../../components/FormattedValueComponent").FormattedValueComponent;
|
package/build/types/domain/mappers/schema/oneOfSchemaToComponent/oneOfSchemaToComponent.d.ts
CHANGED
|
@@ -471,6 +471,31 @@ export declare const oneOfSchemaToComponent: (schemaMapperProps: SchemaMapperPro
|
|
|
471
471
|
onUpload: (value: File | null) => Promise<void>;
|
|
472
472
|
} & {
|
|
473
473
|
kind: "input";
|
|
474
|
+
}) | (import("../../../types").BaseComponent & {
|
|
475
|
+
schemaId?: string;
|
|
476
|
+
isSchemaReferencedInStep?: boolean;
|
|
477
|
+
control?: string;
|
|
478
|
+
description?: string;
|
|
479
|
+
help?: string;
|
|
480
|
+
hidden: boolean;
|
|
481
|
+
media?: import("../../../types").Media;
|
|
482
|
+
title?: string;
|
|
483
|
+
tags?: string[];
|
|
484
|
+
getLocalValue: () => import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
485
|
+
getSubmittableValueSync: () => import("@wise/dynamic-flow-types/spec").Model;
|
|
486
|
+
getSummary: () => import("../../../types").RepeatableSummary;
|
|
487
|
+
getSubmittableValue: () => Promise<import("@wise/dynamic-flow-types/spec").Model>;
|
|
488
|
+
validate: () => boolean;
|
|
489
|
+
} & {
|
|
490
|
+
type: "formatted-value";
|
|
491
|
+
kind: "input";
|
|
492
|
+
format: string;
|
|
493
|
+
alert?: import("../../../types").InlineAlert;
|
|
494
|
+
errors: string[] | undefined;
|
|
495
|
+
value: import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
496
|
+
onChange: (newValue: import("@wise/dynamic-flow-types/spec").JsonElement) => void;
|
|
497
|
+
} & {
|
|
498
|
+
kind: "input";
|
|
474
499
|
}) | (import("../../../types").BaseComponent & {
|
|
475
500
|
schemaId?: string;
|
|
476
501
|
isSchemaReferencedInStep?: boolean;
|
|
@@ -484,6 +484,31 @@ export declare const persistAsyncSchemaToComponent: (schemaMapperProps: SchemaMa
|
|
|
484
484
|
onUpload: (value: File | null) => Promise<void>;
|
|
485
485
|
} & {
|
|
486
486
|
kind: "input";
|
|
487
|
+
}) | (import("../../types").BaseComponent & {
|
|
488
|
+
schemaId?: string;
|
|
489
|
+
isSchemaReferencedInStep?: boolean;
|
|
490
|
+
control?: string;
|
|
491
|
+
description?: string;
|
|
492
|
+
help?: string;
|
|
493
|
+
hidden: boolean;
|
|
494
|
+
media?: import("../../types").Media;
|
|
495
|
+
title?: string;
|
|
496
|
+
tags?: string[];
|
|
497
|
+
getLocalValue: () => import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
498
|
+
getSubmittableValueSync: () => import("@wise/dynamic-flow-types/spec").Model;
|
|
499
|
+
getSummary: () => import("../../types").RepeatableSummary;
|
|
500
|
+
getSubmittableValue: () => Promise<import("@wise/dynamic-flow-types/spec").Model>;
|
|
501
|
+
validate: () => boolean;
|
|
502
|
+
} & {
|
|
503
|
+
type: "formatted-value";
|
|
504
|
+
kind: "input";
|
|
505
|
+
format: string;
|
|
506
|
+
alert?: import("../../types").InlineAlert;
|
|
507
|
+
errors: string[] | undefined;
|
|
508
|
+
value: import("@wise/dynamic-flow-types/spec").JsonElement;
|
|
509
|
+
onChange: (newValue: import("@wise/dynamic-flow-types/spec").JsonElement) => void;
|
|
510
|
+
} & {
|
|
511
|
+
kind: "input";
|
|
487
512
|
}) | (import("../../types").BaseComponent & {
|
|
488
513
|
schemaId?: string;
|
|
489
514
|
isSchemaReferencedInStep?: boolean;
|
|
@@ -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';
|
|
@@ -10,6 +10,7 @@ import type { ContainerComponent } from './components/ContainerComponent';
|
|
|
10
10
|
import type { DateInputComponent } from './components/DateInputComponent';
|
|
11
11
|
import type { DecisionComponent } from './components/DecisionComponent';
|
|
12
12
|
import type { DividerComponent } from './components/DividerComponent';
|
|
13
|
+
import type { FormattedValueComponent } from './components/FormattedValueComponent';
|
|
13
14
|
import type { FormComponent } from './components/FormComponent';
|
|
14
15
|
import type { HeadingComponent } from './components/HeadingComponent';
|
|
15
16
|
import type { ImageComponent } from './components/ImageComponent';
|
|
@@ -41,7 +42,8 @@ import type { TabsComponent } from './components/TabsComponent';
|
|
|
41
42
|
import type { TextInputComponent } from './components/TextInputComponent';
|
|
42
43
|
import type { TupleComponent } from './components/TupleComponent';
|
|
43
44
|
import type { UploadInputComponent } from './components/UploadInputComponent';
|
|
44
|
-
|
|
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;
|
|
45
47
|
export type SchemaComponent = DomainComponent & {
|
|
46
48
|
kind: 'input';
|
|
47
49
|
};
|
|
@@ -66,9 +68,14 @@ export type CallToAction = {
|
|
|
66
68
|
href: string;
|
|
67
69
|
onClick: () => void;
|
|
68
70
|
};
|
|
69
|
-
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) & {
|
|
70
72
|
analytics?: Record<string, unknown>;
|
|
71
73
|
};
|
|
74
|
+
export type Presentation = {
|
|
75
|
+
type: 'modal';
|
|
76
|
+
} | {
|
|
77
|
+
type: 'push';
|
|
78
|
+
};
|
|
72
79
|
type NonMergingActionBehaviour = Omit<ActionBehavior, 'type'> & {
|
|
73
80
|
type: 'non-merging-action';
|
|
74
81
|
};
|
|
@@ -83,6 +90,14 @@ type RefreshBehavior = {
|
|
|
83
90
|
type: 'refresh';
|
|
84
91
|
url?: string;
|
|
85
92
|
};
|
|
93
|
+
export type SubflowBehavior = {
|
|
94
|
+
type: 'subflow';
|
|
95
|
+
referrerId: string;
|
|
96
|
+
launchConfig: LaunchConfig;
|
|
97
|
+
resultKey?: string;
|
|
98
|
+
onCompletion?: Behavior;
|
|
99
|
+
onError?: Behavior;
|
|
100
|
+
};
|
|
86
101
|
export type BaseComponent = {
|
|
87
102
|
kind: 'step' | 'input' | 'layout';
|
|
88
103
|
type: string;
|
|
@@ -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>;
|
|
@@ -1,42 +1,15 @@
|
|
|
1
|
-
import type { Action,
|
|
1
|
+
import type { Action, Model, Request } from '@wise/dynamic-flow-types/spec';
|
|
2
2
|
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/features/events';
|
|
3
|
-
import {
|
|
4
|
-
import type { Behavior } from '../domain/types';
|
|
3
|
+
import { RequestCache } from '../domain/prefetching/request-cache';
|
|
5
4
|
import { HttpClient } from '../types';
|
|
6
|
-
|
|
7
|
-
type: 'complete';
|
|
8
|
-
result: Model;
|
|
9
|
-
} | {
|
|
10
|
-
type: 'replace-step';
|
|
11
|
-
step: Step;
|
|
12
|
-
etag: string | null;
|
|
13
|
-
} | {
|
|
14
|
-
type: 'error';
|
|
15
|
-
body?: {
|
|
16
|
-
analytics?: ErrorResponseBody['analytics'];
|
|
17
|
-
errors?: Step['errors'];
|
|
18
|
-
};
|
|
19
|
-
httpError?: {
|
|
20
|
-
message?: string;
|
|
21
|
-
statusCode?: number;
|
|
22
|
-
};
|
|
23
|
-
} | {
|
|
24
|
-
type: 'refresh';
|
|
25
|
-
body: {
|
|
26
|
-
refreshUrl: string;
|
|
27
|
-
errors?: Step['errors'];
|
|
28
|
-
};
|
|
29
|
-
} | {
|
|
30
|
-
type: 'behavior';
|
|
31
|
-
behavior: Behavior;
|
|
32
|
-
};
|
|
5
|
+
import { Command } from './executeRequest';
|
|
33
6
|
export declare const executeSubmission: (props: {
|
|
34
7
|
action: Action;
|
|
35
8
|
model: Model;
|
|
36
9
|
isInitial: boolean;
|
|
37
|
-
requestCache:
|
|
10
|
+
requestCache: RequestCache;
|
|
38
11
|
httpClient: HttpClient;
|
|
39
|
-
trackEvent: AnalyticsEventDispatcher
|
|
12
|
+
trackEvent: AnalyticsEventDispatcher<string>;
|
|
40
13
|
logEvent: LoggingEventDispatcher;
|
|
41
14
|
}) => Promise<Command>;
|
|
42
|
-
export
|
|
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>;
|
|
@@ -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;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OnBehavior, SubflowBehavior } from './domain/types';
|
|
2
|
+
import { AnalyticsEventDispatcher } from './domain/features/events';
|
|
3
|
+
import { SubflowDomainComponent } from './domain/components/SubflowDomainComponent';
|
|
4
|
+
type Props = {
|
|
5
|
+
behavior: SubflowBehavior;
|
|
6
|
+
onBehavior: OnBehavior;
|
|
7
|
+
close: () => void;
|
|
8
|
+
onError: (error: unknown, analytics?: Record<string, unknown>, status?: number) => void;
|
|
9
|
+
onEvent: AnalyticsEventDispatcher<string>;
|
|
10
|
+
restart: () => void;
|
|
11
|
+
};
|
|
12
|
+
type SubflowCallbacks = Pick<SubflowDomainComponent, 'onCompletion' | 'onError' | 'onEvent' | 'onCancellation'>;
|
|
13
|
+
export declare const getSubflowCallbacks: ({ behavior, close, restart, onBehavior, onError, onEvent, }: Props) => SubflowCallbacks;
|
|
14
|
+
export {};
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export { makeHttpClient } from './common/makeHttpClient';
|
|
2
2
|
export { default as translations } from './i18n';
|
|
3
|
-
export type { DynamicFlowCoreProps as DynamicFlowProps
|
|
4
|
-
export { DynamicFlowCore as DynamicFlow } from './DynamicFlowCore';
|
|
5
|
-
export { DynamicFormCore as DynamicForm } from './DynamicFormCore';
|
|
3
|
+
export type { DynamicFlowCoreProps as DynamicFlowProps } from './types';
|
|
6
4
|
export { findRendererPropsByType } from './renderers/utils';
|
|
5
|
+
export { useDynamicFlow } from './useDynamicFlow';
|
|
6
|
+
export { useDynamicFlowModal } from './useDynamicFlowModal';
|
|
7
|
+
export { DynamicFlowCore as DynamicFlow } from './DynamicFlowCore';
|
|
8
|
+
export { makeRequestCache } from './domain/prefetching/request-cache';
|
|
9
|
+
export type { EventName } from './domain/features/events';
|
|
10
|
+
export { eventNames } from './domain/features/eventNames';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FormattedValueRendererProps } from '@wise/dynamic-flow-types/renderers';
|
|
2
|
+
import type { FormattedValueComponent } from '../../domain/components/FormattedValueComponent';
|
|
3
|
+
import type { RendererMapperProps } from './componentToRendererProps';
|
|
4
|
+
export declare const formattedValueComponentToProps: (component: FormattedValueComponent, rendererMapperProps: RendererMapperProps) => FormattedValueRendererProps;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SubflowRendererProps } from '@wise/dynamic-flow-types/renderers';
|
|
2
|
+
import { SubflowDomainComponent } from '../../domain/components/SubflowDomainComponent';
|
|
3
|
+
import { RendererMapperProps } from './componentToRendererProps';
|
|
4
|
+
export declare const subflowComponentToRendererProps: (component: SubflowDomainComponent, rendererMapperProps: RendererMapperProps) => SubflowRendererProps;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DynamicFlowCoreProps } from '../types';
|
|
2
|
+
type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
3
|
+
export type DynamicFlowWiseProps = MakeOptional<DynamicFlowCoreProps, 'renderers' | 'onLink'> & {
|
|
4
|
+
onAnalytics?: DynamicFlowWiseProps['onEvent'];
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* This component is only used in tests.
|
|
8
|
+
*/
|
|
9
|
+
export declare function DynamicFlowWiseModal(props: DynamicFlowWiseProps & {
|
|
10
|
+
open?: boolean;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { DynamicFlowWiseProps } from './DynamicFlowWise';
|
|
2
|
+
export declare const getMergedTestRenderers: (props: DynamicFlowWiseProps) => (import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").CoreContainerRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").RootRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").StepRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").AlertRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").BoxRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ColumnsRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").DecisionRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").DividerRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ExternalConfirmationRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").FormattedValueRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").FormRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").HeadingRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").InstructionsRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ListRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").LoadingIndicatorRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").MarkdownRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ImageRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ModalLayoutRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ModalRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ParagraphRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ProgressRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ReviewRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").SearchRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").StatusListRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").CheckboxInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").ButtonRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").DateInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").HiddenRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").IntegerInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").MoneyInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").NumberInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").RepeatableRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").FormSectionRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").SelectInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").SectionRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").SubflowRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").MultiSelectInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").TabsRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").TextInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").UploadInputRendererProps> | import("@wise/dynamic-flow-types/renderers").Renderer<import("@wise/dynamic-flow-types/renderers").MultiUploadInputRendererProps>)[];
|
package/build/types/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Renderers } from '@wise/dynamic-flow-types/renderers';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Model, Step } from '@wise/dynamic-flow-types/spec';
|
|
3
3
|
import type { AnalyticsEventHandler, LoggingEventHandler } from './domain/features/events';
|
|
4
|
+
import { RequestCache, RequestCacheEntries } from './domain/prefetching/request-cache';
|
|
4
5
|
export type DynamicFlowCoreProps = {
|
|
5
6
|
flowId: string;
|
|
6
7
|
initialAction?: InitialAction;
|
|
@@ -8,6 +9,7 @@ export type DynamicFlowCoreProps = {
|
|
|
8
9
|
httpClient: HttpClient;
|
|
9
10
|
renderers: Renderers;
|
|
10
11
|
features?: Record<string, unknown>;
|
|
12
|
+
requestCache?: RequestCache | RequestCacheEntries;
|
|
11
13
|
onCancellation?: () => void;
|
|
12
14
|
onCompletion: (result: Model) => void;
|
|
13
15
|
onCopy?: (copiedString: string | null) => void;
|
|
@@ -16,16 +18,6 @@ export type DynamicFlowCoreProps = {
|
|
|
16
18
|
onLog?: LoggingEventHandler;
|
|
17
19
|
onLink: (url: string) => boolean;
|
|
18
20
|
};
|
|
19
|
-
export type DynamicFormController = {
|
|
20
|
-
/**
|
|
21
|
-
* Returns the current value of the form, even if it doesn't pass validation.
|
|
22
|
-
*/
|
|
23
|
-
getValue: () => Promise<JsonElement>;
|
|
24
|
-
/**
|
|
25
|
-
* triggers validation in every UI component and returns whether or not the current value is valid.
|
|
26
|
-
*/
|
|
27
|
-
validate: () => boolean;
|
|
28
|
-
};
|
|
29
21
|
export type InitialAction = {
|
|
30
22
|
id?: string;
|
|
31
23
|
url: string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DynamicFlowCoreProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* @experimental This hook may be changed or removed in the future without notice.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useDynamicFlow(props: DynamicFlowCoreProps): {
|
|
6
|
+
controller: {
|
|
7
|
+
getSubmittableValue: () => Promise<import("@wise/dynamic-flow-types/spec").JsonElement>;
|
|
8
|
+
validate: () => boolean;
|
|
9
|
+
cancel: () => void;
|
|
10
|
+
};
|
|
11
|
+
view: import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
};
|
|
@@ -5,10 +5,11 @@ import type { DynamicFlowCoreProps } from './types';
|
|
|
5
5
|
type UseDynamicFlowCoreProps = Omit<DynamicFlowCoreProps, 'renderers' | 'features'> & {
|
|
6
6
|
features: FeatureFlags;
|
|
7
7
|
onValueChange?: OnValueChange;
|
|
8
|
-
scrollToTop
|
|
8
|
+
scrollToTop: ScrollToTop;
|
|
9
9
|
onLink: (url: string) => boolean;
|
|
10
10
|
};
|
|
11
|
-
export declare function
|
|
11
|
+
export declare function useDynamicFlowController(props: UseDynamicFlowCoreProps): {
|
|
12
12
|
rootComponent: RootDomainComponent;
|
|
13
|
+
cancel: () => void;
|
|
13
14
|
};
|
|
14
15
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { JsonElement } from '@wise/dynamic-flow-types/spec';
|
|
2
|
+
import { DynamicFlowProps } from '.';
|
|
3
|
+
export declare const useDynamicFlowModal: (props: DynamicFlowProps) => {
|
|
4
|
+
modal: {
|
|
5
|
+
body: import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
open: boolean;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onUnmount: () => void;
|
|
9
|
+
};
|
|
10
|
+
controller: {
|
|
11
|
+
getSubmittableValue: () => Promise<JsonElement>;
|
|
12
|
+
validate: () => boolean;
|
|
13
|
+
cancel: () => void;
|
|
14
|
+
};
|
|
15
|
+
view: import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ScrollToTop } from '../domain/types';
|
|
1
|
+
import type { ScrollToTop } from '../domain/types';
|
|
2
2
|
export declare const getScrollToTop: (normalisedFlowId: string, className: string) => ScrollToTop;
|