@tesouro/embedded-components-react 0.2.252 → 0.2.253
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/dist/experimental/WidgetSuite.d.ts +649 -25
- package/dist/experimental/WidgetSuite.js +5 -2
- package/dist/experimental/index.d.ts +649 -25
- package/dist/experimental/index.js +5 -2
- package/dist/index.css +22 -2
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/index.js +2 -2
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/{index3.js → lib/AccountCard.js} +3 -3
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/{index6.js → lib/BankAccountsWidgetUi.js} +7 -7
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/{index4.js → lib/BankingHeader.js} +2 -2
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/{index5.js → lib/CreateAccountDialog.js} +4 -4
- package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/{index2.js → lib/labels.js} +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index5.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/index.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/{index3.js → lib/SettingsWidgetUi/SettingsWidgetUi.js} +3 -3
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/lib/SettingsWidgetUi/index.js +2 -0
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/{index2.js → lib/SettingsWidgetUi/labels.js} +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/EmbedApiContext.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
- package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/UIContext/UIProvider.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index.js +5 -2
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index2.js +4 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index3.js +8 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index4.js +34 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index5.js +59 -0
- package/dist/libs/tesouro-embedded-components-react/widget-suite/ui/dist/index.js +3 -3
- package/dist/libs/tesouro-embedded-components-react/widget-suite/ui/dist/index2.js +6 -3
- package/dist/libs/tesouro-embedded-components-react/widget-suite/ui/dist/index3.js +70 -18
- package/package.json +1 -1
- package/dist/libs/tesouro-embedded-components-react/settings-widget/ui/dist/index4.js +0 -2
|
@@ -1,36 +1,660 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } from 'react';
|
|
3
|
+
import { FallbackProps } from 'react-error-boundary';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Copy the shell owns. The section names are deliberately absent: they arrive on
|
|
7
|
+
* each `SuiteSection`, because whoever decides which sections exist is also the
|
|
8
|
+
* only layer that can name them.
|
|
9
|
+
*/
|
|
10
|
+
interface WidgetSuiteShellLabels {
|
|
11
|
+
/** Names the section menu for assistive technology. */
|
|
12
|
+
navAriaLabel: string;
|
|
13
|
+
/** Shown in place of the menu when the caller supplies no sections. */
|
|
14
|
+
emptyState: {
|
|
15
|
+
title: string;
|
|
16
|
+
body: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `Labels` has a nested group, so a shallow `{ ...defaults, ...overrides }`
|
|
21
|
+
* would let a consumer overriding one `emptyState` string drop the other. The
|
|
22
|
+
* repo has no shared deep-partial type, so each labels module declares its own.
|
|
23
|
+
*/
|
|
24
|
+
type PartialDeep<T> = {
|
|
25
|
+
[K in keyof T]?: T[K] extends object ? PartialDeep<T[K]> : T[K];
|
|
26
|
+
};
|
|
27
|
+
declare const WIDGET_SUITE_SHELL_LABELS_EN: WidgetSuiteShellLabels;
|
|
28
|
+
|
|
29
|
+
type AuthToken = string | undefined;
|
|
30
|
+
interface Auth {
|
|
31
|
+
/**
|
|
32
|
+
* Which part of the request do we use to send the auth?
|
|
33
|
+
*
|
|
34
|
+
* @default 'header'
|
|
35
|
+
*/
|
|
36
|
+
in?: 'header' | 'query' | 'cookie';
|
|
37
|
+
/**
|
|
38
|
+
* A unique identifier for the security scheme.
|
|
39
|
+
*
|
|
40
|
+
* Defined only when there are multiple security schemes whose `Auth`
|
|
41
|
+
* shape would otherwise be identical.
|
|
42
|
+
*/
|
|
43
|
+
key?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Header or query parameter name.
|
|
46
|
+
*
|
|
47
|
+
* @default 'Authorization'
|
|
48
|
+
*/
|
|
49
|
+
name?: string;
|
|
50
|
+
scheme?: 'basic' | 'bearer';
|
|
51
|
+
type: 'apiKey' | 'http';
|
|
6
52
|
}
|
|
7
53
|
|
|
8
|
-
interface
|
|
9
|
-
|
|
54
|
+
interface SerializerOptions<T> {
|
|
55
|
+
/**
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
explode: boolean;
|
|
59
|
+
style: T;
|
|
10
60
|
}
|
|
61
|
+
type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
|
|
62
|
+
type ObjectStyle = 'form' | 'deepObject';
|
|
63
|
+
|
|
64
|
+
type QuerySerializer = (query: Record<string, unknown>) => string;
|
|
65
|
+
type BodySerializer = (body: unknown) => unknown;
|
|
66
|
+
type QuerySerializerOptionsObject = {
|
|
67
|
+
allowReserved?: boolean;
|
|
68
|
+
array?: Partial<SerializerOptions<ArrayStyle>>;
|
|
69
|
+
object?: Partial<SerializerOptions<ObjectStyle>>;
|
|
70
|
+
};
|
|
71
|
+
type QuerySerializerOptions = QuerySerializerOptionsObject & {
|
|
72
|
+
/**
|
|
73
|
+
* Per-parameter serialization overrides. When provided, these settings
|
|
74
|
+
* override the global array/object settings for specific parameter names.
|
|
75
|
+
*/
|
|
76
|
+
parameters?: Record<string, QuerySerializerOptionsObject>;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
|
|
80
|
+
type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
|
|
81
|
+
/**
|
|
82
|
+
* Returns the final request URL.
|
|
83
|
+
*/
|
|
84
|
+
buildUrl: BuildUrlFn;
|
|
85
|
+
getConfig: () => Config;
|
|
86
|
+
request: RequestFn;
|
|
87
|
+
setConfig: (config: Config) => Config;
|
|
88
|
+
} & {
|
|
89
|
+
[K in HttpMethod]: MethodFn;
|
|
90
|
+
} & ([SseFn] extends [never] ? {
|
|
91
|
+
sse?: never;
|
|
92
|
+
} : {
|
|
93
|
+
sse: {
|
|
94
|
+
[K in HttpMethod]: SseFn;
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
interface Config$1 {
|
|
98
|
+
/**
|
|
99
|
+
* Auth token or a function returning auth token. The resolved value will be
|
|
100
|
+
* added to the request payload as defined by its `security` array.
|
|
101
|
+
*/
|
|
102
|
+
auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
|
|
103
|
+
/**
|
|
104
|
+
* A function for serializing request body parameter. By default,
|
|
105
|
+
* {@link JSON.stringify()} will be used.
|
|
106
|
+
*/
|
|
107
|
+
bodySerializer?: BodySerializer | null;
|
|
108
|
+
/**
|
|
109
|
+
* An object containing any HTTP headers that you want to pre-populate your
|
|
110
|
+
* `Headers` object with.
|
|
111
|
+
*
|
|
112
|
+
* {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
|
|
113
|
+
*/
|
|
114
|
+
headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
|
|
115
|
+
/**
|
|
116
|
+
* The request method.
|
|
117
|
+
*
|
|
118
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
|
|
119
|
+
*/
|
|
120
|
+
method?: Uppercase<HttpMethod>;
|
|
121
|
+
/**
|
|
122
|
+
* A function for serializing request query parameters. By default, arrays
|
|
123
|
+
* will be exploded in form style, objects will be exploded in deepObject
|
|
124
|
+
* style, and reserved characters are percent-encoded.
|
|
125
|
+
*
|
|
126
|
+
* This method will have no effect if the native `paramsSerializer()` Axios
|
|
127
|
+
* API function is used.
|
|
128
|
+
*
|
|
129
|
+
* {@link https://swagger.io/docs/specification/serialization/#query View examples}
|
|
130
|
+
*/
|
|
131
|
+
querySerializer?: QuerySerializer | QuerySerializerOptions;
|
|
132
|
+
/**
|
|
133
|
+
* A function validating request data. This is useful if you want to ensure
|
|
134
|
+
* the request conforms to the desired shape, so it can be safely sent to
|
|
135
|
+
* the server.
|
|
136
|
+
*/
|
|
137
|
+
requestValidator?: (data: unknown) => Promise<unknown>;
|
|
138
|
+
/**
|
|
139
|
+
* A function transforming response data before it's returned. This is useful
|
|
140
|
+
* for post-processing data, e.g., converting ISO strings into Date objects.
|
|
141
|
+
*/
|
|
142
|
+
responseTransformer?: (data: unknown) => Promise<unknown>;
|
|
143
|
+
/**
|
|
144
|
+
* A function validating response data. This is useful if you want to ensure
|
|
145
|
+
* the response conforms to the desired shape, so it can be safely passed to
|
|
146
|
+
* the transformers and returned to the user.
|
|
147
|
+
*/
|
|
148
|
+
responseValidator?: (data: unknown) => Promise<unknown>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
|
|
152
|
+
/**
|
|
153
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
154
|
+
* fetch instance.
|
|
155
|
+
*
|
|
156
|
+
* @default globalThis.fetch
|
|
157
|
+
*/
|
|
158
|
+
fetch?: typeof fetch;
|
|
159
|
+
/**
|
|
160
|
+
* Implementing clients can call request interceptors inside this hook.
|
|
161
|
+
*/
|
|
162
|
+
onRequest?: (url: string, init: RequestInit) => Promise<Request>;
|
|
163
|
+
/**
|
|
164
|
+
* Callback invoked when a network or parsing error occurs during streaming.
|
|
165
|
+
*
|
|
166
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
167
|
+
*
|
|
168
|
+
* @param error The error that occurred.
|
|
169
|
+
*/
|
|
170
|
+
onSseError?: (error: unknown) => void;
|
|
171
|
+
/**
|
|
172
|
+
* Callback invoked when an event is streamed from the server.
|
|
173
|
+
*
|
|
174
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
175
|
+
*
|
|
176
|
+
* @param event Event streamed from the server.
|
|
177
|
+
* @returns Nothing (void).
|
|
178
|
+
*/
|
|
179
|
+
onSseEvent?: (event: StreamEvent<TData>) => void;
|
|
180
|
+
serializedBody?: RequestInit['body'];
|
|
181
|
+
/**
|
|
182
|
+
* Default retry delay in milliseconds.
|
|
183
|
+
*
|
|
184
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
185
|
+
*
|
|
186
|
+
* @default 3000
|
|
187
|
+
*/
|
|
188
|
+
sseDefaultRetryDelay?: number;
|
|
189
|
+
/**
|
|
190
|
+
* Maximum number of retry attempts before giving up.
|
|
191
|
+
*/
|
|
192
|
+
sseMaxRetryAttempts?: number;
|
|
193
|
+
/**
|
|
194
|
+
* Maximum retry delay in milliseconds.
|
|
195
|
+
*
|
|
196
|
+
* Applies only when exponential backoff is used.
|
|
197
|
+
*
|
|
198
|
+
* This option applies only if the endpoint returns a stream of events.
|
|
199
|
+
*
|
|
200
|
+
* @default 30000
|
|
201
|
+
*/
|
|
202
|
+
sseMaxRetryDelay?: number;
|
|
203
|
+
/**
|
|
204
|
+
* Optional sleep function for retry backoff.
|
|
205
|
+
*
|
|
206
|
+
* Defaults to using `setTimeout`.
|
|
207
|
+
*/
|
|
208
|
+
sseSleepFn?: (ms: number) => Promise<void>;
|
|
209
|
+
url: string;
|
|
210
|
+
};
|
|
211
|
+
interface StreamEvent<TData = unknown> {
|
|
212
|
+
data: TData;
|
|
213
|
+
event?: string;
|
|
214
|
+
id?: string;
|
|
215
|
+
retry?: number;
|
|
216
|
+
}
|
|
217
|
+
type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
|
|
218
|
+
stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
|
|
222
|
+
/** response may be undefined due to a network error where no response object is produced */
|
|
223
|
+
response: Res | undefined,
|
|
224
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
225
|
+
request: Req | undefined, options: Options) => Err | Promise<Err>;
|
|
226
|
+
type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
|
|
227
|
+
type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
|
|
228
|
+
declare class Interceptors<Interceptor> {
|
|
229
|
+
fns: Array<Interceptor | null>;
|
|
230
|
+
clear(): void;
|
|
231
|
+
eject(id: number | Interceptor): void;
|
|
232
|
+
exists(id: number | Interceptor): boolean;
|
|
233
|
+
getInterceptorIndex(id: number | Interceptor): number;
|
|
234
|
+
update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
|
|
235
|
+
use(fn: Interceptor): number;
|
|
236
|
+
}
|
|
237
|
+
interface Middleware<Req, Res, Err, Options> {
|
|
238
|
+
error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
|
|
239
|
+
request: Interceptors<ReqInterceptor<Req, Options>>;
|
|
240
|
+
response: Interceptors<ResInterceptor<Res, Req, Options>>;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
type ResponseStyle = 'data' | 'fields';
|
|
244
|
+
interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
|
|
245
|
+
/**
|
|
246
|
+
* Base URL for all requests made by this client.
|
|
247
|
+
*/
|
|
248
|
+
baseUrl?: T['baseUrl'];
|
|
249
|
+
/**
|
|
250
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
251
|
+
* fetch instance.
|
|
252
|
+
*
|
|
253
|
+
* @default globalThis.fetch
|
|
254
|
+
*/
|
|
255
|
+
fetch?: typeof fetch;
|
|
256
|
+
/**
|
|
257
|
+
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
258
|
+
* options won't have any effect.
|
|
259
|
+
*
|
|
260
|
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
261
|
+
*/
|
|
262
|
+
next?: never;
|
|
263
|
+
/**
|
|
264
|
+
* Return the response data parsed in a specified format. By default, `auto`
|
|
265
|
+
* will infer the appropriate method from the `Content-Type` response header.
|
|
266
|
+
* You can override this behavior with any of the {@link Body} methods.
|
|
267
|
+
* Select `stream` if you don't want to parse response data at all.
|
|
268
|
+
*
|
|
269
|
+
* @default 'auto'
|
|
270
|
+
*/
|
|
271
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
272
|
+
/**
|
|
273
|
+
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
274
|
+
*
|
|
275
|
+
* @default 'fields'
|
|
276
|
+
*/
|
|
277
|
+
responseStyle?: ResponseStyle;
|
|
278
|
+
/**
|
|
279
|
+
* Throw an error instead of returning it in the response?
|
|
280
|
+
*
|
|
281
|
+
* @default false
|
|
282
|
+
*/
|
|
283
|
+
throwOnError?: T['throwOnError'];
|
|
284
|
+
}
|
|
285
|
+
interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
|
|
286
|
+
responseStyle: TResponseStyle;
|
|
287
|
+
throwOnError: ThrowOnError;
|
|
288
|
+
}>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
|
|
289
|
+
/**
|
|
290
|
+
* Any body that you want to add to your request.
|
|
291
|
+
*
|
|
292
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
293
|
+
*/
|
|
294
|
+
body?: unknown;
|
|
295
|
+
path?: Record<string, unknown>;
|
|
296
|
+
query?: Record<string, unknown>;
|
|
297
|
+
/**
|
|
298
|
+
* Security mechanism(s) to use for the request.
|
|
299
|
+
*/
|
|
300
|
+
security?: ReadonlyArray<Auth>;
|
|
301
|
+
url: Url;
|
|
302
|
+
}
|
|
303
|
+
interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
304
|
+
headers: Headers;
|
|
305
|
+
serializedBody?: string;
|
|
306
|
+
}
|
|
307
|
+
type RequestResult<TData = unknown, TError = unknown, ThrowOnError extends boolean = boolean, TResponseStyle extends ResponseStyle = 'fields'> = ThrowOnError extends true ? Promise<TResponseStyle extends 'data' ? TData extends Record<string, unknown> ? TData[keyof TData] : TData : {
|
|
308
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
309
|
+
request: Request;
|
|
310
|
+
response: Response;
|
|
311
|
+
}> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
|
|
312
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
313
|
+
error: undefined;
|
|
314
|
+
} | {
|
|
315
|
+
data: undefined;
|
|
316
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
317
|
+
}) & {
|
|
318
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
319
|
+
request?: Request;
|
|
320
|
+
/** response may be undefined, because error may be from building the request object itself or from a network error */
|
|
321
|
+
response?: Response;
|
|
322
|
+
}>;
|
|
323
|
+
interface ClientOptions$1 {
|
|
324
|
+
baseUrl?: string;
|
|
325
|
+
responseStyle?: ResponseStyle;
|
|
326
|
+
throwOnError?: boolean;
|
|
327
|
+
}
|
|
328
|
+
type MethodFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
329
|
+
type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
|
|
330
|
+
type RequestFn = <TData = unknown, TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> & Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
331
|
+
type BuildUrlFn = <TData extends {
|
|
332
|
+
body?: unknown;
|
|
333
|
+
path?: Record<string, unknown>;
|
|
334
|
+
query?: Record<string, unknown>;
|
|
335
|
+
url: string;
|
|
336
|
+
}>(options: TData & Options<TData>) => string;
|
|
337
|
+
type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
338
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
339
|
+
};
|
|
340
|
+
interface TDataShape {
|
|
341
|
+
body?: unknown;
|
|
342
|
+
headers?: unknown;
|
|
343
|
+
path?: unknown;
|
|
344
|
+
query?: unknown;
|
|
345
|
+
url: string;
|
|
346
|
+
}
|
|
347
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
348
|
+
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
349
|
+
|
|
350
|
+
type ClientOptions = {
|
|
351
|
+
baseUrl: 'https://api.stage.tesouro.com' | 'https://api.sandbox.stage.tesouro.com' | 'https://api.stage.business-banking.app' | 'https://api.tesouro.com' | 'https://api.sandbox.tesouro.com' | 'https://api.business-banking.app' | (string & {});
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
type EmbeddedClient = Client;
|
|
355
|
+
type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
|
|
356
|
+
type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
|
|
357
|
+
|
|
358
|
+
type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
|
359
|
+
children?: ReactNode;
|
|
360
|
+
};
|
|
361
|
+
type LinkComponent = ComponentType<LinkComponentProps>;
|
|
11
362
|
/**
|
|
12
|
-
*
|
|
363
|
+
* The UI frameworks a widget's UI layer can render with.
|
|
364
|
+
*
|
|
365
|
+
* - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
|
|
366
|
+
* implicit fallback, so existing consumers that select nothing keep rendering
|
|
367
|
+
* shadcn.
|
|
368
|
+
* - `tecton` — the Tecton implementation.
|
|
369
|
+
*
|
|
370
|
+
* Declared as an `as const` object (not a TypeScript `enum`) per repo
|
|
371
|
+
* convention.
|
|
372
|
+
*/
|
|
373
|
+
declare const UIFramework: {
|
|
374
|
+
readonly Shadcn: "shadcn";
|
|
375
|
+
readonly Tecton: "tecton";
|
|
376
|
+
};
|
|
377
|
+
type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* The implementation a widget renders with.
|
|
381
|
+
*
|
|
382
|
+
* - `native` — the Tesouro-native implementation. This is the default and the
|
|
383
|
+
* implicit fallback, so consumers that select nothing keep rendering native.
|
|
384
|
+
* - `monite` — the Monite SDK implementation.
|
|
13
385
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
386
|
+
* Declared as an `as const` object (not a TypeScript `enum`) per repo
|
|
387
|
+
* convention.
|
|
388
|
+
*/
|
|
389
|
+
declare const Implementation: {
|
|
390
|
+
readonly Native: "native";
|
|
391
|
+
readonly Monite: "monite";
|
|
392
|
+
};
|
|
393
|
+
type Implementation = (typeof Implementation)[keyof typeof Implementation];
|
|
394
|
+
/**
|
|
395
|
+
* The settable fields of the widget config cascade.
|
|
396
|
+
*
|
|
397
|
+
* This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
|
|
398
|
+
* It intentionally excludes `initResponse`, which is populated automatically by the
|
|
399
|
+
* provider after a successful fetch and must never be set manually.
|
|
400
|
+
*
|
|
401
|
+
* The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
|
|
402
|
+
* - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
|
|
403
|
+
* - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
|
|
404
|
+
* (e.g. after logout or deliberate de-scoping).
|
|
405
|
+
*
|
|
406
|
+
* @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
|
|
407
|
+
* @see {@link RootWidgetProvider}
|
|
408
|
+
* @see {@link WidgetProvider}
|
|
409
|
+
* @see {@link setGlobalWidgetConfig}
|
|
410
|
+
*/
|
|
411
|
+
interface WidgetConfigInput {
|
|
412
|
+
/**
|
|
413
|
+
* Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
|
|
414
|
+
*
|
|
415
|
+
* When omitted the nearest ancestor's `baseUrl` or the global store value is used.
|
|
416
|
+
* Changing this recreates the underlying HTTP client so all subsequent requests
|
|
417
|
+
* go to the new host.
|
|
418
|
+
*/
|
|
419
|
+
baseUrl?: BaseUrl;
|
|
420
|
+
/**
|
|
421
|
+
* Bearer token used to authenticate widget requests.
|
|
422
|
+
*
|
|
423
|
+
* Injected as `Authorization: Bearer <token>` on every outgoing request via an
|
|
424
|
+
* interceptor on the scoped HTTP client. Token updates are picked up immediately
|
|
425
|
+
* without recreating the client.
|
|
426
|
+
*
|
|
427
|
+
* - `string` — send this token on all requests from this level downward.
|
|
428
|
+
* - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
|
|
429
|
+
* - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
|
|
430
|
+
*/
|
|
431
|
+
widgetToken?: string | null;
|
|
432
|
+
/**
|
|
433
|
+
* Organization ID forwarded as the `x-organization-id` request header.
|
|
434
|
+
*
|
|
435
|
+
* Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
|
|
436
|
+
* so individual data-access hooks can opt in per-request.
|
|
437
|
+
*
|
|
438
|
+
* - `string` — use this organization for downstream data requests.
|
|
439
|
+
* - `null` — explicitly cleared; queries that require an org ID will be disabled.
|
|
440
|
+
* - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
|
|
441
|
+
*
|
|
442
|
+
* When `undefined` across the **whole** cascade (no prop, no ancestor, no global
|
|
443
|
+
* value), the resolved org defaults to the loaded `initResponse.organizationId`
|
|
444
|
+
* (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
|
|
445
|
+
* is the lowest-priority fallback — any explicit `string` or `null` at any cascade
|
|
446
|
+
* level wins, and an explicit `null` is preserved and never falls back.
|
|
447
|
+
*
|
|
448
|
+
* Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
|
|
449
|
+
* default does not propagate into a descendant that owns its own fetch (its own
|
|
450
|
+
* `baseUrl`/`widgetToken`); such a descendant defaults to its own
|
|
451
|
+
* `initResponse.organizationId` instead, so it never sends an ancestor's org with
|
|
452
|
+
* its own token.
|
|
453
|
+
*/
|
|
454
|
+
organizationId?: string | null;
|
|
455
|
+
/**
|
|
456
|
+
* Optional post-creation hook for the scoped HTTP client.
|
|
457
|
+
*
|
|
458
|
+
* Called once after the provider creates its scoped {@link EmbeddedClient} and
|
|
459
|
+
* applies the built-in `Authorization: Bearer` interceptor. Receives the
|
|
460
|
+
* fully-configured client and must return the client to be used for the lifetime of
|
|
461
|
+
* this provider level — either the same instance (with additional interceptors
|
|
462
|
+
* attached) or a new client entirely.
|
|
463
|
+
*
|
|
464
|
+
* **Order:** The built-in auth interceptor is always applied first. `configClient`
|
|
465
|
+
* is called on top of it, so any interceptors you add here run after auth is set.
|
|
466
|
+
*
|
|
467
|
+
* **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
|
|
468
|
+
* scoped client whenever any prop is set — including `configClient` alone, without
|
|
469
|
+
* `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
|
|
470
|
+
* client creation and never calls this function.
|
|
471
|
+
*
|
|
472
|
+
* **Stability:** The function reference is included in the client creation memo's
|
|
473
|
+
* dependency array. Passing an unstable (inline) function recreates the client on
|
|
474
|
+
* every render. Stabilize with `useCallback` or define the function outside the
|
|
475
|
+
* component.
|
|
476
|
+
*
|
|
477
|
+
* **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
|
|
478
|
+
* {@link WidgetProvider} that creates its own scoped client will use the resolved
|
|
479
|
+
* `configClient` from the cascade unless it provides its own override.
|
|
480
|
+
*
|
|
481
|
+
* @example
|
|
482
|
+
* ```tsx
|
|
483
|
+
* const addLogging = useCallback(
|
|
484
|
+
* (client: EmbeddedClient) => {
|
|
485
|
+
* client.interceptors.request.use((req) => {
|
|
486
|
+
* console.log('[widget]', req.method, req.url);
|
|
487
|
+
* return req;
|
|
488
|
+
* });
|
|
489
|
+
* return client;
|
|
490
|
+
* },
|
|
491
|
+
* [],
|
|
492
|
+
* );
|
|
493
|
+
*
|
|
494
|
+
* <RootWidgetProvider
|
|
495
|
+
* baseUrl="https://api.tesouro.com"
|
|
496
|
+
* widgetToken={token}
|
|
497
|
+
* configClient={addLogging}
|
|
498
|
+
* >
|
|
499
|
+
* <App />
|
|
500
|
+
* </RootWidgetProvider>
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
configClient?: (client: EmbeddedClient) => EmbeddedClient;
|
|
504
|
+
/**
|
|
505
|
+
* Component the embedded widgets should render in place of plain `<a>` tags.
|
|
506
|
+
*
|
|
507
|
+
* Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
|
|
508
|
+
* Cascades like other config: provider prop > nearest ancestor > global store.
|
|
509
|
+
* When no value is set anywhere, widgets fall back to a plain `<a>` element.
|
|
510
|
+
*/
|
|
511
|
+
linkComponent?: LinkComponent;
|
|
512
|
+
/**
|
|
513
|
+
* Which UI framework the widget UI layer should render with.
|
|
514
|
+
*
|
|
515
|
+
* Lets a consuming context bind widgets to either the shadcn/Tailwind or the
|
|
516
|
+
* Tecton implementation behind the same outward-facing API. The selection is
|
|
517
|
+
* a presentation concern only — it cascades through the provider tree exactly
|
|
518
|
+
* like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
|
|
519
|
+
* it never appears in any widget's feature-library or component props.
|
|
520
|
+
*
|
|
521
|
+
* - `'shadcn'` — the shadcn/Tailwind implementation.
|
|
522
|
+
* - `'tecton'` — the Tecton implementation.
|
|
523
|
+
* - `null` / `undefined` — not set at this level; inherit from the nearest
|
|
524
|
+
* ancestor or global store, falling back to `shadcn` when unset everywhere.
|
|
525
|
+
* `shadcn` is the implicit default, so existing consumers need no changes.
|
|
526
|
+
*/
|
|
527
|
+
uiFramework?: UIFramework | null;
|
|
528
|
+
/**
|
|
529
|
+
* Which implementation a widget renders with.
|
|
530
|
+
*
|
|
531
|
+
* Lets a consuming context bind widgets to either the Tesouro-native or the
|
|
532
|
+
* Monite SDK implementation behind the same outward-facing API. It cascades
|
|
533
|
+
* through the provider tree exactly like {@link linkComponent} and
|
|
534
|
+
* {@link uiFramework} — provider prop > nearest ancestor > global store — and
|
|
535
|
+
* is read via `useImplementation`.
|
|
536
|
+
*
|
|
537
|
+
* - `'native'` — the Tesouro-native implementation.
|
|
538
|
+
* - `'monite'` — the Monite SDK implementation.
|
|
539
|
+
* - `null` / `undefined` — not set at this level; inherit from the nearest
|
|
540
|
+
* ancestor or global store, falling back to `native` when unset everywhere.
|
|
541
|
+
* `native` is the implicit default, so existing consumers need no changes.
|
|
542
|
+
*/
|
|
543
|
+
implementation?: Implementation | null;
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Props shared by every analytics-owner-capable widget provider.
|
|
547
|
+
*
|
|
548
|
+
* Combines the full settable cascade ({@link WidgetConfigInput}) with the
|
|
549
|
+
* analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
|
|
550
|
+
* and {@link WidgetProvider} build their public props on top of this; the latter
|
|
551
|
+
* adds error-boundary props of its own.
|
|
552
|
+
*
|
|
553
|
+
* @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
|
|
554
|
+
*/
|
|
555
|
+
interface WidgetProviderBaseProps extends WidgetConfigInput {
|
|
556
|
+
/**
|
|
557
|
+
* Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
|
|
558
|
+
*
|
|
559
|
+
* Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
|
|
560
|
+
* standalone {@link WidgetProvider} with no parent provider. When `false`,
|
|
561
|
+
* owner-bound `track` calls in this subtree become no-ops and the PostHog
|
|
562
|
+
* installer is never dynamically imported for this owner's environment.
|
|
563
|
+
* Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
|
|
564
|
+
* `console.warn` is emitted to make the no-op discoverable).
|
|
565
|
+
*/
|
|
566
|
+
analytics?: boolean;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Props for {@link WidgetProvider}.
|
|
571
|
+
*
|
|
572
|
+
* All fields are optional. When **all** are omitted the provider is a transparent
|
|
573
|
+
* pass-through: no fetch is issued and all resolved values cascade unchanged from
|
|
574
|
+
* the nearest ancestor.
|
|
575
|
+
*/
|
|
576
|
+
interface WidgetProviderProps extends WidgetProviderBaseProps {
|
|
577
|
+
/**
|
|
578
|
+
* Fallback rendered when a render-time exception is caught inside this
|
|
579
|
+
* provider's subtree. Pass either a `ReactNode` (rendered directly) or a
|
|
580
|
+
* render-prop receiving `{ error, resetErrorBoundary }` from
|
|
581
|
+
* `react-error-boundary`. Default is a plain `role="alert"` div with
|
|
582
|
+
* generic copy from `DEFAULT_LABELS.errorBoundaryFallback`.
|
|
583
|
+
*/
|
|
584
|
+
errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
|
|
585
|
+
/**
|
|
586
|
+
* Called once when the boundary catches an error, before the fallback
|
|
587
|
+
* renders. Use for telemetry / Sentry / partner logging. Exceptions
|
|
588
|
+
* thrown from `onError` propagate per `react-error-boundary` semantics.
|
|
589
|
+
*/
|
|
590
|
+
onError?: (error: unknown, info: ErrorInfo) => void;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* The sections this pass wires. Three of a planned eight (EMBD-4873): enough to
|
|
595
|
+
* exercise an ungated section, a scope-gated one, and a widget that gates its
|
|
596
|
+
* own subsections, without eight widgets' worth of integration noise.
|
|
597
|
+
*/
|
|
598
|
+
declare const WidgetSuiteSectionId: {
|
|
599
|
+
readonly Accounts: "accounts";
|
|
600
|
+
readonly Cards: "cards";
|
|
601
|
+
readonly Settings: "settings";
|
|
602
|
+
};
|
|
603
|
+
type WidgetSuiteSectionId = (typeof WidgetSuiteSectionId)[keyof typeof WidgetSuiteSectionId];
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* The section names in the suite menu.
|
|
607
|
+
*
|
|
608
|
+
* Keyed by section id rather than hand-listed, so adding a section to the
|
|
609
|
+
* registry fails the build here until it is named — the menu can never render a
|
|
610
|
+
* section with no label. The type import is erased, so this carries no runtime
|
|
611
|
+
* edge back to the registry.
|
|
612
|
+
*
|
|
613
|
+
* Separate from the shell's own `labels` (its nav landmark name and empty
|
|
614
|
+
* state), which the suite forwards untouched: the same split
|
|
615
|
+
* `BillPayWidgetNative` makes between `labels` and `tabsLabels`.
|
|
616
|
+
*/
|
|
617
|
+
type WidgetSuiteSectionLabels = Record<WidgetSuiteSectionId, string>;
|
|
618
|
+
declare const WIDGET_SUITE_SECTION_LABELS_EN: WidgetSuiteSectionLabels;
|
|
619
|
+
|
|
620
|
+
interface WidgetSuiteProps extends WidgetProviderProps {
|
|
621
|
+
/**
|
|
622
|
+
* Which sections the suite offers, in menu order.
|
|
623
|
+
*
|
|
624
|
+
* **Required, with no default, and staying that way.** Defaulting it to the
|
|
625
|
+
* whole registry would make a host's page composition invisible at the call
|
|
626
|
+
* site, and would grow silently every time a section is added. The wrapper
|
|
627
|
+
* that answers this once for a named integrator is a separate package with
|
|
628
|
+
* its own repo, so this prop is not waiting to acquire a default here.
|
|
629
|
+
*
|
|
630
|
+
* A section listed here is still hidden when the token does not earn it, so
|
|
631
|
+
* this is the host's ceiling rather than a promise of what renders.
|
|
632
|
+
*/
|
|
633
|
+
sections: readonly WidgetSuiteSectionId[];
|
|
634
|
+
/** Overrides for the shell's own copy — the nav landmark name, empty state. */
|
|
635
|
+
labels?: PartialDeep<WidgetSuiteShellLabels>;
|
|
636
|
+
/** Overrides for the section names in the menu. */
|
|
637
|
+
sectionLabels?: Partial<WidgetSuiteSectionLabels>;
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* A suite of widgets bound together by navigation.
|
|
20
641
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
642
|
+
* Unlike a widget — a content area an integrator drops onto a page they own — a
|
|
643
|
+
* suite owns the page it is placed on, exists once per page, and decides which
|
|
644
|
+
* widgets appear on it.
|
|
23
645
|
*
|
|
24
|
-
* `
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* that class, so dropping the anchor reds CI rather than silently unstyling.
|
|
646
|
+
* One `/init` serves the whole surface: this provider owns the fetch, and every
|
|
647
|
+
* composed widget is handed no auth props, so its own provider runs in
|
|
648
|
+
* pass-through mode. See `sections.tsx` for the two composition rules that
|
|
649
|
+
* arrangement depends on.
|
|
29
650
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
651
|
+
* The active section is held here rather than taken as a prop, matching
|
|
652
|
+
* `BillPayWidgetNative` and `SettingsWidget`. A host-controlled
|
|
653
|
+
* `selectedSectionId` / `onSectionChange` pair is the natural next step for
|
|
654
|
+
* deep-linking, and is deliberately not invented on an experimental export
|
|
655
|
+
* before a host asks for it.
|
|
32
656
|
*/
|
|
33
|
-
declare
|
|
657
|
+
declare function WidgetSuite({ baseUrl, widgetToken, organizationId, configClient, linkComponent, implementation, uiFramework, errorFallback, onError, analytics, ...innerProps }: WidgetSuiteProps): React.JSX.Element;
|
|
34
658
|
|
|
35
|
-
export {
|
|
36
|
-
export type {
|
|
659
|
+
export { WIDGET_SUITE_SECTION_LABELS_EN, WIDGET_SUITE_SHELL_LABELS_EN, WidgetSuite, WidgetSuiteSectionId };
|
|
660
|
+
export type { PartialDeep, WidgetSuiteProps, WidgetSuiteSectionLabels, WidgetSuiteShellLabels };
|