@wise/dynamic-flow-client 2.8.1 → 2.8.3
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.js +14 -11
- package/build/main.min.js +1 -1
- package/build/types/index.d.ts +1 -1
- package/build/types/legacy/common/contexts/eventsContext/EventsContext.d.ts +1 -1
- package/build/types/legacy/common/contexts/featureContext/FeatureContext.d.ts +1 -1
- package/build/types/legacy/common/contexts/httpClientContext/HttpClientContext.d.ts +1 -1
- package/build/types/legacy/common/contexts/logContext/LogContext.d.ts +1 -1
- package/build/types/legacy/dynamicFlow/DynamicFlow.d.ts +1 -1
- package/build/types/legacy/dynamicFlow/stories/fixtureHttpClient.d.ts +1 -1
- package/build/types/legacy/dynamicFlow/utils/responseParsers/response-parsers.d.ts +1 -1
- package/build/types/legacy/dynamicFlow/utils/useLoader.d.ts +1 -1
- package/build/types/legacy/jsonSchemaForm/JsonSchemaForm.d.ts +1 -1
- package/build/types/legacy/jsonSchemaForm/oneOfSchema/utils.d.ts +1 -1
- package/build/types/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.d.ts +1 -1
- package/build/types/legacy/layout/search/useSearch.d.ts +1 -1
- package/build/types/legacy/step/cameraStep/cameraCapture/CameraCapture.d.ts +1 -1
- package/build/types/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.d.ts +1 -1
- package/build/types/legacy/step/cameraStep/cameraCapture/tracking/index.d.ts +1 -1
- package/build/types/legacy/test-utils/DynamicFlowProviders.d.ts +1 -1
- package/build/types/legacy/test-utils/legacy-utils.d.ts +1 -1
- package/build/types/revamp/DynamicFlowRevamp.d.ts +2 -6
- package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +8 -0
- package/build/types/revamp/domain/components/NumberInputComponent.d.ts +8 -0
- package/build/types/revamp/domain/components/ObjectComponent.d.ts +2 -1
- package/build/types/revamp/domain/components/TextInputComponent.d.ts +4 -20
- package/build/types/revamp/domain/components/utils/component-utils.d.ts +12 -0
- package/build/types/revamp/domain/events/getAnalyticsEventDispatcher.d.ts +9 -0
- package/build/types/revamp/domain/events/getLogggingEventDispatcher.d.ts +4 -0
- package/build/types/revamp/domain/events/index.d.ts +2 -0
- package/build/types/revamp/domain/mappers/mapSchemaToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/schema/integerSchemaToComponent.d.ts +5 -0
- package/build/types/revamp/domain/mappers/schema/numberSchemaToComponent.d.ts +5 -0
- package/build/types/revamp/domain/mappers/schema/objectSchemaToComponent.d.ts +1 -1
- package/build/types/revamp/domain/mappers/schema/stringSchemaToComponent.d.ts +1 -8
- package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +21 -0
- package/build/types/revamp/domain/mappers/schema/types.d.ts +5 -1
- package/build/types/revamp/domain/mappers/types.d.ts +4 -3
- package/build/types/revamp/domain/mappers/utils/getAutocompleteString.d.ts +2 -0
- package/build/types/revamp/domain/types.d.ts +16 -2
- package/build/types/revamp/domain/validation/getModelValidationErrors.d.ts +6 -0
- package/build/types/revamp/domain/validation/spec-utils.d.ts +11 -0
- package/build/types/revamp/{utils → domain/validation}/validateComponents.d.ts +1 -1
- package/build/types/revamp/domain/validation/value-checks.d.ts +13 -0
- package/build/types/revamp/dynamic-flow-types.d.ts +38 -0
- package/build/types/revamp/renderers/mappers/integerInputComponentToProps.d.ts +3 -0
- package/build/types/revamp/renderers/mappers/numberInputComponentToProps.d.ts +3 -0
- package/build/types/revamp/renderers/mappers/textInputComponentToProps.d.ts +1 -1
- package/build/types/revamp/renderers/types.d.ts +18 -4
- package/build/types/revamp/step/Step.d.ts +4 -1
- package/build/types/revamp/utils/type-utils.d.ts +3 -1
- package/build/types/revamp/wise/renderers/IntegerInputRenderer.d.ts +3 -0
- package/build/types/revamp/wise/renderers/NumberInputRenderer.d.ts +3 -0
- package/package.json +1 -1
- package/build/types/revamp/domain/mappers/utils/value-checks.d.ts +0 -10
- /package/build/types/{dynamic-flow-types.d.ts → legacy/dynamic-flow-types.d.ts} +0 -0
package/build/types/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export { DynamicLayout as Layout } from './legacy/layout';
|
|
|
6
6
|
export { isValidSchema } from './legacy/common/validators';
|
|
7
7
|
export { default as translations } from './i18n';
|
|
8
8
|
export * from './legacy/dynamicFlow/DynamicFlow';
|
|
9
|
-
export type { DynamicFlowProps, InitialAction } from './dynamic-flow-types';
|
|
9
|
+
export type { DynamicFlowProps, InitialAction } from './legacy/dynamic-flow-types';
|
|
10
10
|
export type { Step } from '@wise/dynamic-flow-types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { Feature } from '
|
|
2
|
+
import type { Feature } from '../../../dynamic-flow-types';
|
|
3
3
|
import type { FeatureName } from '../../constants/FeatureName';
|
|
4
4
|
type FeatureContextProviderProps = {
|
|
5
5
|
features: Feature[] | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { LogLevel, LogEventHandler } from '
|
|
2
|
+
import type { LogLevel, LogEventHandler } from '../../../dynamic-flow-types';
|
|
3
3
|
export type LogTitle = 'Invalid schema or model' | 'Invalid model on change' | 'Invalid response' | 'Action supressed' | 'Deprecation warning' | 'Deprecated schema' | 'Error fetching';
|
|
4
4
|
type LogFunction = (title: LogTitle, description: string, extra?: Record<string, unknown>) => void;
|
|
5
5
|
export declare const getLogger: (level: LogLevel, onLog: LogEventHandler, flowId?: string | undefined, stepId?: string | undefined) => LogFunction;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ActionResponseBody, ErrorResponseBody, Step } from '@wise/dynamic-flow-types';
|
|
2
|
-
import type { DynamicFlowProps } from '
|
|
2
|
+
import type { DynamicFlowProps } from '../../../dynamic-flow-types';
|
|
3
3
|
type ParsedBody = {
|
|
4
4
|
type: 'exit';
|
|
5
5
|
result: Parameters<DynamicFlowProps['onCompletion']>[0];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { DynamicFlowProps } from '
|
|
2
|
+
import type { DynamicFlowProps } from '../../dynamic-flow-types';
|
|
3
3
|
type LoadingState = 'idle' | 'initial' | 'refresh' | 'submission';
|
|
4
4
|
export declare function useLoader(loaderConfig: DynamicFlowProps['loaderConfig'], initialState: LoadingState): {
|
|
5
5
|
isLoading: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FormErrors, Model, Schema } from '@wise/dynamic-flow-types';
|
|
2
|
-
import type { EventHandler, LogEventHandler } from '
|
|
2
|
+
import type { EventHandler, LogEventHandler } from '../dynamic-flow-types';
|
|
3
3
|
import type { OnPersistAsync } from '../dynamicFlow/DynamicFlowTypes';
|
|
4
4
|
declare function JsonSchemaForm(props: JsonSchemaFormProps): JSX.Element;
|
|
5
5
|
export type OnChange = (parameters: OnChangeProps) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Model, ObjectModel, OneOfSchema, OneOfObjectSchema } from '@wise/dynamic-flow-types';
|
|
1
|
+
import type { Model, ObjectModel, OneOfSchema, OneOfObjectSchema } from '@wise/dynamic-flow-types';
|
|
2
2
|
export declare const getActiveSchemaIndex: (schema: OneOfSchema, model: Model) => number | null;
|
|
3
3
|
export declare const getValidIndexFromValue: (schema: OneOfSchema, value: Model | undefined) => number;
|
|
4
4
|
export declare function getBestMatchingSchemaIndexForValue(schema: OneOfObjectSchema, value: ObjectModel): number | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UploadProps } from '@transferwise/components/build/types/upload/Upload';
|
|
2
2
|
import type { PersistAsync } from '@wise/dynamic-flow-types';
|
|
3
|
-
import type { HttpClient } from '
|
|
3
|
+
import type { HttpClient } from '../../../dynamic-flow-types';
|
|
4
4
|
type Props = UploadProps & {
|
|
5
5
|
id: string;
|
|
6
6
|
httpClient: HttpClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SearchConfig, SearchResult } from '@wise/dynamic-flow-types';
|
|
2
2
|
export declare const useSearch: (defaultSearchConfig: SearchConfig) => {
|
|
3
|
-
status: "
|
|
3
|
+
status: "success" | "loading" | "error" | "idle";
|
|
4
4
|
results: SearchResult[];
|
|
5
5
|
search: (query: string, { url, method, param }?: SearchConfig) => Promise<void>;
|
|
6
6
|
};
|
package/build/types/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventHandler } from '
|
|
1
|
+
import type { EventHandler } from '../../../../dynamic-flow-types';
|
|
2
2
|
export declare const useFullScreenOrientationLock: (shouldLockOrientation: boolean, onEvent: EventHandler | undefined) => {
|
|
3
3
|
enterFullScreen: () => void;
|
|
4
4
|
exitFullScreen: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CameraDirection } from '@wise/dynamic-flow-types';
|
|
2
|
-
import type { EventHandler, EventName } from '
|
|
2
|
+
import type { EventHandler, EventName } from '../../../../dynamic-flow-types';
|
|
3
3
|
export declare const trackCameraError: (message: EventName, onEvent: EventHandler | undefined, error: string | DOMException) => void | undefined;
|
|
4
4
|
export declare const trackCameraFeedStarted: (onEvent: EventHandler | undefined, props: {
|
|
5
5
|
direction?: CameraDirection;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { EventHandler, LogEventHandler } from '
|
|
2
|
+
import type { EventHandler, LogEventHandler } from '../dynamic-flow-types';
|
|
3
3
|
type DynamicFlowProvidersProps = {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
onLog?: LogEventHandler;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactWrapper } from 'enzyme';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
|
-
import type { EventHandler, LogEventHandler } from '
|
|
3
|
+
import type { EventHandler, LogEventHandler } from '../dynamic-flow-types';
|
|
4
4
|
declare const getMockFetchPromise: (status: number, jsonFn: () => void, delay: number, signal?: AbortSignal | null) => Promise<Response>;
|
|
5
5
|
declare const wait: (t: number) => Promise<unknown>;
|
|
6
6
|
declare function mountWithProviders(component: ReactNode, locale?: string, messages?: Record<string, unknown>, baseUrl?: string, onEvent?: EventHandler, onLog?: LogEventHandler): ReactWrapper;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
type Props = Omit<DynamicFlowProps, 'initialStep'> & {
|
|
4
|
-
initialStep?: DFStep;
|
|
5
|
-
};
|
|
6
|
-
declare function DynamicFlowRevamp({ initialStep, onError }: Props): JSX.Element;
|
|
1
|
+
import type { DynamicFlowProps } from './dynamic-flow-types';
|
|
2
|
+
declare function DynamicFlowRevamp(props: DynamicFlowProps): JSX.Element;
|
|
7
3
|
export default DynamicFlowRevamp;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputComponent, UpdateComponent } from '../types';
|
|
2
|
+
import type { IsInvalidCheck } from '../validation/value-checks';
|
|
3
|
+
export type IntegerInputComponent = InputComponent<number> & {
|
|
4
|
+
type: 'integer';
|
|
5
|
+
};
|
|
6
|
+
export declare const createIntegerInputComponent: (integerInputProps: Pick<IntegerInputComponent, "description" | "disabled" | "title" | "placeholder" | "control" | "id" | "errors" | "value" | "autoComplete" | "uid"> & {
|
|
7
|
+
checks: IsInvalidCheck<number | null>[];
|
|
8
|
+
}, updateComponent: UpdateComponent) => IntegerInputComponent;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputComponent, UpdateComponent } from '../types';
|
|
2
|
+
import type { IsInvalidCheck } from '../validation/value-checks';
|
|
3
|
+
export type NumberInputComponent = InputComponent<number> & {
|
|
4
|
+
type: 'number';
|
|
5
|
+
};
|
|
6
|
+
export declare const createNumberInputComponent: (numberInputProps: Pick<NumberInputComponent, "description" | "disabled" | "title" | "placeholder" | "control" | "id" | "errors" | "value" | "autoComplete" | "uid"> & {
|
|
7
|
+
checks: IsInvalidCheck<number | null>[];
|
|
8
|
+
}, updateComponent: UpdateComponent) => NumberInputComponent;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Model } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { BaseComponent, StepComponent } from '../types';
|
|
3
|
-
export type ObjectComponent = BaseComponent<Record<string, Model
|
|
3
|
+
export type ObjectComponent = Omit<BaseComponent<Record<string, Model>>, 'getValue'> & {
|
|
4
4
|
type: 'object';
|
|
5
5
|
title?: string;
|
|
6
6
|
description?: string;
|
|
7
7
|
componentMap: Record<string, StepComponent>;
|
|
8
8
|
getChildren: () => StepComponent[];
|
|
9
|
+
getValue: () => Record<string, Model>;
|
|
9
10
|
};
|
|
10
11
|
export declare const createObjectComponent: (objectProps: {
|
|
11
12
|
uid: string;
|
|
@@ -1,24 +1,8 @@
|
|
|
1
|
-
import type { StringSchemaFormat } from '@wise/dynamic-flow-types/build/next';
|
|
2
1
|
import type { InputComponent, UpdateComponent } from '../types';
|
|
3
|
-
|
|
2
|
+
import type { IsInvalidCheck } from '../validation/value-checks';
|
|
3
|
+
export type TextInputComponent = InputComponent<string> & {
|
|
4
4
|
type: 'text';
|
|
5
|
-
title?: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
placeholder?: string;
|
|
8
|
-
control?: string;
|
|
9
|
-
format?: 'date';
|
|
10
|
-
value: string | null;
|
|
11
|
-
errors: string[];
|
|
12
|
-
onChange: (value: string | null) => void;
|
|
13
5
|
};
|
|
14
|
-
export declare const createTextInputComponent: (textInputProps: {
|
|
15
|
-
|
|
16
|
-
id: string;
|
|
17
|
-
title?: string | undefined;
|
|
18
|
-
description?: string | undefined;
|
|
19
|
-
placeholder?: string | undefined;
|
|
20
|
-
control?: string | undefined;
|
|
21
|
-
format?: StringSchemaFormat | undefined;
|
|
22
|
-
value: string | null;
|
|
23
|
-
validate: (value: string | null) => string[];
|
|
6
|
+
export declare const createTextInputComponent: (textInputProps: Pick<TextInputComponent, "description" | "disabled" | "title" | "placeholder" | "control" | "id" | "errors" | "value" | "autoComplete" | "uid"> & {
|
|
7
|
+
checks: IsInvalidCheck<string | null>[];
|
|
24
8
|
}, updateComponent: UpdateComponent) => TextInputComponent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StepComponent, UpdateComponent } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Helper function to update a component.
|
|
4
|
+
*
|
|
5
|
+
* `updateComponent` is generic, meaning we have to specify the type of the draft whenever we use it. This function takes
|
|
6
|
+
* the component uid and type, and returns a typed function that will update the component without the need to type assert.
|
|
7
|
+
*
|
|
8
|
+
* @param uid uid of the component
|
|
9
|
+
* @param updateComponent the updateComponent function that will update the component with the given uid
|
|
10
|
+
* @returns a function that accepts a function that will update the component
|
|
11
|
+
*/
|
|
12
|
+
export declare const getInputUpdateFunction: <C extends StepComponent>(uid: string, updateComponent: UpdateComponent) => (updateFn: (component: C) => void) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Step } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
export type AnalyticsEventHandler = (eventName: string, properties?: Record<string, unknown>) => void;
|
|
3
|
+
export type AnalyticsEventDispatcher = (eventName: EventName, properties?: Record<string, unknown>) => void;
|
|
4
|
+
export declare const getAnalyticsEventDispatcher: ({ flowId, step, onEvent, }: {
|
|
5
|
+
flowId: string;
|
|
6
|
+
step?: Step | null | undefined;
|
|
7
|
+
onEvent?: AnalyticsEventHandler | undefined;
|
|
8
|
+
}) => AnalyticsEventDispatcher;
|
|
9
|
+
export type EventName = 'Flow Started' | 'Flow Completed' | 'Step Shown' | 'Action Triggered' | 'Action Succeeded' | 'Action Failed' | 'Refresh Triggered' | 'Refresh Succeeded' | 'Refresh Failed' | 'PersistAsync Triggered' | 'PersistAsync Succeeded' | 'PersistAsync Failed' | 'ValidationAsync Triggered' | 'ValidationAsync Succeeded' | 'ValidationAsync Failed' | 'Search Started' | 'Search Result Selected';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type LogLevel = 'info' | 'warning' | 'error';
|
|
2
|
+
export type LoggingEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
|
|
3
|
+
export type LoggingEventDispatcher = (level: LogLevel, message: string, extra?: Record<string, unknown>) => void;
|
|
4
|
+
export declare const getLoggingEventDispatcher: (onLog?: LoggingEventHandler) => LoggingEventDispatcher;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StepComponent } from '../types';
|
|
2
2
|
import type { MapperProps, SchemaMapperProps } from './schema/types';
|
|
3
|
-
export declare const mapSchemaToComponent: (uid: string,
|
|
3
|
+
export declare const mapSchemaToComponent: (uid: string, schemaMapperProps: SchemaMapperProps, mapperProps: MapperProps) => StepComponent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MapperProps, SchemaMapperProps } from './types';
|
|
2
|
+
import type { IntegerSchema } from '@wise/dynamic-flow-types/build/next';
|
|
3
|
+
export declare const integerSchemaToComponent: (uid: string, schemaMapperProps: SchemaMapperProps & {
|
|
4
|
+
schema: IntegerSchema;
|
|
5
|
+
}, mapperProps: MapperProps) => import("../../components/IntegerInputComponent").IntegerInputComponent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MapperProps, SchemaMapperProps } from './types';
|
|
2
|
+
import type { NumberSchema } from '@wise/dynamic-flow-types/build/next';
|
|
3
|
+
export declare const numberSchemaToComponent: (uid: string, schemaMapperProps: SchemaMapperProps & {
|
|
4
|
+
schema: NumberSchema;
|
|
5
|
+
}, mapperProps: MapperProps) => import("../../components/NumberInputComponent").NumberInputComponent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ObjectSchema } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { MapperProps, SchemaMapperProps } from './types';
|
|
3
|
-
export declare const objectSchemaToComponent: (uid: string, { schema, model }: SchemaMapperProps & {
|
|
3
|
+
export declare const objectSchemaToComponent: (uid: string, { schema, model, validationErrors }: SchemaMapperProps & {
|
|
4
4
|
schema: ObjectSchema;
|
|
5
5
|
}, mapperProps: MapperProps) => import("../../components/ObjectComponent").ObjectComponent;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import type { StringSchema } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { MapperProps, SchemaMapperProps } from './types';
|
|
3
|
-
|
|
4
|
-
export declare const stringSchemaToComponent: (uid: string, { schema, model, required }: SchemaMapperProps & {
|
|
3
|
+
export declare const stringSchemaToComponent: (uid: string, schemaMapperProps: SchemaMapperProps & {
|
|
5
4
|
schema: StringSchema;
|
|
6
5
|
}, mapperProps: MapperProps) => import("../../components/TextInputComponent").TextInputComponent;
|
|
7
|
-
export declare const getStringValidationErrors: ({ schema, model, required, getErrorMessageFunctions, }: {
|
|
8
|
-
schema: StringSchema;
|
|
9
|
-
model: string | null;
|
|
10
|
-
required: boolean;
|
|
11
|
-
getErrorMessageFunctions: GetErrorMessageFunctions;
|
|
12
|
-
}) => string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import type { Schema, Step } from '@wise/dynamic-flow-types/build/next';
|
|
3
|
+
import type { MapperProps, SchemaMapperProps } from '../types';
|
|
4
|
+
import type { StepComponent } from '../../../types';
|
|
5
|
+
export declare const getMockMapperProps: (mapperProps?: Partial<MapperProps>) => {
|
|
6
|
+
step: Step;
|
|
7
|
+
getErrorMessageFunctions: jest.Mock<any, any, any> | import("../../types").GetErrorMessageFunctions;
|
|
8
|
+
onAction: jest.Mock<any, any, any> | import("../../../types").OnAction;
|
|
9
|
+
updateComponent: jest.Mock<any, any, any> | import("../../../types").UpdateComponent;
|
|
10
|
+
trackEvent: jest.Mock<any, any, any> | import("../../../events").AnalyticsEventDispatcher;
|
|
11
|
+
logEvent: jest.Mock<any, any, any> | import("../../../events").LoggingEventDispatcher;
|
|
12
|
+
};
|
|
13
|
+
export declare const getMockSchemaMapperProps: <S extends Schema>(schemaMapperProps: Partial<SchemaMapperProps> & {
|
|
14
|
+
schema: S;
|
|
15
|
+
}) => {
|
|
16
|
+
schema: (Schema | undefined) & S;
|
|
17
|
+
model: import("@wise/dynamic-flow-types/build/next").Model;
|
|
18
|
+
required: boolean;
|
|
19
|
+
validationErrors: import("@wise/dynamic-flow-types/build/next").ValidationError;
|
|
20
|
+
};
|
|
21
|
+
export declare const mockUpdateFunction: <C extends StepComponent>(draftComponent: C) => jest.Mock<any, any, any>;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import type { Step as DFStep, Model, Schema } from '@wise/dynamic-flow-types/build/next';
|
|
1
|
+
import type { Step as DFStep, Model, Schema, ValidationError } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { OnAction, UpdateComponent } from '../../types';
|
|
3
3
|
import type { GetErrorMessageFunctions } from '../types';
|
|
4
|
+
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../../events';
|
|
4
5
|
export type MapperProps = {
|
|
5
6
|
step: DFStep;
|
|
6
7
|
getErrorMessageFunctions: GetErrorMessageFunctions;
|
|
7
8
|
onAction: OnAction;
|
|
8
9
|
updateComponent: UpdateComponent;
|
|
10
|
+
trackEvent: AnalyticsEventDispatcher;
|
|
11
|
+
logEvent: LoggingEventDispatcher;
|
|
9
12
|
};
|
|
10
13
|
export type SchemaMapperProps = {
|
|
11
14
|
schema: Schema;
|
|
12
15
|
model: Model;
|
|
13
16
|
required?: boolean;
|
|
17
|
+
validationErrors?: ValidationError;
|
|
14
18
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export type GetErrorMessageFunctions = (validationMessages?: ValidationMessages) => ErrorMessageFunctions;
|
|
2
2
|
export type ValidationMessages = Record<string, string | undefined>;
|
|
3
3
|
export type ErrorMessageFunctions = {
|
|
4
|
-
|
|
4
|
+
maximum: (maximum: number) => string;
|
|
5
|
+
minimum: (minimum: number) => string;
|
|
5
6
|
maximumDate: (maxDate: string) => string;
|
|
6
|
-
|
|
7
|
+
minimumDate: (minDate: string) => string;
|
|
7
8
|
maxLength: (maxLength: number) => string;
|
|
9
|
+
minLength: (minLength: number) => string;
|
|
8
10
|
pattern: () => string;
|
|
9
11
|
required: () => string;
|
|
10
|
-
type: () => string;
|
|
11
12
|
};
|
|
@@ -7,13 +7,15 @@ import type { ObjectComponent } from './components/ObjectComponent';
|
|
|
7
7
|
import type { ParagraphComponent } from './components/ParagraphComponent';
|
|
8
8
|
import type { TextInputComponent } from './components/TextInputComponent';
|
|
9
9
|
import type { ColumnsComponent } from './components/ColumnsComponent';
|
|
10
|
-
|
|
10
|
+
import type { NumberInputComponent } from './components/NumberInputComponent';
|
|
11
|
+
import type { IntegerInputComponent } from './components/IntegerInputComponent';
|
|
12
|
+
export type StepComponent = AlertComponent | BoxComponent | ButtonComponent | ColumnsComponent | HeadingComponent | ObjectComponent | ParagraphComponent | TextInputComponent | NumberInputComponent | IntegerInputComponent;
|
|
11
13
|
export type ContainerComponent = ObjectComponent | BoxComponent | ColumnsComponent;
|
|
12
14
|
export type BaseComponent<M extends Model> = {
|
|
13
15
|
type: string;
|
|
14
16
|
uid: string;
|
|
15
17
|
validate: () => boolean;
|
|
16
|
-
getValue: () => M;
|
|
18
|
+
getValue: () => M | null;
|
|
17
19
|
};
|
|
18
20
|
export type LayoutComponent = BaseComponent<Model> & {
|
|
19
21
|
margin: Margin;
|
|
@@ -21,6 +23,18 @@ export type LayoutComponent = BaseComponent<Model> & {
|
|
|
21
23
|
};
|
|
22
24
|
export type InputComponent<M extends Model> = BaseComponent<M> & {
|
|
23
25
|
id: string;
|
|
26
|
+
autoComplete: string;
|
|
27
|
+
control?: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
disabled: boolean;
|
|
30
|
+
errors: string[];
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
title?: string;
|
|
33
|
+
value: M | null;
|
|
34
|
+
onChange: (value: M | null) => void;
|
|
35
|
+
onBlur: () => void;
|
|
36
|
+
onFocus: () => void;
|
|
37
|
+
getValue: () => M | null;
|
|
24
38
|
};
|
|
25
39
|
export type UpdateComponent = (id: string, update: (component: StepComponent) => void) => void;
|
|
26
40
|
export type OnAction = (action: Action) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Model } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import type { IsInvalidCheck } from './value-checks';
|
|
3
|
+
export declare const getModelValidationErrors: <M extends Model>({ checks, model, }: {
|
|
4
|
+
checks: IsInvalidCheck<M>[];
|
|
5
|
+
model: M;
|
|
6
|
+
}) => string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
export declare const mockErrorMessageFunctions: {
|
|
3
|
+
minimum: jest.Mock<any, any, any>;
|
|
4
|
+
maximum: jest.Mock<any, any, any>;
|
|
5
|
+
minimumDate: jest.Mock<any, any, any>;
|
|
6
|
+
maximumDate: jest.Mock<any, any, any>;
|
|
7
|
+
minLength: jest.Mock<any, any, any>;
|
|
8
|
+
maxLength: jest.Mock<any, any, any>;
|
|
9
|
+
pattern: jest.Mock<any, any, any>;
|
|
10
|
+
required: jest.Mock<any, any, any>;
|
|
11
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { StepComponent } from '../
|
|
1
|
+
import type { StepComponent } from '../types';
|
|
2
2
|
export declare const validateComponents: (components: StepComponent[]) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IntegerSchema, Model, NumberSchema, Schema, StringSchema } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import type { ErrorMessageFunctions } from '../mappers/types';
|
|
3
|
+
export type IsInvalidCheck<M extends Model> = (model: M | null) => string | null;
|
|
4
|
+
type GetIsInvalidCheck<S extends Schema, M extends Model> = (schema: S, messageFunctions: ErrorMessageFunctions) => IsInvalidCheck<M>;
|
|
5
|
+
export declare const getAboveMaxLengthCheck: GetIsInvalidCheck<StringSchema, string | null>;
|
|
6
|
+
export declare const getBelowMinLengthCheck: GetIsInvalidCheck<StringSchema, string | null>;
|
|
7
|
+
export declare const getAboveMaximumCheck: GetIsInvalidCheck<NumberSchema | IntegerSchema, number | null>;
|
|
8
|
+
export declare const getBelowMinimumCheck: GetIsInvalidCheck<NumberSchema | IntegerSchema, number | null>;
|
|
9
|
+
export declare const getAboveMaximumDateCheck: GetIsInvalidCheck<StringSchema, string | null>;
|
|
10
|
+
export declare const getBelowMinimumDateCheck: GetIsInvalidCheck<StringSchema, string | null>;
|
|
11
|
+
export declare const getNotAdheringToPatternCheck: GetIsInvalidCheck<StringSchema, string | null>;
|
|
12
|
+
export declare const getRequiredCheck: (required: boolean, messageFunctions: ErrorMessageFunctions) => IsInvalidCheck<Model | null>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Step, Model } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
+
import type { AnalyticsEventHandler, LoggingEventHandler } from './domain/events';
|
|
3
|
+
export type DynamicFlowProps = DynamicFlowPropsWithInitialAction | DynamicFlowPropsWithInitialStep;
|
|
4
|
+
export type DynamicFlowPropsWithInitialAction = DynamicFlowPropsBasic & {
|
|
5
|
+
initialAction: InitialAction;
|
|
6
|
+
initialStep?: never;
|
|
7
|
+
};
|
|
8
|
+
export type DynamicFlowPropsWithInitialStep = DynamicFlowPropsBasic & {
|
|
9
|
+
initialAction?: never;
|
|
10
|
+
initialStep: Step;
|
|
11
|
+
};
|
|
12
|
+
export type InitialAction = {
|
|
13
|
+
$id?: string;
|
|
14
|
+
url: string;
|
|
15
|
+
method?: 'GET';
|
|
16
|
+
data?: never;
|
|
17
|
+
} | {
|
|
18
|
+
$id?: string;
|
|
19
|
+
url: string;
|
|
20
|
+
method: 'POST';
|
|
21
|
+
data: Model;
|
|
22
|
+
};
|
|
23
|
+
type DynamicFlowPropsBasic = {
|
|
24
|
+
flowId: string;
|
|
25
|
+
displayStepTitle?: boolean;
|
|
26
|
+
features?: Feature[];
|
|
27
|
+
httpClient: HttpClient;
|
|
28
|
+
onCompletion: (result: Model) => void;
|
|
29
|
+
onError: (error: unknown, status?: number) => void;
|
|
30
|
+
onEvent?: AnalyticsEventHandler;
|
|
31
|
+
onLog?: LoggingEventHandler;
|
|
32
|
+
};
|
|
33
|
+
export type HttpClient = typeof fetch;
|
|
34
|
+
type Feature = {
|
|
35
|
+
featureName: string;
|
|
36
|
+
variant: number | null;
|
|
37
|
+
};
|
|
38
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TextInputComponent } from '../../domain/components/TextInputComponent';
|
|
2
2
|
import type { TextInputRendererProps } from '../types';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const textInputComponentToProps: (component: TextInputComponent) => TextInputRendererProps;
|
|
@@ -54,9 +54,9 @@ export interface ObjectRendererProps extends RendererProps {
|
|
|
54
54
|
description?: string;
|
|
55
55
|
children: ReactNode;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
type: 'input-text';
|
|
57
|
+
interface BaseInputRendererProps<M extends string | number> extends RendererProps {
|
|
59
58
|
id: string;
|
|
59
|
+
autoComplete: string;
|
|
60
60
|
control?: string;
|
|
61
61
|
description?: string;
|
|
62
62
|
error?: string;
|
|
@@ -64,8 +64,21 @@ export interface TextInputRendererProps extends RendererProps {
|
|
|
64
64
|
label?: string;
|
|
65
65
|
name: string;
|
|
66
66
|
placeholder?: string;
|
|
67
|
-
value:
|
|
68
|
-
onChange: (value:
|
|
67
|
+
value: M | null;
|
|
68
|
+
onChange: (value: M | null) => void;
|
|
69
|
+
onBlur: () => void;
|
|
70
|
+
onFocus: () => void;
|
|
71
|
+
}
|
|
72
|
+
export interface TextInputRendererProps extends BaseInputRendererProps<string> {
|
|
73
|
+
type: 'input-text';
|
|
74
|
+
control?: string;
|
|
75
|
+
format?: 'date';
|
|
76
|
+
}
|
|
77
|
+
export interface NumberInputRendererProps extends BaseInputRendererProps<number> {
|
|
78
|
+
type: 'input-number';
|
|
79
|
+
}
|
|
80
|
+
export interface IntegerInputRendererProps extends BaseInputRendererProps<number> {
|
|
81
|
+
type: 'input-integer';
|
|
69
82
|
}
|
|
70
83
|
export interface ButtonRendererProps extends RendererProps {
|
|
71
84
|
type: 'button';
|
|
@@ -76,3 +89,4 @@ export interface ButtonRendererProps extends RendererProps {
|
|
|
76
89
|
margin: Margin;
|
|
77
90
|
onClick: () => void;
|
|
78
91
|
}
|
|
92
|
+
export {};
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { Step as DFStep } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { Renderer, RendererProps } from '../renderers/types';
|
|
3
|
+
import type { AnalyticsEventDispatcher, LoggingEventDispatcher } from '../domain/events';
|
|
3
4
|
type StepProps = {
|
|
4
5
|
step: DFStep;
|
|
5
6
|
renderers: Renderer<RendererProps>[];
|
|
7
|
+
trackEvent: AnalyticsEventDispatcher;
|
|
8
|
+
logEvent: LoggingEventDispatcher;
|
|
6
9
|
};
|
|
7
|
-
declare function Step({ step
|
|
10
|
+
declare function Step({ step, renderers, trackEvent, logEvent }: StepProps): JSX.Element;
|
|
8
11
|
export default Step;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AllOfSchema, Model, ObjectSchema, OneOfSchema, Schema, StringSchema } from '@wise/dynamic-flow-types/build/next';
|
|
1
|
+
import type { AllOfSchema, IntegerSchema, Model, NumberSchema, ObjectSchema, OneOfSchema, Schema, StringSchema } from '@wise/dynamic-flow-types/build/next';
|
|
2
2
|
import type { ContainerComponent, StepComponent } from '../domain/types';
|
|
3
3
|
import type { ColumnsComponent } from '../domain/components/ColumnsComponent';
|
|
4
4
|
export declare const isContainerComponent: (component: StepComponent) => component is ContainerComponent;
|
|
@@ -8,3 +8,5 @@ export declare const isAllOfSchema: (schema: Schema) => schema is AllOfSchema;
|
|
|
8
8
|
export declare const isOneOfSchema: (schema: Schema) => schema is OneOfSchema;
|
|
9
9
|
export declare const isObjectSchema: (schema: Schema) => schema is ObjectSchema;
|
|
10
10
|
export declare const isStringSchema: (schema: Schema) => schema is StringSchema;
|
|
11
|
+
export declare const isNumberSchema: (schema: Schema) => schema is NumberSchema;
|
|
12
|
+
export declare const isIntegerSchema: (schema: Schema) => schema is IntegerSchema;
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { StringSchema } from '@wise/dynamic-flow-types/build/next';
|
|
2
|
-
type IsInvalidCheck = (schema: StringSchema, model: string | null) => boolean;
|
|
3
|
-
export declare const isAboveMaximum: IsInvalidCheck;
|
|
4
|
-
export declare const isAboveMaxLength: IsInvalidCheck;
|
|
5
|
-
export declare const isBelowMinimum: IsInvalidCheck;
|
|
6
|
-
export declare const isBelowMinLength: IsInvalidCheck;
|
|
7
|
-
export declare const isNotAdheringToPattern: IsInvalidCheck;
|
|
8
|
-
export declare const isNotCorrectType: IsInvalidCheck;
|
|
9
|
-
export declare const isNotProvided: IsInvalidCheck;
|
|
10
|
-
export {};
|
|
File without changes
|