@tesouro/embedded-components-loader 0.0.0-stage → 0.11.200

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 (42) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +7 -0
  3. package/README.md +316 -2
  4. package/dist/caretRange.d.ts +13 -0
  5. package/dist/caretRange.d.ts.map +1 -0
  6. package/dist/entries.generated.d.ts +34 -0
  7. package/dist/entries.generated.d.ts.map +1 -0
  8. package/dist/index.d.ts +19 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +208 -0
  11. package/dist/loader.d.ts +66 -0
  12. package/dist/loader.d.ts.map +1 -0
  13. package/dist/react/experimental/BalanceHistoryWidget.d.ts +1382 -0
  14. package/dist/react/experimental/QuickViewWidget.d.ts +888 -0
  15. package/dist/react/experimental/RemoteCheckCapture.d.ts +714 -0
  16. package/dist/react/experimental/index.d.ts +1776 -0
  17. package/dist/react/index.d.ts +7429 -0
  18. package/dist/react/lib/AcceptDisclosuresWidget.d.ts +1457 -0
  19. package/dist/react/lib/BalancesWidget.d.ts +647 -0
  20. package/dist/react/lib/BankAccountOnboardingWidget.d.ts +2053 -0
  21. package/dist/react/lib/BankAccountsWidget.d.ts +773 -0
  22. package/dist/react/lib/BankingComplianceBannerWidget.d.ts +647 -0
  23. package/dist/react/lib/BillPayWidget.d.ts +651 -0
  24. package/dist/react/lib/CardDetailsWidget.d.ts +1647 -0
  25. package/dist/react/lib/CounterpartsWidget.d.ts +1698 -0
  26. package/dist/react/lib/CounterpartsWidgetPublic.d.ts +1697 -0
  27. package/dist/react/lib/CreditCardsWidget.d.ts +2153 -0
  28. package/dist/react/lib/DebitCardsWidget.d.ts +2149 -0
  29. package/dist/react/lib/ExpenseManagementWidget.d.ts +835 -0
  30. package/dist/react/lib/InsightsWidget.d.ts +696 -0
  31. package/dist/react/lib/LinkedAccountsWidget.d.ts +726 -0
  32. package/dist/react/lib/OfferWidget.d.ts +1421 -0
  33. package/dist/react/lib/ReceivablesWidget.d.ts +2556 -0
  34. package/dist/react/lib/RecentActivityWidget.d.ts +655 -0
  35. package/dist/react/lib/SettingsWidget.d.ts +775 -0
  36. package/dist/react/lib/TransfersWidget.d.ts +794 -0
  37. package/dist/react/lib/WidgetProvider.d.ts +1305 -0
  38. package/dist/react/lib/WidgetProviderPublic.d.ts +619 -0
  39. package/dist/react/lib/WidgetSuite.d.ts +5664 -0
  40. package/dist/stylesheet.d.ts +3 -0
  41. package/dist/stylesheet.d.ts.map +1 -0
  42. package/package.json +94 -4
@@ -0,0 +1,1382 @@
1
+ import * as React from 'react';
2
+ import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo, CSSProperties } from 'react';
3
+
4
+ /**
5
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
6
+
7
+ @category Type
8
+ */
9
+ type Primitive =
10
+ | null
11
+ | undefined
12
+ | string
13
+ | number
14
+ | boolean
15
+ | symbol
16
+ | bigint;
17
+
18
+ declare global {
19
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
20
+ interface SymbolConstructor {
21
+ readonly observable: symbol;
22
+ }
23
+ }
24
+
25
+ /**
26
+ Extract all optional keys from the given type.
27
+
28
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
29
+
30
+ @example
31
+ ```
32
+ import type {OptionalKeysOf, Except} from 'type-fest';
33
+
34
+ interface User {
35
+ name: string;
36
+ surname: string;
37
+
38
+ luckyNumber?: number;
39
+ }
40
+
41
+ const REMOVE_FIELD = Symbol('remove field symbol');
42
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
43
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
44
+ };
45
+
46
+ const update1: UpdateOperation<User> = {
47
+ name: 'Alice'
48
+ };
49
+
50
+ const update2: UpdateOperation<User> = {
51
+ name: 'Bob',
52
+ luckyNumber: REMOVE_FIELD
53
+ };
54
+ ```
55
+
56
+ @category Utilities
57
+ */
58
+ type OptionalKeysOf<BaseType extends object> =
59
+ BaseType extends unknown // For distributing `BaseType`
60
+ ? (keyof {
61
+ [Key in keyof BaseType as BaseType extends Record<Key, BaseType[Key]> ? never : Key]: never
62
+ }) & (keyof BaseType) // Intersect with `keyof BaseType` to ensure result of `OptionalKeysOf<BaseType>` is always assignable to `keyof BaseType`
63
+ : never; // Should never happen
64
+
65
+ /**
66
+ Extract all required keys from the given type.
67
+
68
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
69
+
70
+ @example
71
+ ```
72
+ import type {RequiredKeysOf} from 'type-fest';
73
+
74
+ declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
75
+
76
+ interface User {
77
+ name: string;
78
+ surname: string;
79
+
80
+ luckyNumber?: number;
81
+ }
82
+
83
+ const validator1 = createValidation<User>('name', value => value.length < 25);
84
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
85
+ ```
86
+
87
+ @category Utilities
88
+ */
89
+ type RequiredKeysOf<BaseType extends object> =
90
+ BaseType extends unknown // For distributing `BaseType`
91
+ ? Exclude<keyof BaseType, OptionalKeysOf<BaseType>>
92
+ : never; // Should never happen
93
+
94
+ /**
95
+ Returns a boolean for whether the given type is `never`.
96
+
97
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
98
+ @link https://stackoverflow.com/a/53984913/10292952
99
+ @link https://www.zhenghao.io/posts/ts-never
100
+
101
+ Useful in type utilities, such as checking if something does not occur.
102
+
103
+ @example
104
+ ```
105
+ import type {IsNever, And} from 'type-fest';
106
+
107
+ // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
108
+ type AreStringsEqual<A extends string, B extends string> =
109
+ And<
110
+ IsNever<Exclude<A, B>> extends true ? true : false,
111
+ IsNever<Exclude<B, A>> extends true ? true : false
112
+ >;
113
+
114
+ type EndIfEqual<I extends string, O extends string> =
115
+ AreStringsEqual<I, O> extends true
116
+ ? never
117
+ : void;
118
+
119
+ function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
120
+ if (input === output) {
121
+ process.exit(0);
122
+ }
123
+ }
124
+
125
+ endIfEqual('abc', 'abc');
126
+ //=> never
127
+
128
+ endIfEqual('abc', '123');
129
+ //=> void
130
+ ```
131
+
132
+ @category Type Guard
133
+ @category Utilities
134
+ */
135
+ type IsNever<T> = [T] extends [never] ? true : false;
136
+
137
+ /**
138
+ An if-else-like type that resolves depending on whether the given type is `never`.
139
+
140
+ @see {@link IsNever}
141
+
142
+ @example
143
+ ```
144
+ import type {IfNever} from 'type-fest';
145
+
146
+ type ShouldBeTrue = IfNever<never>;
147
+ //=> true
148
+
149
+ type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>;
150
+ //=> 'bar'
151
+ ```
152
+
153
+ @category Type Guard
154
+ @category Utilities
155
+ */
156
+ type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = (
157
+ IsNever<T> extends true ? TypeIfNever : TypeIfNotNever
158
+ );
159
+
160
+ // Can eventually be replaced with the built-in once this library supports
161
+ // TS5.4+ only. Tracked in https://github.com/sindresorhus/type-fest/issues/848
162
+ type NoInfer<T> = T extends infer U ? U : never;
163
+
164
+ /**
165
+ Returns a boolean for whether the given type is `any`.
166
+
167
+ @link https://stackoverflow.com/a/49928360/1490091
168
+
169
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
170
+
171
+ @example
172
+ ```
173
+ import type {IsAny} from 'type-fest';
174
+
175
+ const typedObject = {a: 1, b: 2} as const;
176
+ const anyObject: any = {a: 1, b: 2};
177
+
178
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
179
+ return obj[key];
180
+ }
181
+
182
+ const typedA = get(typedObject, 'a');
183
+ //=> 1
184
+
185
+ const anyA = get(anyObject, 'a');
186
+ //=> any
187
+ ```
188
+
189
+ @category Type Guard
190
+ @category Utilities
191
+ */
192
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
193
+
194
+ /**
195
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
196
+
197
+ @example
198
+ ```
199
+ import type {Simplify} from 'type-fest';
200
+
201
+ type PositionProps = {
202
+ top: number;
203
+ left: number;
204
+ };
205
+
206
+ type SizeProps = {
207
+ width: number;
208
+ height: number;
209
+ };
210
+
211
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
212
+ type Props = Simplify<PositionProps & SizeProps>;
213
+ ```
214
+
215
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
216
+
217
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
218
+
219
+ @example
220
+ ```
221
+ import type {Simplify} from 'type-fest';
222
+
223
+ interface SomeInterface {
224
+ foo: number;
225
+ bar?: string;
226
+ baz: number | undefined;
227
+ }
228
+
229
+ type SomeType = {
230
+ foo: number;
231
+ bar?: string;
232
+ baz: number | undefined;
233
+ };
234
+
235
+ const literal = {foo: 123, bar: 'hello', baz: 456};
236
+ const someType: SomeType = literal;
237
+ const someInterface: SomeInterface = literal;
238
+
239
+ function fn(object: Record<string, unknown>): void {}
240
+
241
+ fn(literal); // Good: literal object type is sealed
242
+ fn(someType); // Good: type is sealed
243
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
244
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
245
+ ```
246
+
247
+ @link https://github.com/microsoft/TypeScript/issues/15300
248
+ @see SimplifyDeep
249
+ @category Object
250
+ */
251
+ type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
252
+
253
+ /**
254
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
255
+
256
+ This is the counterpart of `PickIndexSignature`.
257
+
258
+ Use-cases:
259
+ - Remove overly permissive signatures from third-party types.
260
+
261
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
262
+
263
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
264
+
265
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
266
+
267
+ ```
268
+ const indexed: Record<string, unknown> = {}; // Allowed
269
+
270
+ const keyed: Record<'foo', unknown> = {}; // Error
271
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
272
+ ```
273
+
274
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
275
+
276
+ ```
277
+ type Indexed = {} extends Record<string, unknown>
278
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
279
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
280
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
281
+
282
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
283
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
284
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
285
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
286
+ ```
287
+
288
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
289
+
290
+ ```
291
+ import type {OmitIndexSignature} from 'type-fest';
292
+
293
+ type OmitIndexSignature<ObjectType> = {
294
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
295
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
296
+ };
297
+ ```
298
+
299
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
300
+
301
+ ```
302
+ import type {OmitIndexSignature} from 'type-fest';
303
+
304
+ type OmitIndexSignature<ObjectType> = {
305
+ [KeyType in keyof ObjectType
306
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
307
+ as {} extends Record<KeyType, unknown>
308
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
309
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
310
+ ]: ObjectType[KeyType];
311
+ };
312
+ ```
313
+
314
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
315
+
316
+ @example
317
+ ```
318
+ import type {OmitIndexSignature} from 'type-fest';
319
+
320
+ interface Example {
321
+ // These index signatures will be removed.
322
+ [x: string]: any
323
+ [x: number]: any
324
+ [x: symbol]: any
325
+ [x: `head-${string}`]: string
326
+ [x: `${string}-tail`]: string
327
+ [x: `head-${string}-tail`]: string
328
+ [x: `${bigint}`]: string
329
+ [x: `embedded-${number}`]: string
330
+
331
+ // These explicitly defined keys will remain.
332
+ foo: 'bar';
333
+ qux?: 'baz';
334
+ }
335
+
336
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
337
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
338
+ ```
339
+
340
+ @see PickIndexSignature
341
+ @category Object
342
+ */
343
+ type OmitIndexSignature<ObjectType> = {
344
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
345
+ ? never
346
+ : KeyType]: ObjectType[KeyType];
347
+ };
348
+
349
+ /**
350
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
351
+
352
+ This is the counterpart of `OmitIndexSignature`.
353
+
354
+ @example
355
+ ```
356
+ import type {PickIndexSignature} from 'type-fest';
357
+
358
+ declare const symbolKey: unique symbol;
359
+
360
+ type Example = {
361
+ // These index signatures will remain.
362
+ [x: string]: unknown;
363
+ [x: number]: unknown;
364
+ [x: symbol]: unknown;
365
+ [x: `head-${string}`]: string;
366
+ [x: `${string}-tail`]: string;
367
+ [x: `head-${string}-tail`]: string;
368
+ [x: `${bigint}`]: string;
369
+ [x: `embedded-${number}`]: string;
370
+
371
+ // These explicitly defined keys will be removed.
372
+ ['kebab-case-key']: string;
373
+ [symbolKey]: string;
374
+ foo: 'bar';
375
+ qux?: 'baz';
376
+ };
377
+
378
+ type ExampleIndexSignature = PickIndexSignature<Example>;
379
+ // {
380
+ // [x: string]: unknown;
381
+ // [x: number]: unknown;
382
+ // [x: symbol]: unknown;
383
+ // [x: `head-${string}`]: string;
384
+ // [x: `${string}-tail`]: string;
385
+ // [x: `head-${string}-tail`]: string;
386
+ // [x: `${bigint}`]: string;
387
+ // [x: `embedded-${number}`]: string;
388
+ // }
389
+ ```
390
+
391
+ @see OmitIndexSignature
392
+ @category Object
393
+ */
394
+ type PickIndexSignature<ObjectType> = {
395
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
396
+ ? KeyType
397
+ : never]: ObjectType[KeyType];
398
+ };
399
+
400
+ // Merges two objects without worrying about index signatures.
401
+ type SimpleMerge<Destination, Source> = {
402
+ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
403
+ } & Source;
404
+
405
+ /**
406
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
407
+
408
+ @example
409
+ ```
410
+ import type {Merge} from 'type-fest';
411
+
412
+ interface Foo {
413
+ [x: string]: unknown;
414
+ [x: number]: unknown;
415
+ foo: string;
416
+ bar: symbol;
417
+ }
418
+
419
+ type Bar = {
420
+ [x: number]: number;
421
+ [x: symbol]: unknown;
422
+ bar: Date;
423
+ baz: boolean;
424
+ };
425
+
426
+ export type FooBar = Merge<Foo, Bar>;
427
+ // => {
428
+ // [x: string]: unknown;
429
+ // [x: number]: number;
430
+ // [x: symbol]: unknown;
431
+ // foo: string;
432
+ // bar: Date;
433
+ // baz: boolean;
434
+ // }
435
+ ```
436
+
437
+ @category Object
438
+ */
439
+ type Merge<Destination, Source> =
440
+ Simplify<
441
+ SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
442
+ & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
443
+ >;
444
+
445
+ /**
446
+ An if-else-like type that resolves depending on whether the given type is `any`.
447
+
448
+ @see {@link IsAny}
449
+
450
+ @example
451
+ ```
452
+ import type {IfAny} from 'type-fest';
453
+
454
+ type ShouldBeTrue = IfAny<any>;
455
+ //=> true
456
+
457
+ type ShouldBeBar = IfAny<'not any', 'foo', 'bar'>;
458
+ //=> 'bar'
459
+ ```
460
+
461
+ @category Type Guard
462
+ @category Utilities
463
+ */
464
+ type IfAny<T, TypeIfAny = true, TypeIfNotAny = false> = (
465
+ IsAny<T> extends true ? TypeIfAny : TypeIfNotAny
466
+ );
467
+
468
+ /**
469
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
470
+ */
471
+ type BuiltIns = Primitive | void | Date | RegExp;
472
+
473
+ /**
474
+ Merges user specified options with default options.
475
+
476
+ @example
477
+ ```
478
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
479
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
480
+ type SpecifiedOptions = {leavesOnly: true};
481
+
482
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
483
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
484
+ ```
485
+
486
+ @example
487
+ ```
488
+ // Complains if default values are not provided for optional options
489
+
490
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
491
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
492
+ type SpecifiedOptions = {};
493
+
494
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
495
+ // ~~~~~~~~~~~~~~~~~~~
496
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
497
+ ```
498
+
499
+ @example
500
+ ```
501
+ // Complains if an option's default type does not conform to the expected type
502
+
503
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
504
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
505
+ type SpecifiedOptions = {};
506
+
507
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
508
+ // ~~~~~~~~~~~~~~~~~~~
509
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
510
+ ```
511
+
512
+ @example
513
+ ```
514
+ // Complains if an option's specified type does not conform to the expected type
515
+
516
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
517
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
518
+ type SpecifiedOptions = {leavesOnly: 'yes'};
519
+
520
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
521
+ // ~~~~~~~~~~~~~~~~
522
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
523
+ ```
524
+ */
525
+ type ApplyDefaultOptions<
526
+ Options extends object,
527
+ Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
528
+ SpecifiedOptions extends Options,
529
+ > =
530
+ IfAny<SpecifiedOptions, Defaults,
531
+ IfNever<SpecifiedOptions, Defaults,
532
+ Simplify<Merge<Defaults, {
533
+ [Key in keyof SpecifiedOptions
534
+ as Key extends OptionalKeysOf<Options>
535
+ ? Extract<SpecifiedOptions[Key], undefined> extends never
536
+ ? Key
537
+ : never
538
+ : Key
539
+ ]: SpecifiedOptions[Key]
540
+ }> & Required<Options>> // `& Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
541
+ >>;
542
+
543
+ /**
544
+ @see {@link PartialDeep}
545
+ */
546
+ type PartialDeepOptions = {
547
+ /**
548
+ Whether to affect the individual elements of arrays and tuples.
549
+
550
+ @default false
551
+ */
552
+ readonly recurseIntoArrays?: boolean;
553
+
554
+ /**
555
+ Allows `undefined` values in non-tuple arrays.
556
+
557
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
558
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
559
+
560
+ @default true
561
+
562
+ @example
563
+ You can prevent `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}` as the second type argument:
564
+
565
+ ```
566
+ import type {PartialDeep} from 'type-fest';
567
+
568
+ type Settings = {
569
+ languages: string[];
570
+ };
571
+
572
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: false}>;
573
+
574
+ partialSettings.languages = [undefined]; // Error
575
+ partialSettings.languages = []; // Ok
576
+ ```
577
+ */
578
+ readonly allowUndefinedInNonTupleArrays?: boolean;
579
+ };
580
+
581
+ type DefaultPartialDeepOptions = {
582
+ recurseIntoArrays: false;
583
+ allowUndefinedInNonTupleArrays: true;
584
+ };
585
+
586
+ /**
587
+ Create a type from another type with all keys and nested keys set to optional.
588
+
589
+ Use-cases:
590
+ - Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
591
+ - Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
592
+
593
+ @example
594
+ ```
595
+ import type {PartialDeep} from 'type-fest';
596
+
597
+ const settings: Settings = {
598
+ textEditor: {
599
+ fontSize: 14,
600
+ fontColor: '#000000',
601
+ fontWeight: 400
602
+ },
603
+ autocomplete: false,
604
+ autosave: true
605
+ };
606
+
607
+ const applySavedSettings = (savedSettings: PartialDeep<Settings>) => {
608
+ return {...settings, ...savedSettings};
609
+ }
610
+
611
+ settings = applySavedSettings({textEditor: {fontWeight: 500}});
612
+ ```
613
+
614
+ By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
615
+
616
+ ```
617
+ import type {PartialDeep} from 'type-fest';
618
+
619
+ type Settings = {
620
+ languages: string[];
621
+ }
622
+
623
+ const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true}> = {
624
+ languages: [undefined]
625
+ };
626
+ ```
627
+
628
+ @see {@link PartialDeepOptions}
629
+
630
+ @category Object
631
+ @category Array
632
+ @category Set
633
+ @category Map
634
+ */
635
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> =
636
+ _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
637
+
638
+ type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown))
639
+ ? T
640
+ : IsNever<keyof T> extends true // For functions with no properties
641
+ ? T
642
+ : T extends Map<infer KeyType, infer ValueType>
643
+ ? PartialMapDeep<KeyType, ValueType, Options>
644
+ : T extends Set<infer ItemType>
645
+ ? PartialSetDeep<ItemType, Options>
646
+ : T extends ReadonlyMap<infer KeyType, infer ValueType>
647
+ ? PartialReadonlyMapDeep<KeyType, ValueType, Options>
648
+ : T extends ReadonlySet<infer ItemType>
649
+ ? PartialReadonlySetDeep<ItemType, Options>
650
+ : T extends object
651
+ ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
652
+ ? Options['recurseIntoArrays'] extends true
653
+ ? ItemType[] extends T // Test for arrays (non-tuples) specifically
654
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
655
+ ? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
656
+ : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>>
657
+ : PartialObjectDeep<T, Options> // Tuples behave properly
658
+ : T // If they don't opt into array testing, just use the original type
659
+ : PartialObjectDeep<T, Options>
660
+ : unknown;
661
+
662
+ /**
663
+ Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
664
+ */
665
+ type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
666
+
667
+ /**
668
+ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
669
+ */
670
+ type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
671
+
672
+ /**
673
+ Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
674
+ */
675
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
676
+
677
+ /**
678
+ Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
679
+ */
680
+ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
681
+
682
+ /**
683
+ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
684
+ */
685
+ type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> =
686
+ (ObjectType extends (...arguments_: any) => unknown
687
+ ? (...arguments_: Parameters<ObjectType>) => ReturnType<ObjectType>
688
+ : {}) & ({
689
+ [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options>
690
+ });
691
+
692
+ declare type FallbackProps = {
693
+ error: unknown;
694
+ resetErrorBoundary: (...args: unknown[]) => void;
695
+ };
696
+
697
+ type AuthToken = string | undefined;
698
+ interface Auth {
699
+ /**
700
+ * Which part of the request do we use to send the auth?
701
+ *
702
+ * @default 'header'
703
+ */
704
+ in?: 'header' | 'query' | 'cookie';
705
+ /**
706
+ * A unique identifier for the security scheme.
707
+ *
708
+ * Defined only when there are multiple security schemes whose `Auth`
709
+ * shape would otherwise be identical.
710
+ */
711
+ key?: string;
712
+ /**
713
+ * Header or query parameter name.
714
+ *
715
+ * @default 'Authorization'
716
+ */
717
+ name?: string;
718
+ scheme?: 'basic' | 'bearer';
719
+ type: 'apiKey' | 'http';
720
+ }
721
+
722
+ interface SerializerOptions<T> {
723
+ /**
724
+ * @default true
725
+ */
726
+ explode: boolean;
727
+ style: T;
728
+ }
729
+ type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
730
+ type ObjectStyle = 'form' | 'deepObject';
731
+
732
+ type QuerySerializer = (query: Record<string, unknown>) => string;
733
+ type BodySerializer = (body: unknown) => unknown;
734
+ type QuerySerializerOptionsObject = {
735
+ allowReserved?: boolean;
736
+ array?: Partial<SerializerOptions<ArrayStyle>>;
737
+ object?: Partial<SerializerOptions<ObjectStyle>>;
738
+ };
739
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
740
+ /**
741
+ * Per-parameter serialization overrides. When provided, these settings
742
+ * override the global array/object settings for specific parameter names.
743
+ */
744
+ parameters?: Record<string, QuerySerializerOptionsObject>;
745
+ };
746
+
747
+ type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
748
+ type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
749
+ /**
750
+ * Returns the final request URL.
751
+ */
752
+ buildUrl: BuildUrlFn;
753
+ getConfig: () => Config;
754
+ request: RequestFn;
755
+ setConfig: (config: Config) => Config;
756
+ } & {
757
+ [K in HttpMethod]: MethodFn;
758
+ } & ([SseFn] extends [never] ? {
759
+ sse?: never;
760
+ } : {
761
+ sse: {
762
+ [K in HttpMethod]: SseFn;
763
+ };
764
+ });
765
+ interface Config$1 {
766
+ /**
767
+ * Auth token or a function returning auth token. The resolved value will be
768
+ * added to the request payload as defined by its `security` array.
769
+ */
770
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
771
+ /**
772
+ * A function for serializing request body parameter. By default,
773
+ * {@link JSON.stringify()} will be used.
774
+ */
775
+ bodySerializer?: BodySerializer | null;
776
+ /**
777
+ * An object containing any HTTP headers that you want to pre-populate your
778
+ * `Headers` object with.
779
+ *
780
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
781
+ */
782
+ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
783
+ /**
784
+ * The request method.
785
+ *
786
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
787
+ */
788
+ method?: Uppercase<HttpMethod>;
789
+ /**
790
+ * A function for serializing request query parameters. By default, arrays
791
+ * will be exploded in form style, objects will be exploded in deepObject
792
+ * style, and reserved characters are percent-encoded.
793
+ *
794
+ * This method will have no effect if the native `paramsSerializer()` Axios
795
+ * API function is used.
796
+ *
797
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
798
+ */
799
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
800
+ /**
801
+ * A function validating request data. This is useful if you want to ensure
802
+ * the request conforms to the desired shape, so it can be safely sent to
803
+ * the server.
804
+ */
805
+ requestValidator?: (data: unknown) => Promise<unknown>;
806
+ /**
807
+ * A function transforming response data before it's returned. This is useful
808
+ * for post-processing data, e.g., converting ISO strings into Date objects.
809
+ */
810
+ responseTransformer?: (data: unknown) => Promise<unknown>;
811
+ /**
812
+ * A function validating response data. This is useful if you want to ensure
813
+ * the response conforms to the desired shape, so it can be safely passed to
814
+ * the transformers and returned to the user.
815
+ */
816
+ responseValidator?: (data: unknown) => Promise<unknown>;
817
+ }
818
+
819
+ type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
820
+ /**
821
+ * Fetch API implementation. You can use this option to provide a custom
822
+ * fetch instance.
823
+ *
824
+ * @default globalThis.fetch
825
+ */
826
+ fetch?: typeof fetch;
827
+ /**
828
+ * Implementing clients can call request interceptors inside this hook.
829
+ */
830
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
831
+ /**
832
+ * Callback invoked when a network or parsing error occurs during streaming.
833
+ *
834
+ * This option applies only if the endpoint returns a stream of events.
835
+ *
836
+ * @param error The error that occurred.
837
+ */
838
+ onSseError?: (error: unknown) => void;
839
+ /**
840
+ * Callback invoked when an event is streamed from the server.
841
+ *
842
+ * This option applies only if the endpoint returns a stream of events.
843
+ *
844
+ * @param event Event streamed from the server.
845
+ * @returns Nothing (void).
846
+ */
847
+ onSseEvent?: (event: StreamEvent<TData>) => void;
848
+ serializedBody?: RequestInit['body'];
849
+ /**
850
+ * Default retry delay in milliseconds.
851
+ *
852
+ * This option applies only if the endpoint returns a stream of events.
853
+ *
854
+ * @default 3000
855
+ */
856
+ sseDefaultRetryDelay?: number;
857
+ /**
858
+ * Maximum number of retry attempts before giving up.
859
+ */
860
+ sseMaxRetryAttempts?: number;
861
+ /**
862
+ * Maximum retry delay in milliseconds.
863
+ *
864
+ * Applies only when exponential backoff is used.
865
+ *
866
+ * This option applies only if the endpoint returns a stream of events.
867
+ *
868
+ * @default 30000
869
+ */
870
+ sseMaxRetryDelay?: number;
871
+ /**
872
+ * Optional sleep function for retry backoff.
873
+ *
874
+ * Defaults to using `setTimeout`.
875
+ */
876
+ sseSleepFn?: (ms: number) => Promise<void>;
877
+ url: string;
878
+ };
879
+ interface StreamEvent<TData = unknown> {
880
+ data: TData;
881
+ event?: string;
882
+ id?: string;
883
+ retry?: number;
884
+ }
885
+ type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
886
+ stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
887
+ };
888
+
889
+ type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
890
+ /** response may be undefined due to a network error where no response object is produced */
891
+ response: Res | undefined,
892
+ /** request may be undefined, because error may be from building the request object itself */
893
+ request: Req | undefined, options: Options) => Err | Promise<Err>;
894
+ type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
895
+ type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
896
+ declare class Interceptors<Interceptor> {
897
+ fns: Array<Interceptor | null>;
898
+ clear(): void;
899
+ eject(id: number | Interceptor): void;
900
+ exists(id: number | Interceptor): boolean;
901
+ getInterceptorIndex(id: number | Interceptor): number;
902
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
903
+ use(fn: Interceptor): number;
904
+ }
905
+ interface Middleware<Req, Res, Err, Options> {
906
+ error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
907
+ request: Interceptors<ReqInterceptor<Req, Options>>;
908
+ response: Interceptors<ResInterceptor<Res, Req, Options>>;
909
+ }
910
+
911
+ type ResponseStyle = 'data' | 'fields';
912
+ interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
913
+ /**
914
+ * Base URL for all requests made by this client.
915
+ */
916
+ baseUrl?: T['baseUrl'];
917
+ /**
918
+ * Fetch API implementation. You can use this option to provide a custom
919
+ * fetch instance.
920
+ *
921
+ * @default globalThis.fetch
922
+ */
923
+ fetch?: typeof fetch;
924
+ /**
925
+ * Please don't use the Fetch client for Next.js applications. The `next`
926
+ * options won't have any effect.
927
+ *
928
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
929
+ */
930
+ next?: never;
931
+ /**
932
+ * Return the response data parsed in a specified format. By default, `auto`
933
+ * will infer the appropriate method from the `Content-Type` response header.
934
+ * You can override this behavior with any of the {@link Body} methods.
935
+ * Select `stream` if you don't want to parse response data at all.
936
+ *
937
+ * @default 'auto'
938
+ */
939
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
940
+ /**
941
+ * Should we return only data or multiple fields (data, error, response, etc.)?
942
+ *
943
+ * @default 'fields'
944
+ */
945
+ responseStyle?: ResponseStyle;
946
+ /**
947
+ * Throw an error instead of returning it in the response?
948
+ *
949
+ * @default false
950
+ */
951
+ throwOnError?: T['throwOnError'];
952
+ }
953
+ interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
954
+ responseStyle: TResponseStyle;
955
+ throwOnError: ThrowOnError;
956
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
957
+ /**
958
+ * Any body that you want to add to your request.
959
+ *
960
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
961
+ */
962
+ body?: unknown;
963
+ path?: Record<string, unknown>;
964
+ query?: Record<string, unknown>;
965
+ /**
966
+ * Security mechanism(s) to use for the request.
967
+ */
968
+ security?: ReadonlyArray<Auth>;
969
+ url: Url;
970
+ }
971
+ interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
972
+ headers: Headers;
973
+ serializedBody?: string;
974
+ }
975
+ 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 : {
976
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
977
+ request: Request;
978
+ response: Response;
979
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
980
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
981
+ error: undefined;
982
+ } | {
983
+ data: undefined;
984
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
985
+ }) & {
986
+ /** request may be undefined, because error may be from building the request object itself */
987
+ request?: Request;
988
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
989
+ response?: Response;
990
+ }>;
991
+ interface ClientOptions$1 {
992
+ baseUrl?: string;
993
+ responseStyle?: ResponseStyle;
994
+ throwOnError?: boolean;
995
+ }
996
+ 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>;
997
+ type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
998
+ 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>;
999
+ type BuildUrlFn = <TData extends {
1000
+ body?: unknown;
1001
+ path?: Record<string, unknown>;
1002
+ query?: Record<string, unknown>;
1003
+ url: string;
1004
+ }>(options: TData & Options<TData>) => string;
1005
+ type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
1006
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
1007
+ };
1008
+ interface TDataShape {
1009
+ body?: unknown;
1010
+ headers?: unknown;
1011
+ path?: unknown;
1012
+ query?: unknown;
1013
+ url: string;
1014
+ }
1015
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
1016
+ 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'>);
1017
+
1018
+ type ClientOptions = {
1019
+ 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 & {});
1020
+ };
1021
+
1022
+ type EmbeddedClient = Client;
1023
+ type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
1024
+ type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
1025
+
1026
+ type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
1027
+ children?: ReactNode;
1028
+ };
1029
+ type LinkComponent = ComponentType<LinkComponentProps>;
1030
+ /**
1031
+ * The UI frameworks a widget's UI layer can render with.
1032
+ *
1033
+ * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
1034
+ * implicit fallback, so existing consumers that select nothing keep rendering
1035
+ * shadcn.
1036
+ * - `tecton` — the Tecton implementation.
1037
+ *
1038
+ * Declared as an `as const` object (not a TypeScript `enum`) per repo
1039
+ * convention.
1040
+ */
1041
+ declare const UIFramework: {
1042
+ readonly Shadcn: "shadcn";
1043
+ readonly Tecton: "tecton";
1044
+ };
1045
+ type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
1046
+
1047
+ /**
1048
+ * The settable fields of the widget config cascade.
1049
+ *
1050
+ * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
1051
+ * It intentionally excludes `initResponse`, which is populated automatically by the
1052
+ * provider after a successful fetch and must never be set manually.
1053
+ *
1054
+ * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
1055
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
1056
+ * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
1057
+ * (e.g. after logout or deliberate de-scoping).
1058
+ *
1059
+ * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
1060
+ * @see {@link RootWidgetProvider}
1061
+ * @see {@link WidgetProvider}
1062
+ * @see {@link setGlobalWidgetConfig}
1063
+ */
1064
+ interface WidgetConfigInput {
1065
+ /**
1066
+ * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
1067
+ *
1068
+ * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
1069
+ * Changing this recreates the underlying HTTP client so all subsequent requests
1070
+ * go to the new host.
1071
+ */
1072
+ baseUrl?: BaseUrl;
1073
+ /**
1074
+ * Bearer token used to authenticate widget requests.
1075
+ *
1076
+ * Injected as `Authorization: Bearer <token>` on every outgoing request via an
1077
+ * interceptor on the scoped HTTP client. Token updates are picked up immediately
1078
+ * without recreating the client.
1079
+ *
1080
+ * - `string` — send this token on all requests from this level downward.
1081
+ * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
1082
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
1083
+ */
1084
+ widgetToken?: string | null;
1085
+ /**
1086
+ * Organization ID forwarded as the `x-organization-id` request header.
1087
+ *
1088
+ * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
1089
+ * so individual data-access hooks can opt in per-request.
1090
+ *
1091
+ * - `string` — use this organization for downstream data requests.
1092
+ * - `null` — explicitly cleared; queries that require an org ID will be disabled.
1093
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
1094
+ *
1095
+ * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
1096
+ * value), the resolved org defaults to the loaded `initResponse.organizationId`
1097
+ * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
1098
+ * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
1099
+ * level wins, and an explicit `null` is preserved and never falls back.
1100
+ *
1101
+ * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
1102
+ * default does not propagate into a descendant that owns its own fetch (its own
1103
+ * `baseUrl`/`widgetToken`); such a descendant defaults to its own
1104
+ * `initResponse.organizationId` instead, so it never sends an ancestor's org with
1105
+ * its own token.
1106
+ */
1107
+ organizationId?: string | null;
1108
+ /**
1109
+ * Optional post-creation hook for the scoped HTTP client.
1110
+ *
1111
+ * Called once after the provider creates its scoped {@link EmbeddedClient} and
1112
+ * applies the built-in `Authorization: Bearer` interceptor. Receives the
1113
+ * fully-configured client and must return the client to be used for the lifetime of
1114
+ * this provider level — either the same instance (with additional interceptors
1115
+ * attached) or a new client entirely.
1116
+ *
1117
+ * **Order:** The built-in auth interceptor is always applied first. `configClient`
1118
+ * is called on top of it, so any interceptors you add here run after auth is set.
1119
+ *
1120
+ * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
1121
+ * scoped client whenever any prop is set — including `configClient` alone, without
1122
+ * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
1123
+ * client creation and never calls this function.
1124
+ *
1125
+ * **Stability:** The function reference is included in the client creation memo's
1126
+ * dependency array. Passing an unstable (inline) function recreates the client on
1127
+ * every render. Stabilize with `useCallback` or define the function outside the
1128
+ * component.
1129
+ *
1130
+ * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
1131
+ * {@link WidgetProvider} that creates its own scoped client will use the resolved
1132
+ * `configClient` from the cascade unless it provides its own override.
1133
+ *
1134
+ * @example
1135
+ * ```tsx
1136
+ * const addLogging = useCallback(
1137
+ * (client: EmbeddedClient) => {
1138
+ * client.interceptors.request.use((req) => {
1139
+ * console.log('[widget]', req.method, req.url);
1140
+ * return req;
1141
+ * });
1142
+ * return client;
1143
+ * },
1144
+ * [],
1145
+ * );
1146
+ *
1147
+ * <RootWidgetProvider
1148
+ * baseUrl="https://api.tesouro.com"
1149
+ * widgetToken={token}
1150
+ * configClient={addLogging}
1151
+ * >
1152
+ * <App />
1153
+ * </RootWidgetProvider>
1154
+ * ```
1155
+ */
1156
+ configClient?: (client: EmbeddedClient) => EmbeddedClient;
1157
+ /**
1158
+ * Overrides the widget-gateway routing decision for the scoped HTTP client.
1159
+ *
1160
+ * Any caller reaching the Tesouro API with a widget token must route data
1161
+ * requests through the widget gateway: prefix the path with
1162
+ * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
1163
+ * provider applies both automatically per request when the request origin is
1164
+ * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
1165
+ * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
1166
+ * init round-trip) always pass through untouched.
1167
+ *
1168
+ * - `undefined` — decide from the request origin, as above. Inherits from
1169
+ * the nearest ancestor or global store like every other config field.
1170
+ * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
1171
+ * custom domain in front of the gateway).
1172
+ * - `false` — never apply it. For hosts that route widget requests their own
1173
+ * way, such as a same-origin BFF whose `configClient` retargets every
1174
+ * request.
1175
+ *
1176
+ * Independent of {@link configClient}: a host that only adds a header keeps
1177
+ * the built-in routing, and the built-in interceptor runs before any
1178
+ * `configClient` interceptor.
1179
+ */
1180
+ gatewayRouting?: boolean;
1181
+ /**
1182
+ * Component the embedded widgets should render in place of plain `<a>` tags.
1183
+ *
1184
+ * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
1185
+ * Cascades like other config: provider prop > nearest ancestor > global store.
1186
+ * When no value is set anywhere, widgets fall back to a plain `<a>` element.
1187
+ */
1188
+ linkComponent?: LinkComponent;
1189
+ /**
1190
+ * Which UI framework the widget UI layer should render with.
1191
+ *
1192
+ * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
1193
+ * Tecton implementation behind the same outward-facing API. The selection is
1194
+ * a presentation concern only — it cascades through the provider tree exactly
1195
+ * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
1196
+ * it never appears in any widget's feature-library or component props.
1197
+ *
1198
+ * - `'shadcn'` — the shadcn/Tailwind implementation.
1199
+ * - `'tecton'` — the Tecton implementation.
1200
+ * - `null` / `undefined` — not set at this level; inherit from the nearest
1201
+ * ancestor or global store, falling back to `shadcn` when unset everywhere.
1202
+ * `shadcn` is the implicit default, so existing consumers need no changes.
1203
+ */
1204
+ uiFramework?: UIFramework | null;
1205
+ }
1206
+ /**
1207
+ * Props shared by every analytics-owner-capable widget provider.
1208
+ *
1209
+ * Combines the full settable cascade ({@link WidgetConfigInput}) with the
1210
+ * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
1211
+ * and {@link WidgetProvider} build their public props on top of this; the latter
1212
+ * adds error-boundary props of its own.
1213
+ *
1214
+ * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
1215
+ */
1216
+ interface WidgetProviderBaseProps extends WidgetConfigInput {
1217
+ /**
1218
+ * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
1219
+ *
1220
+ * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
1221
+ * standalone {@link WidgetProvider} with no parent provider. When `false`,
1222
+ * owner-bound `track` calls in this subtree become no-ops and the PostHog
1223
+ * installer is never dynamically imported for this owner's environment.
1224
+ * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
1225
+ * `console.warn` is emitted to make the no-op discoverable).
1226
+ */
1227
+ analytics?: boolean;
1228
+ }
1229
+
1230
+ /**
1231
+ * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
1232
+ * the error-boundary fallback and the disclosures gate. A host overrides any
1233
+ * subset through the `providerLabels` prop, which cascades like
1234
+ * `disclosuresAcceptance`.
1235
+ *
1236
+ * Not named `Labels` on the public surface: a widget's own `labels` prop is a
1237
+ * different thing, and these two travel together on every widget's props type.
1238
+ */
1239
+ interface WidgetProviderLabels {
1240
+ /** Default copy for the built-in error boundary fallback. */
1241
+ errorBoundaryFallback: string;
1242
+ /** Heading when init reports disclosures are required and not yet accepted. */
1243
+ disclosuresRequiredTitle: string;
1244
+ /** Heading while a token-only refresh leaves init stale for the live token. */
1245
+ disclosuresRefreshingTitle: string;
1246
+ /** Supporting copy while the accept action is withheld for a stale init. */
1247
+ disclosuresRefreshingDescription: string;
1248
+ }
1249
+
1250
+ /**
1251
+ * Props for {@link WidgetProvider}.
1252
+ *
1253
+ * All fields are optional. When **all** are omitted the provider is a transparent
1254
+ * pass-through: no fetch is issued and all resolved values cascade unchanged from
1255
+ * the nearest ancestor.
1256
+ */
1257
+ interface WidgetProviderProps extends WidgetProviderBaseProps {
1258
+ /**
1259
+ * Fallback rendered when a render-time exception is caught inside this
1260
+ * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
1261
+ * render-prop receiving `{ error, resetErrorBoundary }` from
1262
+ * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
1263
+ * comes from `providerLabels.errorBoundaryFallback`.
1264
+ */
1265
+ errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
1266
+ /**
1267
+ * Called once when the boundary catches an error, before the fallback
1268
+ * renders. Use for telemetry / error tracking / partner logging. Exceptions
1269
+ * thrown from `onError` propagate per `react-error-boundary` semantics.
1270
+ */
1271
+ onError?: (error: unknown, info: ErrorInfo) => void;
1272
+ /**
1273
+ * Accept surface shown when the caller owes disclosures — an INVITED
1274
+ * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
1275
+ * activate) or an ACTIVE user who owes a new version. Pass
1276
+ * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
1277
+ * WidgetProvider cannot import the widget itself (cycle).
1278
+ */
1279
+ disclosuresAcceptance?: ReactNode;
1280
+ /**
1281
+ * Overrides for the copy this provider renders in place of the widget: the
1282
+ * built-in error-boundary fallback and the disclosures gate. Any subset;
1283
+ * unlisted keys keep their defaults. Cascades like `linkComponent`.
1284
+ *
1285
+ * Named `providerLabels` rather than `labels` because a widget's own
1286
+ * `labels` prop sits alongside this one on the same props type.
1287
+ */
1288
+ providerLabels?: Partial<WidgetProviderLabels>;
1289
+ }
1290
+
1291
+ /** The range buttons, in display order. */
1292
+ declare const BalanceHistoryRange: {
1293
+ readonly Days30: "30d";
1294
+ readonly Days90: "90d";
1295
+ readonly Year: "1y";
1296
+ };
1297
+ type BalanceHistoryRange = (typeof BalanceHistoryRange)[keyof typeof BalanceHistoryRange];
1298
+ declare const BALANCE_HISTORY_RANGES: readonly BalanceHistoryRange[];
1299
+
1300
+ interface BalanceHistoryCardLabels {
1301
+ title: string;
1302
+ /** Accessible name of the account picker. */
1303
+ accountSelect: string;
1304
+ /** Placeholder of the account search, used once there are more than ten accounts. */
1305
+ accountSearchPlaceholder: string;
1306
+ /** Shown when the account search matches nothing. */
1307
+ accountSearchEmpty: string;
1308
+ /** Accessible name of the account search's clear button. */
1309
+ accountSearchClear: string;
1310
+ /** Accessible name of the range buttons. */
1311
+ rangeTabs: string;
1312
+ /** Accessible name of the chart. */
1313
+ chart: string;
1314
+ /** Name of the plotted series, shown in the tooltip and as the data table's value column. */
1315
+ seriesName: string;
1316
+ /** Between the series name and the value in the tooltip, e.g. "Balance: $34,054.35". */
1317
+ tooltipSeparator: string;
1318
+ /** Caption of the chart's data table, read to screen readers only. */
1319
+ dataTable: string;
1320
+ /** Heading of the data table's date column. */
1321
+ dateColumn: string;
1322
+ loading: string;
1323
+ errorTitle: string;
1324
+ errorDescription: string;
1325
+ retry: string;
1326
+ }
1327
+
1328
+ interface BalanceHistoryWidgetLabels extends BalanceHistoryCardLabels {
1329
+ /** The picker's first option, the sum of every account. */
1330
+ allAccounts: string;
1331
+ /** A picker option, e.g. "Business Checking - 0578". */
1332
+ accountOption: (name: string, last4: string) => string;
1333
+ /** Range button text, e.g. "30D". */
1334
+ ranges: Record<BalanceHistoryRange, string>;
1335
+ /** The span a full range covers, e.g. "in the last 30 days". */
1336
+ rangeSpans: Record<BalanceHistoryRange, string>;
1337
+ /** Read to screen readers on a range the account is too young for. */
1338
+ rangeTooYoung: Record<BalanceHistoryRange, string>;
1339
+ /** Read to screen readers on a range an unfunded account cannot show. */
1340
+ rangeNeedsMoney: string;
1341
+ /** The span when the window starts on the opening day, e.g. "since account opened Oct 30". */
1342
+ sinceOpened: (date: string) => string;
1343
+ /** Line beside the change, e.g. "in the last 30 days · $1.00 → $2.00". */
1344
+ changeDescription: (span: string, from: string, to: string) => string;
1345
+ /** Notice over the chart while a new account has no money yet. */
1346
+ accountReady: string;
1347
+ /** Notice over the chart once an unfunded account is past 30 days. */
1348
+ addMoney: string;
1349
+ /** Notice link, shown when the host passes `onTransferFromExternalClick`. */
1350
+ transferFromExternal: string;
1351
+ /** Read in place of a fall's parentheses, e.g. "negative $25.00". */
1352
+ negativeAmount: (amount: string) => string;
1353
+ }
1354
+ declare const BALANCE_HISTORY_WIDGET_LABELS_EN: BalanceHistoryWidgetLabels;
1355
+
1356
+ interface BalanceHistoryWidgetWithContextProps {
1357
+ /** Merged with BALANCE_HISTORY_WIDGET_LABELS_EN — only override what you need. */
1358
+ labels?: PartialDeep<BalanceHistoryWidgetLabels>;
1359
+ /** The range shown first. Defaults to 30 days. */
1360
+ defaultRange?: BalanceHistoryRange;
1361
+ /**
1362
+ * Shows "Transfer from an external account" on the notice over an
1363
+ * unfunded account's chart. The host routes it, usually to its transfers
1364
+ * page; without it the notice has no link.
1365
+ */
1366
+ onTransferFromExternalClick?: () => void;
1367
+ className?: string;
1368
+ style?: CSSProperties;
1369
+ }
1370
+ interface BalanceHistoryWidgetProps extends WidgetProviderProps, BalanceHistoryWidgetWithContextProps {
1371
+ }
1372
+ /**
1373
+ * Dashboard card: the org's balance over 30 days, 90 days or a year, for
1374
+ * every account summed or one picked from a list, as a line chart with the
1375
+ * change over the range. Ranges longer than the account's history stay
1376
+ * disabled, and an account that has never held money gets a notice over its
1377
+ * chart. Renders nothing when the token lacks `bank_account:read:org`.
1378
+ */
1379
+ declare function BalanceHistoryWidget({ labels, defaultRange, onTransferFromExternalClick, className, style, ...widgetProviderProps }: BalanceHistoryWidgetProps): React.JSX.Element;
1380
+
1381
+ export { BALANCE_HISTORY_RANGES, BALANCE_HISTORY_WIDGET_LABELS_EN, BalanceHistoryRange, BalanceHistoryWidget };
1382
+ export type { BalanceHistoryWidgetLabels, BalanceHistoryWidgetProps };