@capitalos/react 0.2.1-rc2 → 0.2.1-rc3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,410 @@
1
+ /// <reference types="react" />
2
+
3
+ import { IFrameComponent } from 'iframe-resizer';
4
+ import { IFrameMessageData } from 'iframe-resizer';
5
+ import { IFrameOptions } from 'iframe-resizer';
6
+ import { IFrameResizedData } from 'iframe-resizer';
7
+ import { IFrameScrollData } from 'iframe-resizer';
8
+ import { default as React_2 } from 'react';
9
+ import { ReactNode } from 'react';
10
+ import * as z from 'zod';
11
+ import { z as z_2 } from 'zod';
12
+
13
+ /**
14
+ * Renders the CapitalOS App.
15
+ */
16
+ export declare function App(props: CommonProps): JSX.Element;
17
+
18
+ /**
19
+ * The internal component that handles all the heavy lifting of connecting to the iframe and rendering the app.
20
+ * all user facing components are basically a syntactic sugar on top of this.
21
+ */
22
+ export declare function CapitalOS<T>(props: CapitalOsProps<T>): JSX.Element;
23
+
24
+ /**
25
+ * Base class for all SDK errors
26
+ */
27
+ export declare class CapitalOSError extends Error {
28
+ constructor(message: string);
29
+ }
30
+
31
+ declare type CapitalOsProps<T> = CommonProps & {
32
+ renderingContext?: T | undefined;
33
+ methods?: Partial<IframeConnectionMethods>;
34
+ };
35
+
36
+ export declare type CardApiDto = z.infer<typeof cardApiDtoSchema>;
37
+
38
+ declare const cardApiDtoSchema: z.ZodObject<{
39
+ accountUserId: z.ZodNullable<z.ZodString>;
40
+ status: z.ZodEnum<["active", "inactive", "canceled", "frozen"]>;
41
+ id: z.ZodString;
42
+ last4: z.ZodString;
43
+ platformId: z.ZodString;
44
+ cardholderFirstName: z.ZodString;
45
+ cardholderLastName: z.ZodString;
46
+ cardholderPhoneNumber: z.ZodEffects<z.ZodString, string, string>;
47
+ nickname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ spend: z.ZodObject<{
49
+ daily: z.ZodObject<{
50
+ limit: z.ZodOptional<z.ZodNumber>;
51
+ amount: z.ZodNumber;
52
+ }, "strip", z.ZodTypeAny, {
53
+ amount: number;
54
+ limit?: number | undefined;
55
+ }, {
56
+ amount: number;
57
+ limit?: number | undefined;
58
+ }>;
59
+ weekly: z.ZodObject<{
60
+ limit: z.ZodOptional<z.ZodNumber>;
61
+ amount: z.ZodNumber;
62
+ }, "strip", z.ZodTypeAny, {
63
+ amount: number;
64
+ limit?: number | undefined;
65
+ }, {
66
+ amount: number;
67
+ limit?: number | undefined;
68
+ }>;
69
+ monthly: z.ZodObject<{
70
+ limit: z.ZodOptional<z.ZodNumber>;
71
+ amount: z.ZodNumber;
72
+ }, "strip", z.ZodTypeAny, {
73
+ amount: number;
74
+ limit?: number | undefined;
75
+ }, {
76
+ amount: number;
77
+ limit?: number | undefined;
78
+ }>;
79
+ lifetime: z.ZodObject<{
80
+ limit: z.ZodOptional<z.ZodNumber>;
81
+ amount: z.ZodNumber;
82
+ }, "strip", z.ZodTypeAny, {
83
+ amount: number;
84
+ limit?: number | undefined;
85
+ }, {
86
+ amount: number;
87
+ limit?: number | undefined;
88
+ }>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ daily: {
91
+ amount: number;
92
+ limit?: number | undefined;
93
+ };
94
+ weekly: {
95
+ amount: number;
96
+ limit?: number | undefined;
97
+ };
98
+ monthly: {
99
+ amount: number;
100
+ limit?: number | undefined;
101
+ };
102
+ lifetime: {
103
+ amount: number;
104
+ limit?: number | undefined;
105
+ };
106
+ }, {
107
+ daily: {
108
+ amount: number;
109
+ limit?: number | undefined;
110
+ };
111
+ weekly: {
112
+ amount: number;
113
+ limit?: number | undefined;
114
+ };
115
+ monthly: {
116
+ amount: number;
117
+ limit?: number | undefined;
118
+ };
119
+ lifetime: {
120
+ amount: number;
121
+ limit?: number | undefined;
122
+ };
123
+ }>;
124
+ allowedSpendCategories: z.ZodArray<z.ZodEnum<["airlines", "car_rental", "fuel_pump_only", "fuel_station", "lodging", "parking", "taxi_and_rideshare", "travel_misc"]>, "many">;
125
+ isFuelCard: z.ZodBoolean;
126
+ physicalCard: z.ZodOptional<z.ZodNullable<z.ZodObject<{
127
+ id: z.ZodString;
128
+ }, "strip", z.ZodTypeAny, {
129
+ id: string;
130
+ }, {
131
+ id: string;
132
+ }>>>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ id: string;
135
+ status: "active" | "inactive" | "canceled" | "frozen";
136
+ platformId: string;
137
+ accountUserId: string | null;
138
+ last4: string;
139
+ cardholderFirstName: string;
140
+ cardholderLastName: string;
141
+ cardholderPhoneNumber: string;
142
+ spend: {
143
+ daily: {
144
+ amount: number;
145
+ limit?: number | undefined;
146
+ };
147
+ weekly: {
148
+ amount: number;
149
+ limit?: number | undefined;
150
+ };
151
+ monthly: {
152
+ amount: number;
153
+ limit?: number | undefined;
154
+ };
155
+ lifetime: {
156
+ amount: number;
157
+ limit?: number | undefined;
158
+ };
159
+ };
160
+ allowedSpendCategories: ("airlines" | "car_rental" | "fuel_pump_only" | "fuel_station" | "lodging" | "parking" | "taxi_and_rideshare" | "travel_misc")[];
161
+ isFuelCard: boolean;
162
+ nickname?: string | null | undefined;
163
+ physicalCard?: {
164
+ id: string;
165
+ } | null | undefined;
166
+ }, {
167
+ id: string;
168
+ status: "active" | "inactive" | "canceled" | "frozen";
169
+ platformId: string;
170
+ accountUserId: string | null;
171
+ last4: string;
172
+ cardholderFirstName: string;
173
+ cardholderLastName: string;
174
+ cardholderPhoneNumber: string;
175
+ spend: {
176
+ daily: {
177
+ amount: number;
178
+ limit?: number | undefined;
179
+ };
180
+ weekly: {
181
+ amount: number;
182
+ limit?: number | undefined;
183
+ };
184
+ monthly: {
185
+ amount: number;
186
+ limit?: number | undefined;
187
+ };
188
+ lifetime: {
189
+ amount: number;
190
+ limit?: number | undefined;
191
+ };
192
+ };
193
+ allowedSpendCategories: ("airlines" | "car_rental" | "fuel_pump_only" | "fuel_station" | "lodging" | "parking" | "taxi_and_rideshare" | "travel_misc")[];
194
+ isFuelCard: boolean;
195
+ nickname?: string | null | undefined;
196
+ physicalCard?: {
197
+ id: string;
198
+ } | null | undefined;
199
+ }>;
200
+
201
+ export declare type CommonProps = {
202
+ /**
203
+ * The token provided by initiate-login.
204
+ */
205
+ token: string;
206
+ /**
207
+ * Optional CSS class name for the component.
208
+ */
209
+ className?: string;
210
+ /**
211
+ * Optional flag indicating whether to log events to the console.
212
+ */
213
+ enableLogging?: boolean;
214
+ /**
215
+ * Optional callback for when the app encounters an error.
216
+ */
217
+ onError?: (error: Error) => void;
218
+ /**
219
+ * Optional component to render while the app is loading.
220
+ */
221
+ loadingComponent?: ReactNode;
222
+ };
223
+
224
+ export declare function decodeToken(token: string): any;
225
+
226
+ /**
227
+ * Renders the CapitalOS Dispute Transaction experience.
228
+ */
229
+ export declare function DisputeTransaction({ transactionId, onDone, onCancel, ...restOfProps }: DisputeTransactionProps): JSX.Element;
230
+
231
+ export declare type DisputeTransactionProps = CommonProps & {
232
+ /**
233
+ * The ID of the transaction to dispute.
234
+ */
235
+ transactionId: string;
236
+ /**
237
+ * Callback to invoke when the dispute was successfully submitted.
238
+ */
239
+ onDone: () => void;
240
+ /**
241
+ * Callback to invoke when the user cancels the dispute submission.
242
+ */
243
+ onCancel: () => void;
244
+ };
245
+
246
+ /**
247
+ * Encodes the rendering context as base64 and then URI encodes it.
248
+ */
249
+ export declare function encodeRenderingContext<T>(renderingContext: NonNullable<T>): string;
250
+
251
+ export declare type EntryPoint = RenderingContext_2['entryPoint'];
252
+
253
+ export declare type IframeConnectionMethods = {
254
+ onLoad: () => void;
255
+ createCard?: {
256
+ onDone?: () => void;
257
+ onCancel?: () => void;
258
+ };
259
+ createDispute?: {
260
+ onDone?: () => void;
261
+ onCancel?: () => void;
262
+ };
263
+ };
264
+
265
+ export declare const IframeResizer: React_2.ForwardRefExoticComponent<Omit<IFrameOptions, "closedCallback" | "scrollCallback" | "resizedCallback" | "messageCallback" | "initCallback"> & {
266
+ onClosed?(iframeId: string): void;
267
+ onInit?(iframe: IFrameComponent): void;
268
+ onMessage?(data: IFrameMessageData): void;
269
+ onResized?(data: IFrameResizedData): void;
270
+ onScroll?(data: IFrameScrollData): boolean;
271
+ } & React_2.IframeHTMLAttributes<HTMLIFrameElement> & React_2.RefAttributes<HTMLIFrameElement>>;
272
+
273
+ /**
274
+ * Represents an error that occurs when an invalid token is encountered.
275
+ */
276
+ export declare class InvalidTokenError extends CapitalOSError {
277
+ constructor();
278
+ }
279
+
280
+ /**
281
+ * Renders the CapitalOS Issue Card experience.
282
+ */
283
+ export declare function IssueCard({ defaultValues, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
284
+
285
+ export declare type IssueCardDefaultValues = z_2.infer<typeof issueCardDefaultValuesSchema>;
286
+
287
+ declare const issueCardDefaultValuesSchema: z_2.ZodIntersection<z_2.ZodUnion<[z_2.ZodObject<{
288
+ firstName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
289
+ lastName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
290
+ phone: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
291
+ userId: z_2.ZodOptional<z_2.ZodUndefined>;
292
+ }, "strip", z_2.ZodTypeAny, {
293
+ firstName?: string | null | undefined;
294
+ lastName?: string | null | undefined;
295
+ phone?: string | null | undefined;
296
+ userId?: undefined;
297
+ }, {
298
+ firstName?: string | null | undefined;
299
+ lastName?: string | null | undefined;
300
+ phone?: string | null | undefined;
301
+ userId?: undefined;
302
+ }>, z_2.ZodObject<{
303
+ userId: z_2.ZodString;
304
+ }, "strip", z_2.ZodTypeAny, {
305
+ userId: string;
306
+ }, {
307
+ userId: string;
308
+ }>]>, z_2.ZodObject<{
309
+ nickname: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
310
+ }, "strip", z_2.ZodTypeAny, {
311
+ nickname?: string | null | undefined;
312
+ }, {
313
+ nickname?: string | null | undefined;
314
+ }>>;
315
+
316
+ export declare type IssueCardProps = CommonProps & {
317
+ /**
318
+ * Default values to prefill the form with.
319
+ *
320
+ * Either provide a userId, in which case the default values will be taken from that user's profile, or provide the cardholder's details directly.
321
+ */
322
+ defaultValues?: IssueCardDefaultValues;
323
+ /**
324
+ * Callback to invoke when the card was created successfully.
325
+ */
326
+ onDone: () => void;
327
+ /**
328
+ * Callback to invoke when the card creation was cancelled by the user.
329
+ */
330
+ onCancel: () => void;
331
+ };
332
+
333
+ declare type RenderingContext_2 = z_2.infer<typeof renderingContextSchema>;
334
+
335
+ declare const renderingContextSchema: z_2.ZodDiscriminatedUnion<"entryPoint", [z_2.ZodObject<{
336
+ entryPoint: z_2.ZodLiteral<"createCard">;
337
+ defaultValues: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodIntersection<z_2.ZodUnion<[z_2.ZodObject<{
338
+ firstName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
339
+ lastName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
340
+ phone: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
341
+ userId: z_2.ZodOptional<z_2.ZodUndefined>;
342
+ }, "strip", z_2.ZodTypeAny, {
343
+ firstName?: string | null | undefined;
344
+ lastName?: string | null | undefined;
345
+ phone?: string | null | undefined;
346
+ userId?: undefined;
347
+ }, {
348
+ firstName?: string | null | undefined;
349
+ lastName?: string | null | undefined;
350
+ phone?: string | null | undefined;
351
+ userId?: undefined;
352
+ }>, z_2.ZodObject<{
353
+ userId: z_2.ZodString;
354
+ }, "strip", z_2.ZodTypeAny, {
355
+ userId: string;
356
+ }, {
357
+ userId: string;
358
+ }>]>, z_2.ZodObject<{
359
+ nickname: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
360
+ }, "strip", z_2.ZodTypeAny, {
361
+ nickname?: string | null | undefined;
362
+ }, {
363
+ nickname?: string | null | undefined;
364
+ }>>>>;
365
+ }, "strip", z_2.ZodTypeAny, {
366
+ entryPoint: "createCard";
367
+ defaultValues?: (({
368
+ firstName?: string | null | undefined;
369
+ lastName?: string | null | undefined;
370
+ phone?: string | null | undefined;
371
+ userId?: undefined;
372
+ } | {
373
+ userId: string;
374
+ }) & {
375
+ nickname?: string | null | undefined;
376
+ }) | null | undefined;
377
+ }, {
378
+ entryPoint: "createCard";
379
+ defaultValues?: (({
380
+ firstName?: string | null | undefined;
381
+ lastName?: string | null | undefined;
382
+ phone?: string | null | undefined;
383
+ userId?: undefined;
384
+ } | {
385
+ userId: string;
386
+ }) & {
387
+ nickname?: string | null | undefined;
388
+ }) | null | undefined;
389
+ }>, z_2.ZodObject<{
390
+ entryPoint: z_2.ZodLiteral<"createDispute">;
391
+ transactionId: z_2.ZodString;
392
+ }, "strip", z_2.ZodTypeAny, {
393
+ entryPoint: "createDispute";
394
+ transactionId: string;
395
+ }, {
396
+ entryPoint: "createDispute";
397
+ transactionId: string;
398
+ }>]>;
399
+
400
+ /**
401
+ * connects to child iframe and returns whether the iframe is loaded or not.
402
+ */
403
+ export declare function useIframeConnection({ iframeRef, token, onError, methods, }: {
404
+ iframeRef: React.RefObject<HTMLIFrameElement>;
405
+ token: string;
406
+ onError: ((error: Error) => void) | undefined | null;
407
+ methods: IframeConnectionMethods;
408
+ }): void;
409
+
410
+ export { }
@@ -0,0 +1,410 @@
1
+ /// <reference types="react" />
2
+
3
+ import { IFrameComponent } from 'iframe-resizer';
4
+ import { IFrameMessageData } from 'iframe-resizer';
5
+ import { IFrameOptions } from 'iframe-resizer';
6
+ import { IFrameResizedData } from 'iframe-resizer';
7
+ import { IFrameScrollData } from 'iframe-resizer';
8
+ import { default as React_2 } from 'react';
9
+ import { ReactNode } from 'react';
10
+ import * as z from 'zod';
11
+ import { z as z_2 } from 'zod';
12
+
13
+ /**
14
+ * Renders the CapitalOS App.
15
+ */
16
+ export declare function App(props: CommonProps): JSX.Element;
17
+
18
+ /**
19
+ * The internal component that handles all the heavy lifting of connecting to the iframe and rendering the app.
20
+ * all user facing components are basically a syntactic sugar on top of this.
21
+ */
22
+ export declare function CapitalOS<T>(props: CapitalOsProps<T>): JSX.Element;
23
+
24
+ /**
25
+ * Base class for all SDK errors
26
+ */
27
+ export declare class CapitalOSError extends Error {
28
+ constructor(message: string);
29
+ }
30
+
31
+ declare type CapitalOsProps<T> = CommonProps & {
32
+ renderingContext?: T | undefined;
33
+ methods?: Partial<IframeConnectionMethods>;
34
+ };
35
+
36
+ export declare type CardApiDto = z.infer<typeof cardApiDtoSchema>;
37
+
38
+ declare const cardApiDtoSchema: z.ZodObject<{
39
+ accountUserId: z.ZodNullable<z.ZodString>;
40
+ status: z.ZodEnum<["active", "inactive", "canceled", "frozen"]>;
41
+ id: z.ZodString;
42
+ last4: z.ZodString;
43
+ platformId: z.ZodString;
44
+ cardholderFirstName: z.ZodString;
45
+ cardholderLastName: z.ZodString;
46
+ cardholderPhoneNumber: z.ZodEffects<z.ZodString, string, string>;
47
+ nickname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ spend: z.ZodObject<{
49
+ daily: z.ZodObject<{
50
+ limit: z.ZodOptional<z.ZodNumber>;
51
+ amount: z.ZodNumber;
52
+ }, "strip", z.ZodTypeAny, {
53
+ amount: number;
54
+ limit?: number | undefined;
55
+ }, {
56
+ amount: number;
57
+ limit?: number | undefined;
58
+ }>;
59
+ weekly: z.ZodObject<{
60
+ limit: z.ZodOptional<z.ZodNumber>;
61
+ amount: z.ZodNumber;
62
+ }, "strip", z.ZodTypeAny, {
63
+ amount: number;
64
+ limit?: number | undefined;
65
+ }, {
66
+ amount: number;
67
+ limit?: number | undefined;
68
+ }>;
69
+ monthly: z.ZodObject<{
70
+ limit: z.ZodOptional<z.ZodNumber>;
71
+ amount: z.ZodNumber;
72
+ }, "strip", z.ZodTypeAny, {
73
+ amount: number;
74
+ limit?: number | undefined;
75
+ }, {
76
+ amount: number;
77
+ limit?: number | undefined;
78
+ }>;
79
+ lifetime: z.ZodObject<{
80
+ limit: z.ZodOptional<z.ZodNumber>;
81
+ amount: z.ZodNumber;
82
+ }, "strip", z.ZodTypeAny, {
83
+ amount: number;
84
+ limit?: number | undefined;
85
+ }, {
86
+ amount: number;
87
+ limit?: number | undefined;
88
+ }>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ daily: {
91
+ amount: number;
92
+ limit?: number | undefined;
93
+ };
94
+ weekly: {
95
+ amount: number;
96
+ limit?: number | undefined;
97
+ };
98
+ monthly: {
99
+ amount: number;
100
+ limit?: number | undefined;
101
+ };
102
+ lifetime: {
103
+ amount: number;
104
+ limit?: number | undefined;
105
+ };
106
+ }, {
107
+ daily: {
108
+ amount: number;
109
+ limit?: number | undefined;
110
+ };
111
+ weekly: {
112
+ amount: number;
113
+ limit?: number | undefined;
114
+ };
115
+ monthly: {
116
+ amount: number;
117
+ limit?: number | undefined;
118
+ };
119
+ lifetime: {
120
+ amount: number;
121
+ limit?: number | undefined;
122
+ };
123
+ }>;
124
+ allowedSpendCategories: z.ZodArray<z.ZodEnum<["airlines", "car_rental", "fuel_pump_only", "fuel_station", "lodging", "parking", "taxi_and_rideshare", "travel_misc"]>, "many">;
125
+ isFuelCard: z.ZodBoolean;
126
+ physicalCard: z.ZodOptional<z.ZodNullable<z.ZodObject<{
127
+ id: z.ZodString;
128
+ }, "strip", z.ZodTypeAny, {
129
+ id: string;
130
+ }, {
131
+ id: string;
132
+ }>>>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ id: string;
135
+ status: "active" | "inactive" | "canceled" | "frozen";
136
+ platformId: string;
137
+ accountUserId: string | null;
138
+ last4: string;
139
+ cardholderFirstName: string;
140
+ cardholderLastName: string;
141
+ cardholderPhoneNumber: string;
142
+ spend: {
143
+ daily: {
144
+ amount: number;
145
+ limit?: number | undefined;
146
+ };
147
+ weekly: {
148
+ amount: number;
149
+ limit?: number | undefined;
150
+ };
151
+ monthly: {
152
+ amount: number;
153
+ limit?: number | undefined;
154
+ };
155
+ lifetime: {
156
+ amount: number;
157
+ limit?: number | undefined;
158
+ };
159
+ };
160
+ allowedSpendCategories: ("airlines" | "car_rental" | "fuel_pump_only" | "fuel_station" | "lodging" | "parking" | "taxi_and_rideshare" | "travel_misc")[];
161
+ isFuelCard: boolean;
162
+ nickname?: string | null | undefined;
163
+ physicalCard?: {
164
+ id: string;
165
+ } | null | undefined;
166
+ }, {
167
+ id: string;
168
+ status: "active" | "inactive" | "canceled" | "frozen";
169
+ platformId: string;
170
+ accountUserId: string | null;
171
+ last4: string;
172
+ cardholderFirstName: string;
173
+ cardholderLastName: string;
174
+ cardholderPhoneNumber: string;
175
+ spend: {
176
+ daily: {
177
+ amount: number;
178
+ limit?: number | undefined;
179
+ };
180
+ weekly: {
181
+ amount: number;
182
+ limit?: number | undefined;
183
+ };
184
+ monthly: {
185
+ amount: number;
186
+ limit?: number | undefined;
187
+ };
188
+ lifetime: {
189
+ amount: number;
190
+ limit?: number | undefined;
191
+ };
192
+ };
193
+ allowedSpendCategories: ("airlines" | "car_rental" | "fuel_pump_only" | "fuel_station" | "lodging" | "parking" | "taxi_and_rideshare" | "travel_misc")[];
194
+ isFuelCard: boolean;
195
+ nickname?: string | null | undefined;
196
+ physicalCard?: {
197
+ id: string;
198
+ } | null | undefined;
199
+ }>;
200
+
201
+ export declare type CommonProps = {
202
+ /**
203
+ * The token provided by initiate-login.
204
+ */
205
+ token: string;
206
+ /**
207
+ * Optional CSS class name for the component.
208
+ */
209
+ className?: string;
210
+ /**
211
+ * Optional flag indicating whether to log events to the console.
212
+ */
213
+ enableLogging?: boolean;
214
+ /**
215
+ * Optional callback for when the app encounters an error.
216
+ */
217
+ onError?: (error: Error) => void;
218
+ /**
219
+ * Optional component to render while the app is loading.
220
+ */
221
+ loadingComponent?: ReactNode;
222
+ };
223
+
224
+ export declare function decodeToken(token: string): any;
225
+
226
+ /**
227
+ * Renders the CapitalOS Dispute Transaction experience.
228
+ */
229
+ export declare function DisputeTransaction({ transactionId, onDone, onCancel, ...restOfProps }: DisputeTransactionProps): JSX.Element;
230
+
231
+ export declare type DisputeTransactionProps = CommonProps & {
232
+ /**
233
+ * The ID of the transaction to dispute.
234
+ */
235
+ transactionId: string;
236
+ /**
237
+ * Callback to invoke when the dispute was successfully submitted.
238
+ */
239
+ onDone: () => void;
240
+ /**
241
+ * Callback to invoke when the user cancels the dispute submission.
242
+ */
243
+ onCancel: () => void;
244
+ };
245
+
246
+ /**
247
+ * Encodes the rendering context as base64 and then URI encodes it.
248
+ */
249
+ export declare function encodeRenderingContext<T>(renderingContext: NonNullable<T>): string;
250
+
251
+ export declare type EntryPoint = RenderingContext_2['entryPoint'];
252
+
253
+ export declare type IframeConnectionMethods = {
254
+ onLoad: () => void;
255
+ createCard?: {
256
+ onDone?: () => void;
257
+ onCancel?: () => void;
258
+ };
259
+ createDispute?: {
260
+ onDone?: () => void;
261
+ onCancel?: () => void;
262
+ };
263
+ };
264
+
265
+ export declare const IframeResizer: React_2.ForwardRefExoticComponent<Omit<IFrameOptions, "closedCallback" | "scrollCallback" | "resizedCallback" | "messageCallback" | "initCallback"> & {
266
+ onClosed?(iframeId: string): void;
267
+ onInit?(iframe: IFrameComponent): void;
268
+ onMessage?(data: IFrameMessageData): void;
269
+ onResized?(data: IFrameResizedData): void;
270
+ onScroll?(data: IFrameScrollData): boolean;
271
+ } & React_2.IframeHTMLAttributes<HTMLIFrameElement> & React_2.RefAttributes<HTMLIFrameElement>>;
272
+
273
+ /**
274
+ * Represents an error that occurs when an invalid token is encountered.
275
+ */
276
+ export declare class InvalidTokenError extends CapitalOSError {
277
+ constructor();
278
+ }
279
+
280
+ /**
281
+ * Renders the CapitalOS Issue Card experience.
282
+ */
283
+ export declare function IssueCard({ defaultValues, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
284
+
285
+ export declare type IssueCardDefaultValues = z_2.infer<typeof issueCardDefaultValuesSchema>;
286
+
287
+ declare const issueCardDefaultValuesSchema: z_2.ZodIntersection<z_2.ZodUnion<[z_2.ZodObject<{
288
+ firstName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
289
+ lastName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
290
+ phone: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
291
+ userId: z_2.ZodOptional<z_2.ZodUndefined>;
292
+ }, "strip", z_2.ZodTypeAny, {
293
+ firstName?: string | null | undefined;
294
+ lastName?: string | null | undefined;
295
+ phone?: string | null | undefined;
296
+ userId?: undefined;
297
+ }, {
298
+ firstName?: string | null | undefined;
299
+ lastName?: string | null | undefined;
300
+ phone?: string | null | undefined;
301
+ userId?: undefined;
302
+ }>, z_2.ZodObject<{
303
+ userId: z_2.ZodString;
304
+ }, "strip", z_2.ZodTypeAny, {
305
+ userId: string;
306
+ }, {
307
+ userId: string;
308
+ }>]>, z_2.ZodObject<{
309
+ nickname: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
310
+ }, "strip", z_2.ZodTypeAny, {
311
+ nickname?: string | null | undefined;
312
+ }, {
313
+ nickname?: string | null | undefined;
314
+ }>>;
315
+
316
+ export declare type IssueCardProps = CommonProps & {
317
+ /**
318
+ * Default values to prefill the form with.
319
+ *
320
+ * Either provide a userId, in which case the default values will be taken from that user's profile, or provide the cardholder's details directly.
321
+ */
322
+ defaultValues?: IssueCardDefaultValues;
323
+ /**
324
+ * Callback to invoke when the card was created successfully.
325
+ */
326
+ onDone: () => void;
327
+ /**
328
+ * Callback to invoke when the card creation was cancelled by the user.
329
+ */
330
+ onCancel: () => void;
331
+ };
332
+
333
+ declare type RenderingContext_2 = z_2.infer<typeof renderingContextSchema>;
334
+
335
+ declare const renderingContextSchema: z_2.ZodDiscriminatedUnion<"entryPoint", [z_2.ZodObject<{
336
+ entryPoint: z_2.ZodLiteral<"createCard">;
337
+ defaultValues: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodIntersection<z_2.ZodUnion<[z_2.ZodObject<{
338
+ firstName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
339
+ lastName: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
340
+ phone: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
341
+ userId: z_2.ZodOptional<z_2.ZodUndefined>;
342
+ }, "strip", z_2.ZodTypeAny, {
343
+ firstName?: string | null | undefined;
344
+ lastName?: string | null | undefined;
345
+ phone?: string | null | undefined;
346
+ userId?: undefined;
347
+ }, {
348
+ firstName?: string | null | undefined;
349
+ lastName?: string | null | undefined;
350
+ phone?: string | null | undefined;
351
+ userId?: undefined;
352
+ }>, z_2.ZodObject<{
353
+ userId: z_2.ZodString;
354
+ }, "strip", z_2.ZodTypeAny, {
355
+ userId: string;
356
+ }, {
357
+ userId: string;
358
+ }>]>, z_2.ZodObject<{
359
+ nickname: z_2.ZodOptional<z_2.ZodNullable<z_2.ZodString>>;
360
+ }, "strip", z_2.ZodTypeAny, {
361
+ nickname?: string | null | undefined;
362
+ }, {
363
+ nickname?: string | null | undefined;
364
+ }>>>>;
365
+ }, "strip", z_2.ZodTypeAny, {
366
+ entryPoint: "createCard";
367
+ defaultValues?: (({
368
+ firstName?: string | null | undefined;
369
+ lastName?: string | null | undefined;
370
+ phone?: string | null | undefined;
371
+ userId?: undefined;
372
+ } | {
373
+ userId: string;
374
+ }) & {
375
+ nickname?: string | null | undefined;
376
+ }) | null | undefined;
377
+ }, {
378
+ entryPoint: "createCard";
379
+ defaultValues?: (({
380
+ firstName?: string | null | undefined;
381
+ lastName?: string | null | undefined;
382
+ phone?: string | null | undefined;
383
+ userId?: undefined;
384
+ } | {
385
+ userId: string;
386
+ }) & {
387
+ nickname?: string | null | undefined;
388
+ }) | null | undefined;
389
+ }>, z_2.ZodObject<{
390
+ entryPoint: z_2.ZodLiteral<"createDispute">;
391
+ transactionId: z_2.ZodString;
392
+ }, "strip", z_2.ZodTypeAny, {
393
+ entryPoint: "createDispute";
394
+ transactionId: string;
395
+ }, {
396
+ entryPoint: "createDispute";
397
+ transactionId: string;
398
+ }>]>;
399
+
400
+ /**
401
+ * connects to child iframe and returns whether the iframe is loaded or not.
402
+ */
403
+ export declare function useIframeConnection({ iframeRef, token, onError, methods, }: {
404
+ iframeRef: React.RefObject<HTMLIFrameElement>;
405
+ token: string;
406
+ onError: ((error: Error) => void) | undefined | null;
407
+ methods: IframeConnectionMethods;
408
+ }): void;
409
+
410
+ export { }
@@ -0,0 +1,5 @@
1
+ export { App } from '../_tsup-dts-rollup';
2
+ export { IssueCard } from '../_tsup-dts-rollup';
3
+ export { DisputeTransaction } from '../_tsup-dts-rollup';
4
+ export { IssueCardProps } from '../_tsup-dts-rollup';
5
+ export { DisputeTransactionProps } from '../_tsup-dts-rollup';
@@ -0,0 +1,5 @@
1
+ export { App } from '../_tsup-dts-rollup';
2
+ export { IssueCard } from '../_tsup-dts-rollup';
3
+ export { DisputeTransaction } from '../_tsup-dts-rollup';
4
+ export { IssueCardProps } from '../_tsup-dts-rollup';
5
+ export { DisputeTransactionProps } from '../_tsup-dts-rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capitalos/react",
3
- "version": "0.2.1-rc2",
3
+ "version": "0.2.1-rc3",
4
4
  "description": "integrate CapitalOS into your react app",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",