@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.
@@ -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 {};
@@ -1,4 +1,4 @@
1
1
  export * from './dynamicFlowContexts/DynamicFlowContexts';
2
2
  export * from './eventsContext/EventsContext';
3
- export * from './fetcherContexts/FetcherContexts';
3
+ export * from './httpClientContext/HttpClientContext';
4
4
  export * from './logContext/LogContext';
@@ -0,0 +1 @@
1
+ export * from './makeHttpClient';
@@ -0,0 +1,2 @@
1
+ export type HttpClient = typeof fetch;
2
+ export declare const makeHttpClient: (baseUrl: string, additionalHeaders?: HeadersInit) => HttpClient;
@@ -5,9 +5,8 @@ export type DynamicFlowPropsBasic = {
5
5
  flowId: string;
6
6
  loaderConfig?: LoaderConfig;
7
7
  displayStepTitle?: boolean;
8
- fetcher: Fetcher;
9
- onComplete: (result: Record<string, unknown> | undefined | null) => void;
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 Fetcher = typeof fetch;
26
+ export type HttpClient = typeof fetch;
28
27
  export type ETag = string;
29
28
  export type LoaderConfig = {
30
29
  size?: Size;
@@ -0,0 +1,2 @@
1
+ import { HttpClient } from '../DynamicFlowTypes';
2
+ export declare const fixtureHttpClient: HttpClient;
@@ -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['onComplete']>[0];
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['onComplete']>[0]>;
16
+ export declare const parseExitResponse: (response: Response) => Promise<Parameters<DynamicFlowProps['onCompletion']>[0]>;
17
17
  export {};
@@ -1,6 +1,6 @@
1
1
  export { convertStepToLayout, inlineReferences } from './step/layoutStep/utils';
2
2
  export { default as DynamicFlow } from './dynamicFlow';
3
- export { makeFetcher } from './common/makeFetcher';
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';
@@ -1,9 +1,9 @@
1
1
  import { UploadProps } from '@transferwise/components/build/types/upload/Upload';
2
- import { Fetcher } from '../../../dynamicFlow/DynamicFlowTypes';
2
+ import { HttpClient } from '../../../dynamicFlow/DynamicFlowTypes';
3
3
  import { PersistAsync } from '../../../types';
4
4
  type Props = UploadProps & {
5
5
  id: string;
6
- fetcher: Fetcher;
6
+ httpClient: HttpClient;
7
7
  fileId: number | string;
8
8
  idProperty: string;
9
9
  httpOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wise/dynamic-flow-client",
3
- "version": "0.4.4",
3
+ "version": "0.5.0",
4
4
  "description": "Dynamic Flow web client",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./build/main.min.js",
@@ -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';
@@ -1,2 +0,0 @@
1
- export type Fetcher = typeof fetch;
2
- export declare const makeFetcher: (baseUrl: string, additionalHeaders?: HeadersInit) => Fetcher;
@@ -1,2 +0,0 @@
1
- import { Fetcher } from '../DynamicFlowTypes';
2
- export declare const fixtureFetcher: Fetcher;