@tesouro/embedded-components-react 0.3.42 → 0.3.44

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.
Files changed (36) hide show
  1. package/README.md +18 -2
  2. package/dist/experimental/index.d.ts +1 -975
  3. package/dist/experimental/index.js +0 -6
  4. package/dist/index.d.ts +1730 -1425
  5. package/dist/index.js +65 -61
  6. package/dist/lib/WidgetProvider.js +7 -7
  7. package/dist/lib/WidgetSuite.d.ts +2081 -0
  8. package/dist/lib/WidgetSuite.js +5 -0
  9. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index5.js +60 -60
  10. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js +6 -6
  11. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js +18 -18
  12. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index8.js +16 -16
  13. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/ui/dist/lib/BankAccountsWidgetUi.js +10 -10
  14. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index6.js +45 -45
  15. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/zod.gen.js +2 -1
  16. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/RootWidgetProvider.js +18 -18
  17. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/WidgetProvider/WidgetProvider.js +118 -118
  18. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  19. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index.js +6 -5
  20. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index10.js +33 -0
  21. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index11.js +23 -0
  22. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index12.js +19 -0
  23. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index13.js +16 -0
  24. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index14.js +21 -0
  25. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index15.js +22 -0
  26. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index16.js +116 -0
  27. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index4.js +46 -23
  28. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index5.js +20 -88
  29. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index6.js +31 -34
  30. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +12 -132
  31. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +11 -137
  32. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index9.js +33 -0
  33. package/dist/libs/tesouro-embedded-components-react/widget-suite/ui/dist/index3.js +12 -12
  34. package/package.json +1 -1
  35. package/dist/experimental/WidgetSuite.d.ts +0 -976
  36. package/dist/experimental/WidgetSuite.js +0 -6
@@ -1,976 +0,0 @@
1
- import * as React from 'react';
2
- import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } from 'react';
3
- import { FallbackProps } from 'react-error-boundary';
4
-
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
- /**
14
- * Announces the placeholder shell while the caller resolves which sections
15
- * exist. Read out in place of the menu, which has no items yet to name.
16
- */
17
- loadingAriaLabel: string;
18
- /** Shown in place of the menu when the caller supplies no sections. */
19
- emptyState: {
20
- title: string;
21
- body: string;
22
- };
23
- }
24
- /**
25
- * `Labels` has a nested group, so a shallow `{ ...defaults, ...overrides }`
26
- * would let a consumer overriding one `emptyState` string drop the other. The
27
- * repo has no shared deep-partial type, so each labels module declares its own.
28
- */
29
- type PartialDeep<T> = {
30
- [K in keyof T]?: T[K] extends object ? PartialDeep<T[K]> : T[K];
31
- };
32
- declare const WIDGET_SUITE_SHELL_LABELS_EN: WidgetSuiteShellLabels;
33
-
34
- type AuthToken = string | undefined;
35
- interface Auth {
36
- /**
37
- * Which part of the request do we use to send the auth?
38
- *
39
- * @default 'header'
40
- */
41
- in?: 'header' | 'query' | 'cookie';
42
- /**
43
- * A unique identifier for the security scheme.
44
- *
45
- * Defined only when there are multiple security schemes whose `Auth`
46
- * shape would otherwise be identical.
47
- */
48
- key?: string;
49
- /**
50
- * Header or query parameter name.
51
- *
52
- * @default 'Authorization'
53
- */
54
- name?: string;
55
- scheme?: 'basic' | 'bearer';
56
- type: 'apiKey' | 'http';
57
- }
58
-
59
- interface SerializerOptions<T> {
60
- /**
61
- * @default true
62
- */
63
- explode: boolean;
64
- style: T;
65
- }
66
- type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
67
- type ObjectStyle = 'form' | 'deepObject';
68
-
69
- type QuerySerializer = (query: Record<string, unknown>) => string;
70
- type BodySerializer = (body: unknown) => unknown;
71
- type QuerySerializerOptionsObject = {
72
- allowReserved?: boolean;
73
- array?: Partial<SerializerOptions<ArrayStyle>>;
74
- object?: Partial<SerializerOptions<ObjectStyle>>;
75
- };
76
- type QuerySerializerOptions = QuerySerializerOptionsObject & {
77
- /**
78
- * Per-parameter serialization overrides. When provided, these settings
79
- * override the global array/object settings for specific parameter names.
80
- */
81
- parameters?: Record<string, QuerySerializerOptionsObject>;
82
- };
83
-
84
- type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
85
- type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
86
- /**
87
- * Returns the final request URL.
88
- */
89
- buildUrl: BuildUrlFn;
90
- getConfig: () => Config;
91
- request: RequestFn;
92
- setConfig: (config: Config) => Config;
93
- } & {
94
- [K in HttpMethod]: MethodFn;
95
- } & ([SseFn] extends [never] ? {
96
- sse?: never;
97
- } : {
98
- sse: {
99
- [K in HttpMethod]: SseFn;
100
- };
101
- });
102
- interface Config$1 {
103
- /**
104
- * Auth token or a function returning auth token. The resolved value will be
105
- * added to the request payload as defined by its `security` array.
106
- */
107
- auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
108
- /**
109
- * A function for serializing request body parameter. By default,
110
- * {@link JSON.stringify()} will be used.
111
- */
112
- bodySerializer?: BodySerializer | null;
113
- /**
114
- * An object containing any HTTP headers that you want to pre-populate your
115
- * `Headers` object with.
116
- *
117
- * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
118
- */
119
- headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
120
- /**
121
- * The request method.
122
- *
123
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
124
- */
125
- method?: Uppercase<HttpMethod>;
126
- /**
127
- * A function for serializing request query parameters. By default, arrays
128
- * will be exploded in form style, objects will be exploded in deepObject
129
- * style, and reserved characters are percent-encoded.
130
- *
131
- * This method will have no effect if the native `paramsSerializer()` Axios
132
- * API function is used.
133
- *
134
- * {@link https://swagger.io/docs/specification/serialization/#query View examples}
135
- */
136
- querySerializer?: QuerySerializer | QuerySerializerOptions;
137
- /**
138
- * A function validating request data. This is useful if you want to ensure
139
- * the request conforms to the desired shape, so it can be safely sent to
140
- * the server.
141
- */
142
- requestValidator?: (data: unknown) => Promise<unknown>;
143
- /**
144
- * A function transforming response data before it's returned. This is useful
145
- * for post-processing data, e.g., converting ISO strings into Date objects.
146
- */
147
- responseTransformer?: (data: unknown) => Promise<unknown>;
148
- /**
149
- * A function validating response data. This is useful if you want to ensure
150
- * the response conforms to the desired shape, so it can be safely passed to
151
- * the transformers and returned to the user.
152
- */
153
- responseValidator?: (data: unknown) => Promise<unknown>;
154
- }
155
-
156
- type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
157
- /**
158
- * Fetch API implementation. You can use this option to provide a custom
159
- * fetch instance.
160
- *
161
- * @default globalThis.fetch
162
- */
163
- fetch?: typeof fetch;
164
- /**
165
- * Implementing clients can call request interceptors inside this hook.
166
- */
167
- onRequest?: (url: string, init: RequestInit) => Promise<Request>;
168
- /**
169
- * Callback invoked when a network or parsing error occurs during streaming.
170
- *
171
- * This option applies only if the endpoint returns a stream of events.
172
- *
173
- * @param error The error that occurred.
174
- */
175
- onSseError?: (error: unknown) => void;
176
- /**
177
- * Callback invoked when an event is streamed from the server.
178
- *
179
- * This option applies only if the endpoint returns a stream of events.
180
- *
181
- * @param event Event streamed from the server.
182
- * @returns Nothing (void).
183
- */
184
- onSseEvent?: (event: StreamEvent<TData>) => void;
185
- serializedBody?: RequestInit['body'];
186
- /**
187
- * Default retry delay in milliseconds.
188
- *
189
- * This option applies only if the endpoint returns a stream of events.
190
- *
191
- * @default 3000
192
- */
193
- sseDefaultRetryDelay?: number;
194
- /**
195
- * Maximum number of retry attempts before giving up.
196
- */
197
- sseMaxRetryAttempts?: number;
198
- /**
199
- * Maximum retry delay in milliseconds.
200
- *
201
- * Applies only when exponential backoff is used.
202
- *
203
- * This option applies only if the endpoint returns a stream of events.
204
- *
205
- * @default 30000
206
- */
207
- sseMaxRetryDelay?: number;
208
- /**
209
- * Optional sleep function for retry backoff.
210
- *
211
- * Defaults to using `setTimeout`.
212
- */
213
- sseSleepFn?: (ms: number) => Promise<void>;
214
- url: string;
215
- };
216
- interface StreamEvent<TData = unknown> {
217
- data: TData;
218
- event?: string;
219
- id?: string;
220
- retry?: number;
221
- }
222
- type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
223
- stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
224
- };
225
-
226
- type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
227
- /** response may be undefined due to a network error where no response object is produced */
228
- response: Res | undefined,
229
- /** request may be undefined, because error may be from building the request object itself */
230
- request: Req | undefined, options: Options) => Err | Promise<Err>;
231
- type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
232
- type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
233
- declare class Interceptors<Interceptor> {
234
- fns: Array<Interceptor | null>;
235
- clear(): void;
236
- eject(id: number | Interceptor): void;
237
- exists(id: number | Interceptor): boolean;
238
- getInterceptorIndex(id: number | Interceptor): number;
239
- update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
240
- use(fn: Interceptor): number;
241
- }
242
- interface Middleware<Req, Res, Err, Options> {
243
- error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
244
- request: Interceptors<ReqInterceptor<Req, Options>>;
245
- response: Interceptors<ResInterceptor<Res, Req, Options>>;
246
- }
247
-
248
- type ResponseStyle = 'data' | 'fields';
249
- interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
250
- /**
251
- * Base URL for all requests made by this client.
252
- */
253
- baseUrl?: T['baseUrl'];
254
- /**
255
- * Fetch API implementation. You can use this option to provide a custom
256
- * fetch instance.
257
- *
258
- * @default globalThis.fetch
259
- */
260
- fetch?: typeof fetch;
261
- /**
262
- * Please don't use the Fetch client for Next.js applications. The `next`
263
- * options won't have any effect.
264
- *
265
- * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
266
- */
267
- next?: never;
268
- /**
269
- * Return the response data parsed in a specified format. By default, `auto`
270
- * will infer the appropriate method from the `Content-Type` response header.
271
- * You can override this behavior with any of the {@link Body} methods.
272
- * Select `stream` if you don't want to parse response data at all.
273
- *
274
- * @default 'auto'
275
- */
276
- parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
277
- /**
278
- * Should we return only data or multiple fields (data, error, response, etc.)?
279
- *
280
- * @default 'fields'
281
- */
282
- responseStyle?: ResponseStyle;
283
- /**
284
- * Throw an error instead of returning it in the response?
285
- *
286
- * @default false
287
- */
288
- throwOnError?: T['throwOnError'];
289
- }
290
- interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
291
- responseStyle: TResponseStyle;
292
- throwOnError: ThrowOnError;
293
- }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
294
- /**
295
- * Any body that you want to add to your request.
296
- *
297
- * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
298
- */
299
- body?: unknown;
300
- path?: Record<string, unknown>;
301
- query?: Record<string, unknown>;
302
- /**
303
- * Security mechanism(s) to use for the request.
304
- */
305
- security?: ReadonlyArray<Auth>;
306
- url: Url;
307
- }
308
- interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
309
- headers: Headers;
310
- serializedBody?: string;
311
- }
312
- 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 : {
313
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
314
- request: Request;
315
- response: Response;
316
- }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
317
- data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
318
- error: undefined;
319
- } | {
320
- data: undefined;
321
- error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
322
- }) & {
323
- /** request may be undefined, because error may be from building the request object itself */
324
- request?: Request;
325
- /** response may be undefined, because error may be from building the request object itself or from a network error */
326
- response?: Response;
327
- }>;
328
- interface ClientOptions$1 {
329
- baseUrl?: string;
330
- responseStyle?: ResponseStyle;
331
- throwOnError?: boolean;
332
- }
333
- 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>;
334
- type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
335
- 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>;
336
- type BuildUrlFn = <TData extends {
337
- body?: unknown;
338
- path?: Record<string, unknown>;
339
- query?: Record<string, unknown>;
340
- url: string;
341
- }>(options: TData & Options<TData>) => string;
342
- type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
343
- interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
344
- };
345
- interface TDataShape {
346
- body?: unknown;
347
- headers?: unknown;
348
- path?: unknown;
349
- query?: unknown;
350
- url: string;
351
- }
352
- type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
353
- 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'>);
354
-
355
- type ClientOptions = {
356
- 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 & {});
357
- };
358
-
359
- type EmbeddedClient = Client;
360
- type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
361
- type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
362
-
363
- type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
364
- children?: ReactNode;
365
- };
366
- type LinkComponent = ComponentType<LinkComponentProps>;
367
- /**
368
- * The UI frameworks a widget's UI layer can render with.
369
- *
370
- * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
371
- * implicit fallback, so existing consumers that select nothing keep rendering
372
- * shadcn.
373
- * - `tecton` — the Tecton implementation.
374
- *
375
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
376
- * convention.
377
- */
378
- declare const UIFramework: {
379
- readonly Shadcn: "shadcn";
380
- readonly Tecton: "tecton";
381
- };
382
- type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
383
-
384
- /**
385
- * The implementation a widget renders with.
386
- *
387
- * - `native` — the Tesouro-native implementation. This is the default and the
388
- * implicit fallback, so consumers that select nothing keep rendering native.
389
- * - `monite` — the Monite SDK implementation.
390
- *
391
- * Declared as an `as const` object (not a TypeScript `enum`) per repo
392
- * convention.
393
- */
394
- declare const Implementation: {
395
- readonly Native: "native";
396
- readonly Monite: "monite";
397
- };
398
- type Implementation = (typeof Implementation)[keyof typeof Implementation];
399
- /**
400
- * The settable fields of the widget config cascade.
401
- *
402
- * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
403
- * It intentionally excludes `initResponse`, which is populated automatically by the
404
- * provider after a successful fetch and must never be set manually.
405
- *
406
- * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
407
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
408
- * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
409
- * (e.g. after logout or deliberate de-scoping).
410
- *
411
- * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
412
- * @see {@link RootWidgetProvider}
413
- * @see {@link WidgetProvider}
414
- * @see {@link setGlobalWidgetConfig}
415
- */
416
- interface WidgetConfigInput {
417
- /**
418
- * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
419
- *
420
- * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
421
- * Changing this recreates the underlying HTTP client so all subsequent requests
422
- * go to the new host.
423
- */
424
- baseUrl?: BaseUrl;
425
- /**
426
- * Bearer token used to authenticate widget requests.
427
- *
428
- * Injected as `Authorization: Bearer <token>` on every outgoing request via an
429
- * interceptor on the scoped HTTP client. Token updates are picked up immediately
430
- * without recreating the client.
431
- *
432
- * - `string` — send this token on all requests from this level downward.
433
- * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
434
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
435
- */
436
- widgetToken?: string | null;
437
- /**
438
- * Organization ID forwarded as the `x-organization-id` request header.
439
- *
440
- * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
441
- * so individual data-access hooks can opt in per-request.
442
- *
443
- * - `string` — use this organization for downstream data requests.
444
- * - `null` — explicitly cleared; queries that require an org ID will be disabled.
445
- * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
446
- *
447
- * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
448
- * value), the resolved org defaults to the loaded `initResponse.organizationId`
449
- * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
450
- * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
451
- * level wins, and an explicit `null` is preserved and never falls back.
452
- *
453
- * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
454
- * default does not propagate into a descendant that owns its own fetch (its own
455
- * `baseUrl`/`widgetToken`); such a descendant defaults to its own
456
- * `initResponse.organizationId` instead, so it never sends an ancestor's org with
457
- * its own token.
458
- */
459
- organizationId?: string | null;
460
- /**
461
- * Optional post-creation hook for the scoped HTTP client.
462
- *
463
- * Called once after the provider creates its scoped {@link EmbeddedClient} and
464
- * applies the built-in `Authorization: Bearer` interceptor. Receives the
465
- * fully-configured client and must return the client to be used for the lifetime of
466
- * this provider level — either the same instance (with additional interceptors
467
- * attached) or a new client entirely.
468
- *
469
- * **Order:** The built-in auth interceptor is always applied first. `configClient`
470
- * is called on top of it, so any interceptors you add here run after auth is set.
471
- *
472
- * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
473
- * scoped client whenever any prop is set — including `configClient` alone, without
474
- * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
475
- * client creation and never calls this function.
476
- *
477
- * **Stability:** The function reference is included in the client creation memo's
478
- * dependency array. Passing an unstable (inline) function recreates the client on
479
- * every render. Stabilize with `useCallback` or define the function outside the
480
- * component.
481
- *
482
- * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
483
- * {@link WidgetProvider} that creates its own scoped client will use the resolved
484
- * `configClient` from the cascade unless it provides its own override.
485
- *
486
- * @example
487
- * ```tsx
488
- * const addLogging = useCallback(
489
- * (client: EmbeddedClient) => {
490
- * client.interceptors.request.use((req) => {
491
- * console.log('[widget]', req.method, req.url);
492
- * return req;
493
- * });
494
- * return client;
495
- * },
496
- * [],
497
- * );
498
- *
499
- * <RootWidgetProvider
500
- * baseUrl="https://api.tesouro.com"
501
- * widgetToken={token}
502
- * configClient={addLogging}
503
- * >
504
- * <App />
505
- * </RootWidgetProvider>
506
- * ```
507
- */
508
- configClient?: (client: EmbeddedClient) => EmbeddedClient;
509
- /**
510
- * Overrides the widget-gateway routing decision for the scoped HTTP client.
511
- *
512
- * Any caller reaching the Tesouro API with a widget token must route data
513
- * requests through the widget gateway: prefix the path with
514
- * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
515
- * provider applies both automatically per request when the request origin is
516
- * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
517
- * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
518
- * init round-trip) always pass through untouched.
519
- *
520
- * - `undefined` — decide from the request origin, as above. Inherits from
521
- * the nearest ancestor or global store like every other config field.
522
- * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
523
- * custom domain in front of the gateway).
524
- * - `false` — never apply it. For hosts that route widget requests their own
525
- * way, such as a same-origin BFF whose `configClient` retargets every
526
- * request.
527
- *
528
- * Independent of {@link configClient}: a host that only adds a header keeps
529
- * the built-in routing, and the built-in interceptor runs before any
530
- * `configClient` interceptor.
531
- */
532
- gatewayRouting?: boolean;
533
- /**
534
- * Component the embedded widgets should render in place of plain `<a>` tags.
535
- *
536
- * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
537
- * Cascades like other config: provider prop > nearest ancestor > global store.
538
- * When no value is set anywhere, widgets fall back to a plain `<a>` element.
539
- */
540
- linkComponent?: LinkComponent;
541
- /**
542
- * Which UI framework the widget UI layer should render with.
543
- *
544
- * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
545
- * Tecton implementation behind the same outward-facing API. The selection is
546
- * a presentation concern only — it cascades through the provider tree exactly
547
- * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
548
- * it never appears in any widget's feature-library or component props.
549
- *
550
- * - `'shadcn'` — the shadcn/Tailwind implementation.
551
- * - `'tecton'` — the Tecton implementation.
552
- * - `null` / `undefined` — not set at this level; inherit from the nearest
553
- * ancestor or global store, falling back to `shadcn` when unset everywhere.
554
- * `shadcn` is the implicit default, so existing consumers need no changes.
555
- */
556
- uiFramework?: UIFramework | null;
557
- /**
558
- * Which implementation a widget renders with.
559
- *
560
- * Lets a consuming context bind widgets to either the Tesouro-native or the
561
- * Monite SDK implementation behind the same outward-facing API. It cascades
562
- * through the provider tree exactly like {@link linkComponent} and
563
- * {@link uiFramework} — provider prop > nearest ancestor > global store — and
564
- * is read via `useImplementation`.
565
- *
566
- * - `'native'` — the Tesouro-native implementation.
567
- * - `'monite'` — the Monite SDK implementation.
568
- * - `null` / `undefined` — not set at this level; inherit from the nearest
569
- * ancestor or global store, falling back to `native` when unset everywhere.
570
- * `native` is the implicit default, so existing consumers need no changes.
571
- */
572
- implementation?: Implementation | null;
573
- }
574
- /**
575
- * Props shared by every analytics-owner-capable widget provider.
576
- *
577
- * Combines the full settable cascade ({@link WidgetConfigInput}) with the
578
- * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
579
- * and {@link WidgetProvider} build their public props on top of this; the latter
580
- * adds error-boundary props of its own.
581
- *
582
- * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
583
- */
584
- interface WidgetProviderBaseProps extends WidgetConfigInput {
585
- /**
586
- * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
587
- *
588
- * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
589
- * standalone {@link WidgetProvider} with no parent provider. When `false`,
590
- * owner-bound `track` calls in this subtree become no-ops and the PostHog
591
- * installer is never dynamically imported for this owner's environment.
592
- * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
593
- * `console.warn` is emitted to make the no-op discoverable).
594
- */
595
- analytics?: boolean;
596
- }
597
-
598
- /**
599
- * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
600
- * the error-boundary fallback and the disclosures gate. A host overrides any
601
- * subset through the `providerLabels` prop, which cascades like
602
- * `disclosuresAcceptance`.
603
- *
604
- * Not named `Labels` on the public surface: a widget's own `labels` prop is a
605
- * different thing, and these two travel together on every widget's props type.
606
- */
607
- interface WidgetProviderLabels {
608
- /** Default copy for the built-in error boundary fallback. */
609
- errorBoundaryFallback: string;
610
- /** Heading when init reports disclosures are required and not yet accepted. */
611
- disclosuresRequiredTitle: string;
612
- /** Heading while a token-only refresh leaves init stale for the live token. */
613
- disclosuresRefreshingTitle: string;
614
- /** Supporting copy while the accept action is withheld for a stale init. */
615
- disclosuresRefreshingDescription: string;
616
- }
617
-
618
- /**
619
- * Props for {@link WidgetProvider}.
620
- *
621
- * All fields are optional. When **all** are omitted the provider is a transparent
622
- * pass-through: no fetch is issued and all resolved values cascade unchanged from
623
- * the nearest ancestor.
624
- */
625
- interface WidgetProviderProps extends WidgetProviderBaseProps {
626
- /**
627
- * Fallback rendered when a render-time exception is caught inside this
628
- * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
629
- * render-prop receiving `{ error, resetErrorBoundary }` from
630
- * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
631
- * comes from `providerLabels.errorBoundaryFallback`.
632
- */
633
- errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
634
- /**
635
- * Called once when the boundary catches an error, before the fallback
636
- * renders. Use for telemetry / Sentry / partner logging. Exceptions
637
- * thrown from `onError` propagate per `react-error-boundary` semantics.
638
- */
639
- onError?: (error: unknown, info: ErrorInfo) => void;
640
- /**
641
- * Accept surface shown when the caller owes disclosures — an INVITED
642
- * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
643
- * activate) or an ACTIVE user who owes a new version. Pass
644
- * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
645
- * WidgetProvider cannot import the widget itself (cycle).
646
- */
647
- disclosuresAcceptance?: ReactNode;
648
- /**
649
- * Overrides for the copy this provider renders in place of the widget: the
650
- * built-in error-boundary fallback and the disclosures gate. Any subset;
651
- * unlisted keys keep their defaults. Cascades like `linkComponent`.
652
- *
653
- * Named `providerLabels` rather than `labels` because a widget's own
654
- * `labels` prop sits alongside this one on the same props type.
655
- */
656
- providerLabels?: Partial<WidgetProviderLabels>;
657
- }
658
-
659
- /**
660
- * The sections the suite can offer, declared in the default menu order
661
- * (EMBD-4875). Order here is documentation only — the suite renders whatever
662
- * order its `sections` prop lists.
663
- */
664
- declare const WidgetSuiteSectionId: {
665
- readonly Dashboard: "dashboard";
666
- readonly Accounts: "accounts";
667
- readonly Cards: "cards";
668
- readonly Transfers: "transfers";
669
- readonly BillPay: "bill-pay";
670
- readonly Invoicing: "invoicing";
671
- readonly Expenses: "expenses";
672
- readonly Settings: "settings";
673
- };
674
- type WidgetSuiteSectionId = (typeof WidgetSuiteSectionId)[keyof typeof WidgetSuiteSectionId];
675
- /**
676
- * The whole surface in the shipped white-label header order
677
- * (`useDashboardLayout.tsx`): its banking group, then its finops group, then
678
- * Settings, which white label keeps in the avatar menu rather than the header.
679
- *
680
- * Exported as a constant to spread rather than wired up as a default for
681
- * `sections`, which stays required. A default would make a host's page
682
- * composition invisible at the call site and would grow silently every time a
683
- * section is added here. The zero-config wrapper is the intended consumer.
684
- */
685
- declare const WIDGET_SUITE_DEFAULT_SECTIONS: readonly ["dashboard", "accounts", "cards", "transfers", "bill-pay", "invoicing", "expenses", "settings"];
686
-
687
- /**
688
- * The section names in the suite menu.
689
- *
690
- * Keyed by section id rather than hand-listed, so adding a section to the
691
- * registry fails the build here until it is named — the menu can never render a
692
- * section with no label. The type import is erased, so this carries no runtime
693
- * edge back to the registry.
694
- *
695
- * Separate from the shell's own `labels` (its nav landmark name and empty
696
- * state), which the suite forwards untouched: the same split
697
- * `BillPayWidgetNative` makes between `labels` and `tabsLabels`.
698
- */
699
- type WidgetSuiteSectionLabels = Record<WidgetSuiteSectionId, string>;
700
- /** Copy for the heading above a section, as opposed to its menu item. */
701
- interface WidgetSuiteSectionTitleLabels {
702
- /**
703
- * The bank attribution beneath the heading. `{bankName}` is replaced with the
704
- * bank `/init` names, so a translation can put it anywhere in the sentence
705
- * rather than after a fixed lead-in. An override that drops the placeholder
706
- * shows no name.
707
- */
708
- bankTagline: string;
709
- }
710
- /**
711
- * Copy the suite puts *inside* a section's panel, rather than in its menu or
712
- * heading. Each group is shaped as the props of the widget it is handed to, so
713
- * the merged object below can be passed down by reference.
714
- */
715
- interface WidgetSuiteContentLabels {
716
- /**
717
- * `CardsList` renders its own `labels.title` as the list heading, defaulting
718
- * to "Cards". Two instances stack in the Cards section, so each is retitled by
719
- * program.
720
- */
721
- creditCards: {
722
- title: string;
723
- };
724
- debitCards: {
725
- title: string;
726
- };
727
- /** Expenses is only a placeholder until the suite wires a read/self surface. */
728
- expensePlaceholders: {
729
- expensesUnavailable: string;
730
- };
731
- }
732
- /**
733
- * Copy for the states where the suite cannot prove it may show normal content.
734
- *
735
- * Both are places the gate cannot proceed, and neither is reachable by a correct
736
- * integration against a healthy API.
737
- */
738
- interface WidgetSuiteDisclosureLabels {
739
- /**
740
- * The first init fetch failed before the disclosure flags were known. The suite
741
- * must fail closed here, because an unknown requirement is not permission to
742
- * show ungated sections.
743
- */
744
- initFailedState: {
745
- title: string;
746
- body: string;
747
- retryButton: string;
748
- };
749
- /**
750
- * The acceptance was recorded and the init refresh that clears the gate
751
- * failed, so only our view of it is stale.
752
- *
753
- * The failure is the title and the reassurance is the body, in that order on
754
- * purpose: `ErrorState` puts a destructive-toned glyph above the title, so
755
- * leading with "accepted" reads at a glance as the acceptance having failed —
756
- * the one thing this state must not imply, since a user who believes that will
757
- * try to accept again.
758
- */
759
- refreshFailedState: {
760
- title: string;
761
- body: string;
762
- retryButton: string;
763
- };
764
- }
765
- /** Named as the shipped white-label header names them. */
766
- declare const WIDGET_SUITE_SECTION_LABELS_EN: WidgetSuiteSectionLabels;
767
- declare const WIDGET_SUITE_SECTION_TITLE_LABELS_EN: WidgetSuiteSectionTitleLabels;
768
- declare const WIDGET_SUITE_CONTENT_LABELS_EN: WidgetSuiteContentLabels;
769
- declare const WIDGET_SUITE_DISCLOSURE_LABELS_EN: WidgetSuiteDisclosureLabels;
770
-
771
- interface CardsWidgetPaginationInput {
772
- paginationToken?: string;
773
- pageSize?: number;
774
- }
775
-
776
- /**
777
- * The sections this widget renders itself. These ids are the public vocabulary
778
- * a host uses to deep-link into a section, so they are part of the package's
779
- * API surface — renaming one is a breaking change.
780
- */
781
- declare const SettingsSection: {
782
- readonly Profile: "profile";
783
- readonly Team: "team";
784
- readonly Invoice: "invoice";
785
- readonly Expense: "expense";
786
- readonly BillPay: "bill-pay";
787
- readonly Accounting: "accounting";
788
- readonly Tags: "tags";
789
- readonly Help: "help";
790
- };
791
- type SettingsSection = (typeof SettingsSection)[keyof typeof SettingsSection];
792
- /**
793
- * A selectable section id: one of the built-ins, or the id of a host-supplied
794
- * {@link SettingsWidgetAdditionalSection}. The `string & {}` arm keeps the
795
- * built-in literals visible to editor autocomplete while still accepting a
796
- * host's own id.
797
- */
798
- type SettingsWidgetSectionId = SettingsSection | (string & {});
799
-
800
- interface WidgetSuiteAccountsSelection {
801
- /** The account whose details are open. `null` is the list. */
802
- accountId?: string | null;
803
- }
804
- interface WidgetSuiteCardsSelection {
805
- /** The card whose details panel is open. `null` closes it. */
806
- cardId?: string | null;
807
- /**
808
- * The list's cursor and page size. Forwarded to the widget's own `pagination`
809
- * and `defaultPagination`, so the suite holds no cursor of its own: leaving
810
- * the section and coming back restarts the walk unless a host drives it.
811
- */
812
- pagination?: CardsWidgetPaginationInput;
813
- }
814
- interface WidgetSuiteSettingsSelection {
815
- /**
816
- * The settings section on screen. The suite holds this one, so it survives
817
- * leaving the section — but hands it down as the widget's
818
- * `defaultSelectedSection`, never its controlled `selectedSection`. The widget
819
- * substitutes another section when this one is not available to the user and
820
- * reports nothing when it does, so a controlled value could disagree with the
821
- * screen with no way to recover; an initial one just loses a deep link the
822
- * user could never have reached.
823
- */
824
- section?: SettingsWidgetSectionId;
825
- }
826
- /**
827
- * Where the suite is pointed, grouped by section.
828
- *
829
- * One object rather than a prop per key: it is the value a host mirrors into its
830
- * URL, and it groups the same way `contentLabels` does. Every key resolves
831
- * independently, so `selection={{ section: 'accounts' }}` drives the menu and
832
- * leaves the account to `defaultSelection`.
833
- *
834
- * Credit and debit cards get separate groups because the Cards section mounts
835
- * two `CardsWidget` instances against two endpoints, so one card id cannot
836
- * address both. There is no `invoicing` group: that section renders the Monite
837
- * `<Receivables />`, whose tab is internal state (EMBD-2171 replaces it,
838
- * EMBD-4979 makes the native tab controllable).
839
- */
840
- interface WidgetSuiteSelection {
841
- section?: WidgetSuiteSectionId;
842
- accounts?: WidgetSuiteAccountsSelection;
843
- creditCards?: WidgetSuiteCardsSelection;
844
- debitCards?: WidgetSuiteCardsSelection;
845
- settings?: WidgetSuiteSettingsSelection;
846
- }
847
- /**
848
- * Where the suite can *open*, which is narrower than what it can be driven to
849
- * whenever a key's widget takes no initial value. Every key has both halves
850
- * today, so nothing is omitted; this is where the next controlled-only key goes.
851
- */
852
- type WidgetSuiteDefaultSelection = WidgetSuiteSelection;
853
- interface WidgetSuiteCardsSelectionSnapshot {
854
- cardId: string | null;
855
- pagination: CardsWidgetPaginationInput | undefined;
856
- }
857
- /**
858
- * The selection as the suite reports it: every key carries a value, so a host
859
- * reading one needs no optional chaining. Assignable to
860
- * {@link WidgetSuiteSelection}, so a host can hand a snapshot straight back.
861
- */
862
- interface WidgetSuiteSelectionSnapshot {
863
- section: WidgetSuiteSectionId | undefined;
864
- accounts: {
865
- accountId: string | null;
866
- };
867
- creditCards: WidgetSuiteCardsSelectionSnapshot;
868
- debitCards: WidgetSuiteCardsSelectionSnapshot;
869
- settings: {
870
- section: SettingsWidgetSectionId | undefined;
871
- };
872
- }
873
-
874
- interface WidgetSuiteProps extends WidgetProviderProps {
875
- /**
876
- * Which sections the suite offers, in menu order.
877
- *
878
- * **Required, with no default, and staying that way.** Defaulting it to the
879
- * whole registry would make a host's page composition invisible at the call
880
- * site, and would grow silently every time a section is added. The wrapper
881
- * that answers this once for a named integrator is a separate package with
882
- * its own repo, so this prop is not waiting to acquire a default here.
883
- *
884
- * A section listed here is still hidden when the token does not earn it, so
885
- * this is the host's ceiling rather than a promise of what renders.
886
- */
887
- sections: readonly WidgetSuiteSectionId[];
888
- /**
889
- * Where the suite is pointed, for a host that owns navigation — a URL, a
890
- * router, its own state. Every key resolves on its own, so driving one leaves
891
- * the rest to the suite.
892
- *
893
- * A key here puts the widget behind it in controlled mode for the lifetime of
894
- * the mount, so supply it with `onSelectionChange` or the surface will not
895
- * move when the user clicks.
896
- */
897
- selection?: WidgetSuiteSelection;
898
- /**
899
- * Where the suite opens, for a host that wants a deep link but not ownership.
900
- * Read once per mount, and ignored per key when `selection` names that key.
901
- *
902
- * Carries every key `selection` does — see {@link WidgetSuiteDefaultSelection}.
903
- */
904
- defaultSelection?: WidgetSuiteDefaultSelection;
905
- /**
906
- * The whole selection after a person moved the suite: a menu click, a row, a
907
- * card, a settings tab, a page of a card list. Every key carries a value, and
908
- * the object can be handed straight back as `selection`.
909
- *
910
- * Never fired for the entitlement fallback, and never fired on mount, so a
911
- * host mirroring this into its URL cannot overwrite the deep link it was just
912
- * handed. A move that touches two keys reports once.
913
- */
914
- onSelectionChange?: (selection: WidgetSuiteSelectionSnapshot) => void;
915
- /** Overrides for the shell's own copy — the nav landmark name, empty state. */
916
- labels?: PartialDeep<WidgetSuiteShellLabels>;
917
- /** Overrides for the section names in the menu. */
918
- sectionLabels?: Partial<WidgetSuiteSectionLabels>;
919
- /**
920
- * Overrides for the section heading's own copy — today the bank tagline, whose
921
- * `{bankName}` placeholder is filled with the bank `/init` names.
922
- */
923
- sectionTitleLabels?: Partial<WidgetSuiteSectionTitleLabels>;
924
- /**
925
- * Overrides for the copy inside a section's panel: the two card-list titles
926
- * and the Expenses placeholder.
927
- */
928
- contentLabels?: PartialDeep<WidgetSuiteContentLabels>;
929
- /**
930
- * Overrides for the copy the disclosure gate owns: its init-failure and
931
- * refresh-failure recovery. The acceptance surface carries its own labels.
932
- */
933
- disclosureLabels?: PartialDeep<WidgetSuiteDisclosureLabels>;
934
- /**
935
- * Shows a heading above each section, named as its menu item is.
936
- *
937
- * Defaults to `true`: the suite owns its page, and a page with a menu but no
938
- * heading reads as a fragment of someone else's. Set `false` when the host
939
- * already renders a heading of its own above the suite.
940
- *
941
- * Every section gets one: no widget heads itself any more (embedded ADR
942
- * 0010), so the suite is the only thing that can name them.
943
- */
944
- showSectionTitle?: boolean;
945
- }
946
- /**
947
- * A suite of widgets bound together by navigation.
948
- *
949
- * Unlike a widget — a content area an integrator drops onto a page they own — a
950
- * suite owns the page it is placed on, exists once per page, and decides which
951
- * widgets appear on it.
952
- *
953
- * One `/init` serves the whole surface: this provider owns the fetch, and every
954
- * composed widget is handed no auth props, so its own provider runs in
955
- * pass-through mode. See `sections.tsx` for the two composition rules that
956
- * arrangement depends on.
957
- *
958
- * That one response also decides which state the suite is in before the shell
959
- * renders: placeholders while init has not settled, a closed retry state when
960
- * init fails before answering the disclosure flags, the acceptance surface
961
- * alone when the session owes the bank's disclosures, or the nav over its
962
- * sections. States rather than an overlay over a mounted shell — see
963
- * `WidgetSuiteSurface` for why each boundary sits where it does.
964
- *
965
- * Navigation is one `selection` object a host can drive key by key, published to
966
- * the sections through `WidgetSuiteProvider`. Only the open panel is mounted, so
967
- * a key the suite holds survives leaving a section and coming back and a key it
968
- * does not hold is lost: today Accounts remembers its open account, Cards its
969
- * open card and Settings its section, while Bill Pay forgets its tab and each
970
- * card list its cursor. That split is the widgets' current shape rather than a
971
- * decision — see `WidgetSuiteSelection` for the ticket behind each gap.
972
- */
973
- declare function WidgetSuite({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, implementation, uiFramework, errorFallback, onError, analytics, disclosuresAcceptance, providerLabels, ...innerProps }: WidgetSuiteProps): React.JSX.Element;
974
-
975
- export { WIDGET_SUITE_CONTENT_LABELS_EN, WIDGET_SUITE_DEFAULT_SECTIONS, WIDGET_SUITE_DISCLOSURE_LABELS_EN, WIDGET_SUITE_SECTION_LABELS_EN, WIDGET_SUITE_SECTION_TITLE_LABELS_EN, WIDGET_SUITE_SHELL_LABELS_EN, WidgetSuite, WidgetSuiteSectionId };
976
- export type { PartialDeep, WidgetSuiteAccountsSelection, WidgetSuiteCardsSelection, WidgetSuiteCardsSelectionSnapshot, WidgetSuiteContentLabels, WidgetSuiteDefaultSelection, WidgetSuiteDisclosureLabels, WidgetSuiteProps, WidgetSuiteSectionLabels, WidgetSuiteSectionTitleLabels, WidgetSuiteSelection, WidgetSuiteSelectionSnapshot, WidgetSuiteSettingsSelection, WidgetSuiteShellLabels };