@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,1457 @@
1
+ import * as React from 'react';
2
+ import { ComponentType, AnchorHTMLAttributes, ReactNode, ErrorInfo } 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
+ interface AcceptDisclosuresWidgetLabels {
698
+ title: string;
699
+ acceptButton: string;
700
+ submittingButton?: string;
701
+ successToast?: string;
702
+ agreementCheckboxAriaLabel: string;
703
+ /** Fallback when the accept API fails without a usable message. */
704
+ acceptErrorFallback: string;
705
+ /**
706
+ * Shown when acceptance succeeded but the host could not continue to its
707
+ * next step. Kept distinct from `acceptErrorFallback` because the disclosure
708
+ * operation has already completed.
709
+ */
710
+ continuationErrorFallback?: string;
711
+ /**
712
+ * Use `{bankName}` for the bank display name and `{documents}` for the
713
+ * conjunction list of titles the backend returned (same order as the links).
714
+ * A legacy override that omits `{documents}` still has those titles appended
715
+ * so consent copy cannot disagree with the linked documents.
716
+ */
717
+ agreementTextTemplate: string;
718
+ providerAttributionPrefix: string;
719
+ providerAttributionMiddle: string;
720
+ providerAttributionSuffix: string;
721
+ /**
722
+ * @deprecated Ignored. Document titles come from
723
+ * `GET /identity/v1/disclosures`. Kept so hosts that implement the full
724
+ * published `AcceptDisclosuresWidgetLabels` interface continue to typecheck.
725
+ */
726
+ linkLabels: {
727
+ termsOfUse: string;
728
+ privacyPolicy: string;
729
+ electronicCommunications: string;
730
+ patriotAct: string;
731
+ };
732
+ /** Title when the backend returned no documents (`NOT_REQUIRED`). */
733
+ noDocumentsTitle?: string;
734
+ /** Use `{bankName}` when the backend returned no documents. */
735
+ noDocumentsAgreementTextTemplate?: string;
736
+ /**
737
+ * Checkbox `aria-label` when the backend returned no documents. Use
738
+ * `{bankName}`. Must not say the user is agreeing to disclosures.
739
+ */
740
+ noDocumentsAgreementCheckboxAriaLabel?: string;
741
+ /**
742
+ * Two-item document list. Use `{first}` and `{second}` for the titles.
743
+ */
744
+ documentListPairTemplate?: string;
745
+ /** Separator between titles in a list of three or more (before the last). */
746
+ documentListSeparator?: string;
747
+ /** Conjunction before the last title in a list of three or more. */
748
+ documentListLastConjunction?: string;
749
+ /** Heading when the disclosures query fails. */
750
+ loadErrorTitle?: string;
751
+ /** Fallback when the disclosures query fails without a usable message. */
752
+ loadErrorFallback?: string;
753
+ /** Retry control on the disclosures-query error surface. */
754
+ loadErrorRetryLabel?: string;
755
+ /**
756
+ * Shown when accept is refused because a newer disclosure version is in
757
+ * force than the documents the invitee agreed to.
758
+ */
759
+ disclosuresUpdatedFallback?: string;
760
+ }
761
+ declare const ACCEPT_DISCLOSURES_WIDGET_LABELS_EN: {
762
+ title: string;
763
+ acceptButton: string;
764
+ submittingButton: string;
765
+ successToast: string;
766
+ agreementCheckboxAriaLabel: string;
767
+ acceptErrorFallback: string;
768
+ continuationErrorFallback: string;
769
+ agreementTextTemplate: string;
770
+ providerAttributionPrefix: string;
771
+ providerAttributionMiddle: string;
772
+ providerAttributionSuffix: string;
773
+ linkLabels: {
774
+ termsOfUse: string;
775
+ privacyPolicy: string;
776
+ electronicCommunications: string;
777
+ patriotAct: string;
778
+ };
779
+ noDocumentsTitle: string;
780
+ noDocumentsAgreementTextTemplate: string;
781
+ noDocumentsAgreementCheckboxAriaLabel: string;
782
+ documentListPairTemplate: string;
783
+ documentListSeparator: string;
784
+ documentListLastConjunction: string;
785
+ loadErrorTitle: string;
786
+ loadErrorFallback: string;
787
+ loadErrorRetryLabel: string;
788
+ disclosuresUpdatedFallback: string;
789
+ };
790
+
791
+ interface DisclosureLink {
792
+ label: string;
793
+ href: string;
794
+ }
795
+
796
+ interface AcceptDisclosuresWidgetTestIds {
797
+ root?: string;
798
+ providerAttribution?: string;
799
+ disclosureLinks?: string;
800
+ agreeCheckbox?: string;
801
+ agreementText?: string;
802
+ acceptButton?: string;
803
+ error?: string;
804
+ }
805
+ interface AcceptDisclosuresWidgetProps$1 {
806
+ /**
807
+ * Attribution line under the title (e.g. “Banking services for Nail It! are
808
+ * provided by Zenith Bank, Member FDIC.”). Caller supplies emphasis (bold VSP).
809
+ */
810
+ providerAttribution: ReactNode;
811
+ /** Plain agreement copy rendered next to the checkbox. */
812
+ agreementText: string;
813
+ disclosureLinks: DisclosureLink[];
814
+ isAgreed: boolean;
815
+ onAgreedChange: (checked: boolean) => void;
816
+ onAccept: () => void;
817
+ /** Disables the checkbox and Accept control while a submit is in flight. */
818
+ isSubmitting?: boolean;
819
+ /**
820
+ * Keeps the checkbox and Accept control disabled once acceptance is done.
821
+ * Separate from {@link isSubmitting} so `aria-busy` only means "in flight".
822
+ */
823
+ isAccepted?: boolean;
824
+ /** Inline error shown under Accept; omit or empty when there is no error. */
825
+ errorMessage?: string;
826
+ labels?: PartialDeep<AcceptDisclosuresWidgetLabels>;
827
+ testIds?: AcceptDisclosuresWidgetTestIds;
828
+ }
829
+
830
+ type AuthToken = string | undefined;
831
+ interface Auth {
832
+ /**
833
+ * Which part of the request do we use to send the auth?
834
+ *
835
+ * @default 'header'
836
+ */
837
+ in?: 'header' | 'query' | 'cookie';
838
+ /**
839
+ * A unique identifier for the security scheme.
840
+ *
841
+ * Defined only when there are multiple security schemes whose `Auth`
842
+ * shape would otherwise be identical.
843
+ */
844
+ key?: string;
845
+ /**
846
+ * Header or query parameter name.
847
+ *
848
+ * @default 'Authorization'
849
+ */
850
+ name?: string;
851
+ scheme?: 'basic' | 'bearer';
852
+ type: 'apiKey' | 'http';
853
+ }
854
+
855
+ interface SerializerOptions<T> {
856
+ /**
857
+ * @default true
858
+ */
859
+ explode: boolean;
860
+ style: T;
861
+ }
862
+ type ArrayStyle = 'form' | 'spaceDelimited' | 'pipeDelimited';
863
+ type ObjectStyle = 'form' | 'deepObject';
864
+
865
+ type QuerySerializer = (query: Record<string, unknown>) => string;
866
+ type BodySerializer = (body: unknown) => unknown;
867
+ type QuerySerializerOptionsObject = {
868
+ allowReserved?: boolean;
869
+ array?: Partial<SerializerOptions<ArrayStyle>>;
870
+ object?: Partial<SerializerOptions<ObjectStyle>>;
871
+ };
872
+ type QuerySerializerOptions = QuerySerializerOptionsObject & {
873
+ /**
874
+ * Per-parameter serialization overrides. When provided, these settings
875
+ * override the global array/object settings for specific parameter names.
876
+ */
877
+ parameters?: Record<string, QuerySerializerOptionsObject>;
878
+ };
879
+
880
+ type HttpMethod = 'connect' | 'delete' | 'get' | 'head' | 'options' | 'patch' | 'post' | 'put' | 'trace';
881
+ type Client$1<RequestFn = never, Config = unknown, MethodFn = never, BuildUrlFn = never, SseFn = never> = {
882
+ /**
883
+ * Returns the final request URL.
884
+ */
885
+ buildUrl: BuildUrlFn;
886
+ getConfig: () => Config;
887
+ request: RequestFn;
888
+ setConfig: (config: Config) => Config;
889
+ } & {
890
+ [K in HttpMethod]: MethodFn;
891
+ } & ([SseFn] extends [never] ? {
892
+ sse?: never;
893
+ } : {
894
+ sse: {
895
+ [K in HttpMethod]: SseFn;
896
+ };
897
+ });
898
+ interface Config$1 {
899
+ /**
900
+ * Auth token or a function returning auth token. The resolved value will be
901
+ * added to the request payload as defined by its `security` array.
902
+ */
903
+ auth?: ((auth: Auth) => Promise<AuthToken> | AuthToken) | AuthToken;
904
+ /**
905
+ * A function for serializing request body parameter. By default,
906
+ * {@link JSON.stringify()} will be used.
907
+ */
908
+ bodySerializer?: BodySerializer | null;
909
+ /**
910
+ * An object containing any HTTP headers that you want to pre-populate your
911
+ * `Headers` object with.
912
+ *
913
+ * {@link https://developer.mozilla.org/docs/Web/API/Headers/Headers#init See more}
914
+ */
915
+ headers?: RequestInit['headers'] | Record<string, string | number | boolean | (string | number | boolean)[] | null | undefined | unknown>;
916
+ /**
917
+ * The request method.
918
+ *
919
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#method See more}
920
+ */
921
+ method?: Uppercase<HttpMethod>;
922
+ /**
923
+ * A function for serializing request query parameters. By default, arrays
924
+ * will be exploded in form style, objects will be exploded in deepObject
925
+ * style, and reserved characters are percent-encoded.
926
+ *
927
+ * This method will have no effect if the native `paramsSerializer()` Axios
928
+ * API function is used.
929
+ *
930
+ * {@link https://swagger.io/docs/specification/serialization/#query View examples}
931
+ */
932
+ querySerializer?: QuerySerializer | QuerySerializerOptions;
933
+ /**
934
+ * A function validating request data. This is useful if you want to ensure
935
+ * the request conforms to the desired shape, so it can be safely sent to
936
+ * the server.
937
+ */
938
+ requestValidator?: (data: unknown) => Promise<unknown>;
939
+ /**
940
+ * A function transforming response data before it's returned. This is useful
941
+ * for post-processing data, e.g., converting ISO strings into Date objects.
942
+ */
943
+ responseTransformer?: (data: unknown) => Promise<unknown>;
944
+ /**
945
+ * A function validating response data. This is useful if you want to ensure
946
+ * the response conforms to the desired shape, so it can be safely passed to
947
+ * the transformers and returned to the user.
948
+ */
949
+ responseValidator?: (data: unknown) => Promise<unknown>;
950
+ }
951
+
952
+ type ServerSentEventsOptions<TData = unknown> = Omit<RequestInit, 'method'> & Pick<Config$1, 'method' | 'responseTransformer' | 'responseValidator'> & {
953
+ /**
954
+ * Fetch API implementation. You can use this option to provide a custom
955
+ * fetch instance.
956
+ *
957
+ * @default globalThis.fetch
958
+ */
959
+ fetch?: typeof fetch;
960
+ /**
961
+ * Implementing clients can call request interceptors inside this hook.
962
+ */
963
+ onRequest?: (url: string, init: RequestInit) => Promise<Request>;
964
+ /**
965
+ * Callback invoked when a network or parsing error occurs during streaming.
966
+ *
967
+ * This option applies only if the endpoint returns a stream of events.
968
+ *
969
+ * @param error The error that occurred.
970
+ */
971
+ onSseError?: (error: unknown) => void;
972
+ /**
973
+ * Callback invoked when an event is streamed from the server.
974
+ *
975
+ * This option applies only if the endpoint returns a stream of events.
976
+ *
977
+ * @param event Event streamed from the server.
978
+ * @returns Nothing (void).
979
+ */
980
+ onSseEvent?: (event: StreamEvent<TData>) => void;
981
+ serializedBody?: RequestInit['body'];
982
+ /**
983
+ * Default retry delay in milliseconds.
984
+ *
985
+ * This option applies only if the endpoint returns a stream of events.
986
+ *
987
+ * @default 3000
988
+ */
989
+ sseDefaultRetryDelay?: number;
990
+ /**
991
+ * Maximum number of retry attempts before giving up.
992
+ */
993
+ sseMaxRetryAttempts?: number;
994
+ /**
995
+ * Maximum retry delay in milliseconds.
996
+ *
997
+ * Applies only when exponential backoff is used.
998
+ *
999
+ * This option applies only if the endpoint returns a stream of events.
1000
+ *
1001
+ * @default 30000
1002
+ */
1003
+ sseMaxRetryDelay?: number;
1004
+ /**
1005
+ * Optional sleep function for retry backoff.
1006
+ *
1007
+ * Defaults to using `setTimeout`.
1008
+ */
1009
+ sseSleepFn?: (ms: number) => Promise<void>;
1010
+ url: string;
1011
+ };
1012
+ interface StreamEvent<TData = unknown> {
1013
+ data: TData;
1014
+ event?: string;
1015
+ id?: string;
1016
+ retry?: number;
1017
+ }
1018
+ type ServerSentEventsResult<TData = unknown, TReturn = void, TNext = unknown> = {
1019
+ stream: AsyncGenerator<TData extends Record<string, unknown> ? TData[keyof TData] : TData, TReturn, TNext>;
1020
+ };
1021
+
1022
+ type ErrInterceptor<Err, Res, Req, Options> = (error: Err,
1023
+ /** response may be undefined due to a network error where no response object is produced */
1024
+ response: Res | undefined,
1025
+ /** request may be undefined, because error may be from building the request object itself */
1026
+ request: Req | undefined, options: Options) => Err | Promise<Err>;
1027
+ type ReqInterceptor<Req, Options> = (request: Req, options: Options) => Req | Promise<Req>;
1028
+ type ResInterceptor<Res, Req, Options> = (response: Res, request: Req, options: Options) => Res | Promise<Res>;
1029
+ declare class Interceptors<Interceptor> {
1030
+ fns: Array<Interceptor | null>;
1031
+ clear(): void;
1032
+ eject(id: number | Interceptor): void;
1033
+ exists(id: number | Interceptor): boolean;
1034
+ getInterceptorIndex(id: number | Interceptor): number;
1035
+ update(id: number | Interceptor, fn: Interceptor): number | Interceptor | false;
1036
+ use(fn: Interceptor): number;
1037
+ }
1038
+ interface Middleware<Req, Res, Err, Options> {
1039
+ error: Interceptors<ErrInterceptor<Err, Res, Req, Options>>;
1040
+ request: Interceptors<ReqInterceptor<Req, Options>>;
1041
+ response: Interceptors<ResInterceptor<Res, Req, Options>>;
1042
+ }
1043
+
1044
+ type ResponseStyle = 'data' | 'fields';
1045
+ interface Config<T extends ClientOptions$1 = ClientOptions$1> extends Omit<RequestInit, 'body' | 'headers' | 'method'>, Config$1 {
1046
+ /**
1047
+ * Base URL for all requests made by this client.
1048
+ */
1049
+ baseUrl?: T['baseUrl'];
1050
+ /**
1051
+ * Fetch API implementation. You can use this option to provide a custom
1052
+ * fetch instance.
1053
+ *
1054
+ * @default globalThis.fetch
1055
+ */
1056
+ fetch?: typeof fetch;
1057
+ /**
1058
+ * Please don't use the Fetch client for Next.js applications. The `next`
1059
+ * options won't have any effect.
1060
+ *
1061
+ * Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
1062
+ */
1063
+ next?: never;
1064
+ /**
1065
+ * Return the response data parsed in a specified format. By default, `auto`
1066
+ * will infer the appropriate method from the `Content-Type` response header.
1067
+ * You can override this behavior with any of the {@link Body} methods.
1068
+ * Select `stream` if you don't want to parse response data at all.
1069
+ *
1070
+ * @default 'auto'
1071
+ */
1072
+ parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
1073
+ /**
1074
+ * Should we return only data or multiple fields (data, error, response, etc.)?
1075
+ *
1076
+ * @default 'fields'
1077
+ */
1078
+ responseStyle?: ResponseStyle;
1079
+ /**
1080
+ * Throw an error instead of returning it in the response?
1081
+ *
1082
+ * @default false
1083
+ */
1084
+ throwOnError?: T['throwOnError'];
1085
+ }
1086
+ interface RequestOptions<TData = unknown, TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends Config<{
1087
+ responseStyle: TResponseStyle;
1088
+ throwOnError: ThrowOnError;
1089
+ }>, Pick<ServerSentEventsOptions<TData>, 'onRequest' | 'onSseError' | 'onSseEvent' | 'sseDefaultRetryDelay' | 'sseMaxRetryAttempts' | 'sseMaxRetryDelay'> {
1090
+ /**
1091
+ * Any body that you want to add to your request.
1092
+ *
1093
+ * {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
1094
+ */
1095
+ body?: unknown;
1096
+ path?: Record<string, unknown>;
1097
+ query?: Record<string, unknown>;
1098
+ /**
1099
+ * Security mechanism(s) to use for the request.
1100
+ */
1101
+ security?: ReadonlyArray<Auth>;
1102
+ url: Url;
1103
+ }
1104
+ interface ResolvedRequestOptions<TResponseStyle extends ResponseStyle = 'fields', ThrowOnError extends boolean = boolean, Url extends string = string> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
1105
+ headers: Headers;
1106
+ serializedBody?: string;
1107
+ }
1108
+ 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 : {
1109
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
1110
+ request: Request;
1111
+ response: Response;
1112
+ }> : Promise<TResponseStyle extends 'data' ? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined : ({
1113
+ data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
1114
+ error: undefined;
1115
+ } | {
1116
+ data: undefined;
1117
+ error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
1118
+ }) & {
1119
+ /** request may be undefined, because error may be from building the request object itself */
1120
+ request?: Request;
1121
+ /** response may be undefined, because error may be from building the request object itself or from a network error */
1122
+ response?: Response;
1123
+ }>;
1124
+ interface ClientOptions$1 {
1125
+ baseUrl?: string;
1126
+ responseStyle?: ResponseStyle;
1127
+ throwOnError?: boolean;
1128
+ }
1129
+ 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>;
1130
+ type SseFn = <TData = unknown, _TError = unknown, ThrowOnError extends boolean = false, TResponseStyle extends ResponseStyle = 'fields'>(options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>) => Promise<ServerSentEventsResult<TData>>;
1131
+ 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>;
1132
+ type BuildUrlFn = <TData extends {
1133
+ body?: unknown;
1134
+ path?: Record<string, unknown>;
1135
+ query?: Record<string, unknown>;
1136
+ url: string;
1137
+ }>(options: TData & Options<TData>) => string;
1138
+ type Client = Client$1<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
1139
+ interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
1140
+ };
1141
+ interface TDataShape {
1142
+ body?: unknown;
1143
+ headers?: unknown;
1144
+ path?: unknown;
1145
+ query?: unknown;
1146
+ url: string;
1147
+ }
1148
+ type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
1149
+ 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'>);
1150
+
1151
+ type ClientOptions = {
1152
+ 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 & {});
1153
+ };
1154
+
1155
+ type EmbeddedClient = Client;
1156
+ type ExtractLiterals<T> = T extends string ? string extends T ? never : T : never;
1157
+ type BaseUrl = ExtractLiterals<ClientOptions['baseUrl']>;
1158
+
1159
+ type LinkComponentProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
1160
+ children?: ReactNode;
1161
+ };
1162
+ type LinkComponent = ComponentType<LinkComponentProps>;
1163
+ /**
1164
+ * The UI frameworks a widget's UI layer can render with.
1165
+ *
1166
+ * - `shadcn` — the shadcn/Tailwind implementation. This is the default and the
1167
+ * implicit fallback, so existing consumers that select nothing keep rendering
1168
+ * shadcn.
1169
+ * - `tecton` — the Tecton implementation.
1170
+ *
1171
+ * Declared as an `as const` object (not a TypeScript `enum`) per repo
1172
+ * convention.
1173
+ */
1174
+ declare const UIFramework: {
1175
+ readonly Shadcn: "shadcn";
1176
+ readonly Tecton: "tecton";
1177
+ };
1178
+ type UIFramework = (typeof UIFramework)[keyof typeof UIFramework];
1179
+
1180
+ /**
1181
+ * The settable fields of the widget config cascade.
1182
+ *
1183
+ * This is the type accepted by {@link setGlobalWidgetConfig} and all provider props.
1184
+ * It intentionally excludes `initResponse`, which is populated automatically by the
1185
+ * provider after a successful fetch and must never be set manually.
1186
+ *
1187
+ * The `null` vs `undefined` distinction on `widgetToken` and `organizationId` is intentional:
1188
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
1189
+ * - `null` — explicitly cleared; downstream sees "no value" even if an ancestor had one
1190
+ * (e.g. after logout or deliberate de-scoping).
1191
+ *
1192
+ * @see {@link WidgetConfig} for the resolved output type (includes `initResponse`)
1193
+ * @see {@link RootWidgetProvider}
1194
+ * @see {@link WidgetProvider}
1195
+ * @see {@link setGlobalWidgetConfig}
1196
+ */
1197
+ interface WidgetConfigInput {
1198
+ /**
1199
+ * Base URL of the Tesouro embedded API (e.g. `"https://api.tesouro.com"`).
1200
+ *
1201
+ * When omitted the nearest ancestor's `baseUrl` or the global store value is used.
1202
+ * Changing this recreates the underlying HTTP client so all subsequent requests
1203
+ * go to the new host.
1204
+ */
1205
+ baseUrl?: BaseUrl;
1206
+ /**
1207
+ * Bearer token used to authenticate widget requests.
1208
+ *
1209
+ * Injected as `Authorization: Bearer <token>` on every outgoing request via an
1210
+ * interceptor on the scoped HTTP client. Token updates are picked up immediately
1211
+ * without recreating the client.
1212
+ *
1213
+ * - `string` — send this token on all requests from this level downward.
1214
+ * - `null` — explicitly cleared; no auth header is sent and fetching is suppressed.
1215
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
1216
+ */
1217
+ widgetToken?: string | null;
1218
+ /**
1219
+ * Organization ID forwarded as the `x-organization-id` request header.
1220
+ *
1221
+ * Passed through {@link EmbedApiProvider} context rather than the auth interceptor,
1222
+ * so individual data-access hooks can opt in per-request.
1223
+ *
1224
+ * - `string` — use this organization for downstream data requests.
1225
+ * - `null` — explicitly cleared; queries that require an org ID will be disabled.
1226
+ * - `undefined` — not set at this level; inherit from the nearest ancestor or global store.
1227
+ *
1228
+ * When `undefined` across the **whole** cascade (no prop, no ancestor, no global
1229
+ * value), the resolved org defaults to the loaded `initResponse.organizationId`
1230
+ * (see {@link WidgetConfig.initResponse}) once the widget-init fetch settles. This
1231
+ * is the lowest-priority fallback — any explicit `string` or `null` at any cascade
1232
+ * level wins, and an explicit `null` is preserved and never falls back.
1233
+ *
1234
+ * Only an **explicit** ancestor org is inherited. An ancestor's *init-derived*
1235
+ * default does not propagate into a descendant that owns its own fetch (its own
1236
+ * `baseUrl`/`widgetToken`); such a descendant defaults to its own
1237
+ * `initResponse.organizationId` instead, so it never sends an ancestor's org with
1238
+ * its own token.
1239
+ */
1240
+ organizationId?: string | null;
1241
+ /**
1242
+ * Optional post-creation hook for the scoped HTTP client.
1243
+ *
1244
+ * Called once after the provider creates its scoped {@link EmbeddedClient} and
1245
+ * applies the built-in `Authorization: Bearer` interceptor. Receives the
1246
+ * fully-configured client and must return the client to be used for the lifetime of
1247
+ * this provider level — either the same instance (with additional interceptors
1248
+ * attached) or a new client entirely.
1249
+ *
1250
+ * **Order:** The built-in auth interceptor is always applied first. `configClient`
1251
+ * is called on top of it, so any interceptors you add here run after auth is set.
1252
+ *
1253
+ * **Any prop triggers a scoped client.** A {@link WidgetProvider} creates its own
1254
+ * scoped client whenever any prop is set — including `configClient` alone, without
1255
+ * `baseUrl` or `widgetToken`. Only a fully props-free pass-through provider skips
1256
+ * client creation and never calls this function.
1257
+ *
1258
+ * **Stability:** The function reference is included in the client creation memo's
1259
+ * dependency array. Passing an unstable (inline) function recreates the client on
1260
+ * every render. Stabilize with `useCallback` or define the function outside the
1261
+ * component.
1262
+ *
1263
+ * **Cascade:** Inherits from the nearest ancestor when `undefined`. A child
1264
+ * {@link WidgetProvider} that creates its own scoped client will use the resolved
1265
+ * `configClient` from the cascade unless it provides its own override.
1266
+ *
1267
+ * @example
1268
+ * ```tsx
1269
+ * const addLogging = useCallback(
1270
+ * (client: EmbeddedClient) => {
1271
+ * client.interceptors.request.use((req) => {
1272
+ * console.log('[widget]', req.method, req.url);
1273
+ * return req;
1274
+ * });
1275
+ * return client;
1276
+ * },
1277
+ * [],
1278
+ * );
1279
+ *
1280
+ * <RootWidgetProvider
1281
+ * baseUrl="https://api.tesouro.com"
1282
+ * widgetToken={token}
1283
+ * configClient={addLogging}
1284
+ * >
1285
+ * <App />
1286
+ * </RootWidgetProvider>
1287
+ * ```
1288
+ */
1289
+ configClient?: (client: EmbeddedClient) => EmbeddedClient;
1290
+ /**
1291
+ * Overrides the widget-gateway routing decision for the scoped HTTP client.
1292
+ *
1293
+ * Any caller reaching the Tesouro API with a widget token must route data
1294
+ * requests through the widget gateway: prefix the path with
1295
+ * `/api/widget-gateway/proxy` and carry the token as `X-Widget-Token`. The
1296
+ * provider applies both automatically per request when the request origin is
1297
+ * a known Tesouro API host (`WIDGET_GATEWAY_HOSTS`, derived from the
1298
+ * generated `ClientOptions['baseUrl']`); `/api/widget-gateway/*` paths (the
1299
+ * init round-trip) always pass through untouched.
1300
+ *
1301
+ * - `undefined` — decide from the request origin, as above. Inherits from
1302
+ * the nearest ancestor or global store like every other config field.
1303
+ * - `true` — always apply the rewrite, even for an unlisted base URL (e.g. a
1304
+ * custom domain in front of the gateway).
1305
+ * - `false` — never apply it. For hosts that route widget requests their own
1306
+ * way, such as a same-origin BFF whose `configClient` retargets every
1307
+ * request.
1308
+ *
1309
+ * Independent of {@link configClient}: a host that only adds a header keeps
1310
+ * the built-in routing, and the built-in interceptor runs before any
1311
+ * `configClient` interceptor.
1312
+ */
1313
+ gatewayRouting?: boolean;
1314
+ /**
1315
+ * Component the embedded widgets should render in place of plain `<a>` tags.
1316
+ *
1317
+ * Pass e.g. Next.js's `Link` to make in-app navigation use the host router.
1318
+ * Cascades like other config: provider prop > nearest ancestor > global store.
1319
+ * When no value is set anywhere, widgets fall back to a plain `<a>` element.
1320
+ */
1321
+ linkComponent?: LinkComponent;
1322
+ /**
1323
+ * Which UI framework the widget UI layer should render with.
1324
+ *
1325
+ * Lets a consuming context bind widgets to either the shadcn/Tailwind or the
1326
+ * Tecton implementation behind the same outward-facing API. The selection is
1327
+ * a presentation concern only — it cascades through the provider tree exactly
1328
+ * like {@link linkComponent} and is read by UI libraries via `useUIFramework`;
1329
+ * it never appears in any widget's feature-library or component props.
1330
+ *
1331
+ * - `'shadcn'` — the shadcn/Tailwind implementation.
1332
+ * - `'tecton'` — the Tecton implementation.
1333
+ * - `null` / `undefined` — not set at this level; inherit from the nearest
1334
+ * ancestor or global store, falling back to `shadcn` when unset everywhere.
1335
+ * `shadcn` is the implicit default, so existing consumers need no changes.
1336
+ */
1337
+ uiFramework?: UIFramework | null;
1338
+ }
1339
+ /**
1340
+ * Props shared by every analytics-owner-capable widget provider.
1341
+ *
1342
+ * Combines the full settable cascade ({@link WidgetConfigInput}) with the
1343
+ * analytics opt-out honored by analytics owners. Both {@link RootWidgetProvider}
1344
+ * and {@link WidgetProvider} build their public props on top of this; the latter
1345
+ * adds error-boundary props of its own.
1346
+ *
1347
+ * @see {@link WidgetConfigInput} for per-field cascade and `null` vs omitted semantics
1348
+ */
1349
+ interface WidgetProviderBaseProps extends WidgetConfigInput {
1350
+ /**
1351
+ * Opt out of all analytics capture and prevent PostHog from loading. Default `true`.
1352
+ *
1353
+ * Honored only by an analytics **owner** — a {@link RootWidgetProvider} or a
1354
+ * standalone {@link WidgetProvider} with no parent provider. When `false`,
1355
+ * owner-bound `track` calls in this subtree become no-ops and the PostHog
1356
+ * installer is never dynamically imported for this owner's environment.
1357
+ * Setting it on a nested {@link WidgetProvider} is ignored in v1 (a one-time
1358
+ * `console.warn` is emitted to make the no-op discoverable).
1359
+ */
1360
+ analytics?: boolean;
1361
+ }
1362
+
1363
+ /**
1364
+ * Copy for the states `WidgetProvider` renders *itself*, in place of the widget:
1365
+ * the error-boundary fallback and the disclosures gate. A host overrides any
1366
+ * subset through the `providerLabels` prop, which cascades like
1367
+ * `disclosuresAcceptance`.
1368
+ *
1369
+ * Not named `Labels` on the public surface: a widget's own `labels` prop is a
1370
+ * different thing, and these two travel together on every widget's props type.
1371
+ */
1372
+ interface WidgetProviderLabels {
1373
+ /** Default copy for the built-in error boundary fallback. */
1374
+ errorBoundaryFallback: string;
1375
+ /** Heading when init reports disclosures are required and not yet accepted. */
1376
+ disclosuresRequiredTitle: string;
1377
+ /** Heading while a token-only refresh leaves init stale for the live token. */
1378
+ disclosuresRefreshingTitle: string;
1379
+ /** Supporting copy while the accept action is withheld for a stale init. */
1380
+ disclosuresRefreshingDescription: string;
1381
+ }
1382
+
1383
+ /**
1384
+ * Props for {@link WidgetProvider}.
1385
+ *
1386
+ * All fields are optional. When **all** are omitted the provider is a transparent
1387
+ * pass-through: no fetch is issued and all resolved values cascade unchanged from
1388
+ * the nearest ancestor.
1389
+ */
1390
+ interface WidgetProviderProps extends WidgetProviderBaseProps {
1391
+ /**
1392
+ * Fallback rendered when a render-time exception is caught inside this
1393
+ * provider's subtree. Pass either a `ReactNode` (rendered directly) or a
1394
+ * render-prop receiving `{ error, resetErrorBoundary }` from
1395
+ * `react-error-boundary`. Default is a plain `role="alert"` div whose copy
1396
+ * comes from `providerLabels.errorBoundaryFallback`.
1397
+ */
1398
+ errorFallback?: ReactNode | ((props: FallbackProps) => ReactNode);
1399
+ /**
1400
+ * Called once when the boundary catches an error, before the fallback
1401
+ * renders. Use for telemetry / error tracking / partner logging. Exceptions
1402
+ * thrown from `onError` propagate per `react-error-boundary` semantics.
1403
+ */
1404
+ onError?: (error: unknown, info: ErrorInfo) => void;
1405
+ /**
1406
+ * Accept surface shown when the caller owes disclosures — an INVITED
1407
+ * teammate (including `NOT_REQUIRED` orgs, who still need Accept to
1408
+ * activate) or an ACTIVE user who owes a new version. Pass
1409
+ * `<AcceptDisclosuresWidget />`. Cascades like `linkComponent`.
1410
+ * WidgetProvider cannot import the widget itself (cycle).
1411
+ */
1412
+ disclosuresAcceptance?: ReactNode;
1413
+ /**
1414
+ * Overrides for the copy this provider renders in place of the widget: the
1415
+ * built-in error-boundary fallback and the disclosures gate. Any subset;
1416
+ * unlisted keys keep their defaults. Cascades like `linkComponent`.
1417
+ *
1418
+ * Named `providerLabels` rather than `labels` because a widget's own
1419
+ * `labels` prop sits alongside this one on the same props type.
1420
+ */
1421
+ providerLabels?: Partial<WidgetProviderLabels>;
1422
+ }
1423
+
1424
+ type UiOwnedProps = 'providerAttribution' | 'agreementText' | 'disclosureLinks' | 'isAgreed' | 'onAgreedChange' | 'onAccept' | 'isSubmitting' | 'isAccepted' | 'errorMessage' | 'testIds';
1425
+ type InnerProps = Omit<AcceptDisclosuresWidgetProps$1, UiOwnedProps> & {
1426
+ /**
1427
+ * Called after the atomic accept succeeds and before init refresh is kicked.
1428
+ * May return a promise — the widget awaits it before locking controls and
1429
+ * refreshing init, so a rejected continuation surfaces as an error and leaves
1430
+ * Accept retryable (and the host gate stays mounted).
1431
+ */
1432
+ onAccepted?: () => void | Promise<void>;
1433
+ };
1434
+ type AcceptDisclosuresWidgetProps = WidgetProviderProps & InnerProps;
1435
+ /**
1436
+ * Self-contained AcceptDisclosures widget. Fetches the caller's disclosure
1437
+ * document set (title/url pairs, in presentation order) from
1438
+ * `GET /identity/v1/disclosures` and renders it directly — the host supplies
1439
+ * no document URLs. An empty document list (`NOT_REQUIRED`) still renders
1440
+ * Accept so those invitees can activate. Posts
1441
+ * `POST /api/widget-gateway/disclosure-acceptance` with the version that was
1442
+ * on screen after confirming that version is still in force via the
1443
+ * widget-gateway proxy. A newer published version is refused rather than
1444
+ * accepted unseen. The POST activates the invitee (when they are still
1445
+ * invited) and records acceptance in one transaction, then awaits any
1446
+ * `onAccepted` continuation and kicks a widget-init refresh so host gates
1447
+ * keyed on `INVITED` — or on the disclosure flags — can clear. Auth uses
1448
+ * the normal WidgetToken provider contract — never an APP/M2M bearer. The
1449
+ * widget token identifies the caller on both the disclosures lookup and
1450
+ * the accept; this widget does not take invite-link credentials.
1451
+ *
1452
+ * See `WidgetSuite`, which mounts it as its acceptance state.
1453
+ */
1454
+ declare function AcceptDisclosuresWidget({ baseUrl, widgetToken, organizationId, configClient, gatewayRouting, linkComponent, uiFramework, errorFallback, onError, analytics, disclosuresAcceptance, providerLabels, ...innerProps }: AcceptDisclosuresWidgetProps): React.JSX.Element;
1455
+
1456
+ export { ACCEPT_DISCLOSURES_WIDGET_LABELS_EN, AcceptDisclosuresWidget };
1457
+ export type { AcceptDisclosuresWidgetLabels, AcceptDisclosuresWidgetProps };