@wise/dynamic-flow-client 0.4.4 → 0.5.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/README.md +17 -22
- package/build/main.js +53 -59
- package/build/main.min.js +3 -3
- package/build/types/common/contexts/httpClientContext/HttpClientContext.d.ts +18 -0
- package/build/types/common/contexts/index.d.ts +1 -1
- package/build/types/common/makeHttpClient/index.d.ts +1 -0
- package/build/types/common/makeHttpClient/makeHttpClient.d.ts +2 -0
- package/build/types/dynamicFlow/DynamicFlowTypes.d.ts +3 -4
- package/build/types/dynamicFlow/stories/fixtureHttpClient.d.ts +2 -0
- package/build/types/dynamicFlow/utils/responseParsers/response-parsers.d.ts +2 -2
- package/build/types/index.d.ts +1 -1
- package/build/types/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.d.ts +2 -2
- package/package.json +1 -1
- package/build/types/common/contexts/fetcherContexts/FetcherContexts.d.ts +0 -18
- package/build/types/common/makeFetcher/index.d.ts +0 -1
- package/build/types/common/makeFetcher/makeFetcher.d.ts +0 -2
- package/build/types/dynamicFlow/stories/fixtureFetcher.d.ts +0 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type HttpClient = typeof fetch;
|
|
3
|
+
type ProviderProps = {
|
|
4
|
+
httpClient: HttpClient;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
export declare const HttpClientProvider: ({ httpClient, children }: ProviderProps) => JSX.Element;
|
|
8
|
+
type ProviderFromBaseUrlProps = {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export declare const HttpClientProviderFromBaseUrl: ({ baseUrl, children }: ProviderFromBaseUrlProps) => JSX.Element;
|
|
13
|
+
/**
|
|
14
|
+
* Provides the fetch(er) function for dynamic flows asynchronous operations.
|
|
15
|
+
*/
|
|
16
|
+
export declare const useHttpClient: () => typeof fetch;
|
|
17
|
+
export declare const useHasHttpClientProvider: () => boolean;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './makeHttpClient';
|
|
@@ -5,9 +5,8 @@ export type DynamicFlowPropsBasic = {
|
|
|
5
5
|
flowId: string;
|
|
6
6
|
loaderConfig?: LoaderConfig;
|
|
7
7
|
displayStepTitle?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
onStepChange?: (newStep: Step, previousStep: Step | undefined) => void;
|
|
8
|
+
httpClient: HttpClient;
|
|
9
|
+
onCompletion: (result: Record<string, unknown> | undefined | null) => void;
|
|
11
10
|
onError: (error: unknown, status?: number) => void;
|
|
12
11
|
onEvent?: EventHandler;
|
|
13
12
|
onLog?: LogEventHandler;
|
|
@@ -24,7 +23,7 @@ type DynamicFlowPropsWithInitialStep = {
|
|
|
24
23
|
};
|
|
25
24
|
export type DynamicFlowProps = DynamicFlowPropsBasic & (DynamicFlowPropsWithInitialAction | DynamicFlowPropsWithInitialStep);
|
|
26
25
|
export declare function isSchema(schema: FormLayout['schema']): schema is Schema;
|
|
27
|
-
export type
|
|
26
|
+
export type HttpClient = typeof fetch;
|
|
28
27
|
export type ETag = string;
|
|
29
28
|
export type LoaderConfig = {
|
|
30
29
|
size?: Size;
|
|
@@ -2,7 +2,7 @@ import { ActionResponseBody, ErrorResponseBody, Step } from '../../../types';
|
|
|
2
2
|
import { DynamicFlowProps } from '../../DynamicFlowTypes';
|
|
3
3
|
type ParsedBody = {
|
|
4
4
|
type: 'exit';
|
|
5
|
-
result: Parameters<DynamicFlowProps['
|
|
5
|
+
result: Parameters<DynamicFlowProps['onCompletion']>[0];
|
|
6
6
|
} | {
|
|
7
7
|
type: 'action';
|
|
8
8
|
action: ActionResponseBody['action'];
|
|
@@ -13,5 +13,5 @@ type ParsedBody = {
|
|
|
13
13
|
};
|
|
14
14
|
export declare const parseFetchResponse: (response: Response) => Promise<ParsedBody>;
|
|
15
15
|
export declare const parseErrorResponse: (response: Response) => Promise<ErrorResponseBody>;
|
|
16
|
-
export declare const parseExitResponse: (response: Response) => Promise<Parameters<DynamicFlowProps['
|
|
16
|
+
export declare const parseExitResponse: (response: Response) => Promise<Parameters<DynamicFlowProps['onCompletion']>[0]>;
|
|
17
17
|
export {};
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { convertStepToLayout, inlineReferences } from './step/layoutStep/utils';
|
|
2
2
|
export { default as DynamicFlow } from './dynamicFlow';
|
|
3
|
-
export {
|
|
3
|
+
export { makeHttpClient } from './common/makeHttpClient';
|
|
4
4
|
export { default as JsonSchemaForm } from './jsonSchemaForm';
|
|
5
5
|
export { DynamicLayout as Layout } from './layout';
|
|
6
6
|
export { isValidSchema } from './common/validators';
|
package/build/types/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UploadProps } from '@transferwise/components/build/types/upload/Upload';
|
|
2
|
-
import {
|
|
2
|
+
import { HttpClient } from '../../../dynamicFlow/DynamicFlowTypes';
|
|
3
3
|
import { PersistAsync } from '../../../types';
|
|
4
4
|
type Props = UploadProps & {
|
|
5
5
|
id: string;
|
|
6
|
-
|
|
6
|
+
httpClient: HttpClient;
|
|
7
7
|
fileId: number | string;
|
|
8
8
|
idProperty: string;
|
|
9
9
|
httpOptions: {
|
package/package.json
CHANGED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type Fetcher = typeof fetch;
|
|
3
|
-
type FetcherProviderProps = {
|
|
4
|
-
fetcher: Fetcher;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
};
|
|
7
|
-
export declare const FetcherProvider: ({ fetcher, children }: FetcherProviderProps) => JSX.Element;
|
|
8
|
-
type FetcherProviderFromBaseUrlProps = {
|
|
9
|
-
baseUrl: string;
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
};
|
|
12
|
-
export declare const FetcherProviderFromBaseUrl: ({ baseUrl, children, }: FetcherProviderFromBaseUrlProps) => JSX.Element;
|
|
13
|
-
/**
|
|
14
|
-
* Provides the fetch(er) function for dynamic flows asynchronous operations.
|
|
15
|
-
*/
|
|
16
|
-
export declare const useFetcher: () => typeof fetch;
|
|
17
|
-
export declare const useHasFetcherProvider: () => boolean;
|
|
18
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './makeFetcher';
|