@saas-support/react 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +732 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +491 -0
- package/dist/index.js +524 -0
- package/dist/react.cjs +593 -0
- package/dist/react.d.ts +783 -0
- package/dist/react.js +1908 -0
- package/package.json +52 -0
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
import { Context } from 'react';
|
|
2
|
+
import { Dispatch } from 'react';
|
|
3
|
+
import { JSX as JSX_2 } from 'react/jsx-runtime';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { SetStateAction } from 'react';
|
|
6
|
+
|
|
7
|
+
export declare interface Appearance {
|
|
8
|
+
baseTheme?: 'light' | 'dark';
|
|
9
|
+
variables?: ThemeVariables;
|
|
10
|
+
elements?: ElementOverrides;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare interface ApplyCouponResult {
|
|
14
|
+
applied: boolean;
|
|
15
|
+
discountType: string;
|
|
16
|
+
amount: number;
|
|
17
|
+
duration: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare class AuthClient {
|
|
21
|
+
private transport;
|
|
22
|
+
private tokenManager;
|
|
23
|
+
private emitter;
|
|
24
|
+
private baseUrl;
|
|
25
|
+
private cachedUser;
|
|
26
|
+
private cachedSettings;
|
|
27
|
+
private loaded;
|
|
28
|
+
constructor(transport: Transport, tokenManager: TokenManager | null, emitter: EventEmitter<SaaSEvents>, baseUrl: string);
|
|
29
|
+
load(): Promise<void>;
|
|
30
|
+
signIn(email: string, password: string): Promise<AuthResult>;
|
|
31
|
+
signUp(email: string, password: string): Promise<SignUpResult>;
|
|
32
|
+
signOut(): Promise<void>;
|
|
33
|
+
signInWithOAuth(provider: OAuthProvider): Promise<SignInResult>;
|
|
34
|
+
submitMfaCode(mfaToken: string, code: string): Promise<SignInResult>;
|
|
35
|
+
sendMagicLink(email: string, redirectUrl: string): Promise<void>;
|
|
36
|
+
verifyMagicLink(token: string): Promise<SignInResult>;
|
|
37
|
+
sendPasswordReset(email: string, redirectUrl: string): Promise<void>;
|
|
38
|
+
resetPassword(token: string, newPassword: string): Promise<void>;
|
|
39
|
+
setupMfa(): Promise<MfaSetupResult>;
|
|
40
|
+
verifyMfa(code: string): Promise<MfaVerifyResult>;
|
|
41
|
+
disableMfa(code: string): Promise<void>;
|
|
42
|
+
getToken(): Promise<string | null>;
|
|
43
|
+
getUser(): Promise<User | null>;
|
|
44
|
+
getUserSync(): User | null;
|
|
45
|
+
isLoaded(): boolean;
|
|
46
|
+
getSettings(): Promise<ProjectSettings | null>;
|
|
47
|
+
onAuthStateChange(callback: AuthStateCallback): () => void;
|
|
48
|
+
updateProfile(metadata: Record<string, unknown>): Promise<User>;
|
|
49
|
+
listOrgs(): Promise<Org[]>;
|
|
50
|
+
createOrg(name: string, slug: string): Promise<Org>;
|
|
51
|
+
getOrg(orgId: string): Promise<Org>;
|
|
52
|
+
updateOrg(orgId: string, params: {
|
|
53
|
+
name?: string;
|
|
54
|
+
avatarUrl?: string;
|
|
55
|
+
}): Promise<Org>;
|
|
56
|
+
deleteOrg(orgId: string): Promise<void>;
|
|
57
|
+
listMembers(orgId: string): Promise<Member[]>;
|
|
58
|
+
sendInvite(orgId: string, email: string, role: string): Promise<Invite>;
|
|
59
|
+
updateMemberRole(orgId: string, userId: string, role: string): Promise<void>;
|
|
60
|
+
removeMember(orgId: string, userId: string): Promise<void>;
|
|
61
|
+
acceptInvite(token: string): Promise<{
|
|
62
|
+
orgId: string;
|
|
63
|
+
role: string;
|
|
64
|
+
}>;
|
|
65
|
+
/* Excluded from this release type: performRefresh */
|
|
66
|
+
private setSession;
|
|
67
|
+
private clearSession;
|
|
68
|
+
private authHeaders;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
declare type AuthMode = {
|
|
72
|
+
type: 'publishableKey';
|
|
73
|
+
key: string;
|
|
74
|
+
} | {
|
|
75
|
+
type: 'apiKey';
|
|
76
|
+
key: string;
|
|
77
|
+
} | {
|
|
78
|
+
type: 'portalToken';
|
|
79
|
+
token: string;
|
|
80
|
+
} | {
|
|
81
|
+
type: 'embedToken';
|
|
82
|
+
token: string;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export declare type AuthResult = SignInResult | MfaRequiredResult;
|
|
86
|
+
|
|
87
|
+
declare type AuthStateCallback = (user: User | null) => void;
|
|
88
|
+
|
|
89
|
+
declare class BillingClient {
|
|
90
|
+
private transport;
|
|
91
|
+
constructor(transport: Transport);
|
|
92
|
+
createCustomer(params: {
|
|
93
|
+
email: string;
|
|
94
|
+
name?: string;
|
|
95
|
+
metadata?: string;
|
|
96
|
+
}): Promise<Customer>;
|
|
97
|
+
getCustomer(customerId: string): Promise<Customer>;
|
|
98
|
+
updateCustomer(customerId: string, params: {
|
|
99
|
+
email?: string;
|
|
100
|
+
name?: string;
|
|
101
|
+
metadata?: string;
|
|
102
|
+
}): Promise<Customer>;
|
|
103
|
+
subscribe(customerId: string, planId: string): Promise<Subscription>;
|
|
104
|
+
changePlan(customerId: string, planId: string): Promise<Subscription>;
|
|
105
|
+
cancelSubscription(customerId: string): Promise<{
|
|
106
|
+
canceledAtPeriodEnd: boolean;
|
|
107
|
+
}>;
|
|
108
|
+
getInvoices(customerId: string): Promise<Invoice[]>;
|
|
109
|
+
ingestUsageEvent(params: {
|
|
110
|
+
customerId: string;
|
|
111
|
+
metric: string;
|
|
112
|
+
quantity: number;
|
|
113
|
+
timestamp?: string;
|
|
114
|
+
idempotencyKey?: string;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
id: string;
|
|
117
|
+
ingested: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
getCurrentUsage(customerId: string): Promise<UsageSummary[]>;
|
|
120
|
+
createPortalToken(customerId: string, expiresIn?: number): Promise<PortalTokenResult>;
|
|
121
|
+
applyCoupon(customerId: string, code: string): Promise<ApplyCouponResult>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export declare function Chart({ type, data, title, width, height, appearance: localAppearance }: ChartProps): JSX_2.Element;
|
|
125
|
+
|
|
126
|
+
export declare interface ChartProps {
|
|
127
|
+
type: 'bar' | 'line' | 'pie';
|
|
128
|
+
data: {
|
|
129
|
+
labels: string[];
|
|
130
|
+
values: number[];
|
|
131
|
+
};
|
|
132
|
+
title?: string;
|
|
133
|
+
width?: number;
|
|
134
|
+
height?: number;
|
|
135
|
+
appearance?: Appearance;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export declare function CouponInput({ customerId, portalToken, onApplied, appearance: localAppearance }: CouponInputProps): JSX_2.Element;
|
|
139
|
+
|
|
140
|
+
export declare interface CouponInputProps {
|
|
141
|
+
customerId: string;
|
|
142
|
+
portalToken?: string;
|
|
143
|
+
onApplied?: (result: ApplyCouponResult) => void;
|
|
144
|
+
appearance?: Appearance;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare interface Customer {
|
|
148
|
+
id: string;
|
|
149
|
+
projectId: string;
|
|
150
|
+
email: string;
|
|
151
|
+
name?: string;
|
|
152
|
+
stripeCustomerId?: string;
|
|
153
|
+
balanceCents: number;
|
|
154
|
+
metadata?: string;
|
|
155
|
+
taxExempt: boolean;
|
|
156
|
+
taxId?: string;
|
|
157
|
+
createdAt: string;
|
|
158
|
+
updatedAt: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
declare interface Dashboard {
|
|
162
|
+
id: string;
|
|
163
|
+
projectId: string;
|
|
164
|
+
name: string;
|
|
165
|
+
layoutJson: string;
|
|
166
|
+
isPublic: boolean;
|
|
167
|
+
refreshIntervalSeconds: number;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
updatedAt: string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export declare function DashboardView({ dashboardId, embedToken, baseUrl, refreshInterval, appearance: localAppearance }: DashboardViewProps): JSX_2.Element;
|
|
173
|
+
|
|
174
|
+
export declare interface DashboardViewProps {
|
|
175
|
+
dashboardId: string;
|
|
176
|
+
embedToken?: string;
|
|
177
|
+
baseUrl?: string;
|
|
178
|
+
refreshInterval?: number;
|
|
179
|
+
appearance?: Appearance;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export declare function DataTable({ columns, rows, sortable, maxRows, appearance: localAppearance }: DataTableProps): JSX_2.Element;
|
|
183
|
+
|
|
184
|
+
export declare interface DataTableProps {
|
|
185
|
+
columns: string[];
|
|
186
|
+
rows: Record<string, unknown>[];
|
|
187
|
+
sortable?: boolean;
|
|
188
|
+
maxRows?: number;
|
|
189
|
+
appearance?: Appearance;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
declare interface ElementOverrides {
|
|
193
|
+
card?: React.CSSProperties;
|
|
194
|
+
headerTitle?: React.CSSProperties;
|
|
195
|
+
formField?: React.CSSProperties;
|
|
196
|
+
submitButton?: React.CSSProperties;
|
|
197
|
+
socialButton?: React.CSSProperties;
|
|
198
|
+
footerLink?: React.CSSProperties;
|
|
199
|
+
divider?: React.CSSProperties;
|
|
200
|
+
errorMessage?: React.CSSProperties;
|
|
201
|
+
pricingCard?: React.CSSProperties;
|
|
202
|
+
badge?: React.CSSProperties;
|
|
203
|
+
table?: React.CSSProperties;
|
|
204
|
+
tableHeader?: React.CSSProperties;
|
|
205
|
+
tableRow?: React.CSSProperties;
|
|
206
|
+
progressBar?: React.CSSProperties;
|
|
207
|
+
chartContainer?: React.CSSProperties;
|
|
208
|
+
queryInput?: React.CSSProperties;
|
|
209
|
+
dashboardGrid?: React.CSSProperties;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
declare interface EmbedToken {
|
|
213
|
+
id: string;
|
|
214
|
+
projectId: string;
|
|
215
|
+
dashboardId?: string;
|
|
216
|
+
customerId?: string;
|
|
217
|
+
filterRules?: FilterRule[];
|
|
218
|
+
expiresAt: string;
|
|
219
|
+
createdAt: string;
|
|
220
|
+
revokedAt?: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare interface EmbedTokenResult {
|
|
224
|
+
embedToken: string;
|
|
225
|
+
expiresAt: string;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
declare class EventEmitter<Events extends Record<string, any>> {
|
|
229
|
+
private listeners;
|
|
230
|
+
on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): () => void;
|
|
231
|
+
emit<K extends keyof Events>(event: K, data: Events[K]): void;
|
|
232
|
+
removeAll(): void;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
declare interface FilterRule {
|
|
236
|
+
table?: string;
|
|
237
|
+
column: string;
|
|
238
|
+
op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'between';
|
|
239
|
+
value: string;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
declare interface Invite {
|
|
243
|
+
inviteId: string;
|
|
244
|
+
email: string;
|
|
245
|
+
role: string;
|
|
246
|
+
token: string;
|
|
247
|
+
expiresAt: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
declare interface Invoice {
|
|
251
|
+
id: string;
|
|
252
|
+
projectId: string;
|
|
253
|
+
customerId: string;
|
|
254
|
+
subscriptionId?: string;
|
|
255
|
+
amountCents: number;
|
|
256
|
+
status: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
|
|
257
|
+
stripeInvoiceId?: string;
|
|
258
|
+
pdfUrl?: string;
|
|
259
|
+
dueDate?: string;
|
|
260
|
+
paidAt?: string;
|
|
261
|
+
createdAt: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export declare function InvoiceHistory({ customerId, portalToken, appearance: localAppearance }: InvoiceHistoryProps): JSX_2.Element;
|
|
265
|
+
|
|
266
|
+
export declare interface InvoiceHistoryProps {
|
|
267
|
+
customerId: string;
|
|
268
|
+
portalToken?: string;
|
|
269
|
+
appearance?: Appearance;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export declare function isMfaRequired(result: AuthResult): result is MfaRequiredResult;
|
|
273
|
+
|
|
274
|
+
declare type Listener<T> = (data: T) => void;
|
|
275
|
+
|
|
276
|
+
declare interface ListParams {
|
|
277
|
+
page?: number;
|
|
278
|
+
perPage?: number;
|
|
279
|
+
sort?: string;
|
|
280
|
+
order?: string;
|
|
281
|
+
search?: string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare interface Member {
|
|
285
|
+
userId: string;
|
|
286
|
+
email: string;
|
|
287
|
+
role: string;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export declare interface MfaRequiredResult {
|
|
291
|
+
mfaRequired: true;
|
|
292
|
+
mfaToken: string;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
declare interface MfaSetupResult {
|
|
296
|
+
secret: string;
|
|
297
|
+
uri: string;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
declare interface MfaVerifyResult {
|
|
301
|
+
backupCodes: string[];
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export declare type OAuthProvider = 'google' | 'github';
|
|
305
|
+
|
|
306
|
+
declare interface OffsetPage<T> {
|
|
307
|
+
data: T[];
|
|
308
|
+
meta: {
|
|
309
|
+
page: number;
|
|
310
|
+
perPage: number;
|
|
311
|
+
total: number;
|
|
312
|
+
totalPages: number;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
declare interface Org {
|
|
317
|
+
id: string;
|
|
318
|
+
projectId: string;
|
|
319
|
+
name: string;
|
|
320
|
+
slug: string;
|
|
321
|
+
avatarUrl?: string;
|
|
322
|
+
metadata?: string;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export declare function OrgSwitcher({ appearance: localAppearance, onOrgChange }: OrgSwitcherProps): JSX_2.Element | null;
|
|
326
|
+
|
|
327
|
+
export declare interface OrgSwitcherProps {
|
|
328
|
+
appearance?: Appearance;
|
|
329
|
+
onOrgChange?: (org: Org) => void;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export declare function PaymentPortal({ customerId, portalToken, limits, onChangePlan, onCancel, appearance: localAppearance, }: PaymentPortalProps): JSX_2.Element;
|
|
333
|
+
|
|
334
|
+
export declare interface PaymentPortalProps {
|
|
335
|
+
customerId: string;
|
|
336
|
+
portalToken?: string;
|
|
337
|
+
limits?: Record<string, number>;
|
|
338
|
+
onChangePlan?: () => void;
|
|
339
|
+
onCancel?: () => void;
|
|
340
|
+
appearance?: Appearance;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
declare interface Plan {
|
|
344
|
+
id: string;
|
|
345
|
+
name: string;
|
|
346
|
+
description?: string;
|
|
347
|
+
amountCents: number;
|
|
348
|
+
interval: 'month' | 'year';
|
|
349
|
+
currency: string;
|
|
350
|
+
trialDays: number;
|
|
351
|
+
isFree: boolean;
|
|
352
|
+
features: string[];
|
|
353
|
+
isActive: boolean;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
declare interface PortalTokenResult {
|
|
357
|
+
portalToken: string;
|
|
358
|
+
expiresAt: string;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
export declare function PricingTable({ plans, currentPlanId, onSelectPlan, interval, appearance: localAppearance }: PricingTableProps): JSX_2.Element;
|
|
362
|
+
|
|
363
|
+
export declare interface PricingTableProps {
|
|
364
|
+
plans: Plan[];
|
|
365
|
+
currentPlanId?: string;
|
|
366
|
+
onSelectPlan: (planId: string) => void;
|
|
367
|
+
interval?: 'month' | 'year';
|
|
368
|
+
appearance?: Appearance;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
declare interface ProjectSettings {
|
|
372
|
+
googleEnabled: boolean;
|
|
373
|
+
githubEnabled: boolean;
|
|
374
|
+
emailEnabled: boolean;
|
|
375
|
+
mfaEnforced: boolean;
|
|
376
|
+
passwordMinLength: number;
|
|
377
|
+
emailVerification: boolean;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export declare function QueryInput({ onResult, mode, placeholder, appearance: localAppearance }: QueryInputProps): JSX_2.Element;
|
|
381
|
+
|
|
382
|
+
export declare interface QueryInputProps {
|
|
383
|
+
onResult?: (result: QueryResult) => void;
|
|
384
|
+
mode?: 'nl' | 'sql' | 'both';
|
|
385
|
+
placeholder?: string;
|
|
386
|
+
appearance?: Appearance;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
declare interface QueryParams {
|
|
390
|
+
naturalLanguage?: string;
|
|
391
|
+
sql?: string;
|
|
392
|
+
filterRules?: FilterRule[];
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
declare interface QueryResult {
|
|
396
|
+
sql: string;
|
|
397
|
+
columns: string[];
|
|
398
|
+
rows: Record<string, unknown>[];
|
|
399
|
+
rowCount: number;
|
|
400
|
+
executionMs: number;
|
|
401
|
+
chartType: string;
|
|
402
|
+
cached: boolean;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
declare class ReportClient {
|
|
406
|
+
private transport;
|
|
407
|
+
constructor(transport: Transport);
|
|
408
|
+
executeQuery(params: QueryParams): Promise<QueryResult>;
|
|
409
|
+
listQueries(params?: ListParams): Promise<OffsetPage<SavedQuery>>;
|
|
410
|
+
saveQuery(params: {
|
|
411
|
+
name: string;
|
|
412
|
+
naturalLanguage?: string;
|
|
413
|
+
generatedSql?: string;
|
|
414
|
+
chartType?: string;
|
|
415
|
+
}): Promise<SavedQuery>;
|
|
416
|
+
updateQuery(queryId: string, params: {
|
|
417
|
+
name?: string;
|
|
418
|
+
chartType?: string;
|
|
419
|
+
}): Promise<SavedQuery>;
|
|
420
|
+
deleteQuery(queryId: string): Promise<void>;
|
|
421
|
+
listDashboards(params?: ListParams): Promise<OffsetPage<Dashboard>>;
|
|
422
|
+
createDashboard(params: {
|
|
423
|
+
name: string;
|
|
424
|
+
layoutJson?: string;
|
|
425
|
+
isPublic?: boolean;
|
|
426
|
+
refreshIntervalSeconds?: number;
|
|
427
|
+
}): Promise<Dashboard>;
|
|
428
|
+
getDashboard(dashboardId: string): Promise<Dashboard>;
|
|
429
|
+
updateDashboard(dashboardId: string, params: {
|
|
430
|
+
name?: string;
|
|
431
|
+
layoutJson?: string;
|
|
432
|
+
isPublic?: boolean;
|
|
433
|
+
refreshIntervalSeconds?: number;
|
|
434
|
+
}): Promise<Dashboard>;
|
|
435
|
+
deleteDashboard(dashboardId: string): Promise<void>;
|
|
436
|
+
createEmbedToken(params: {
|
|
437
|
+
dashboardId?: string;
|
|
438
|
+
customerId?: string;
|
|
439
|
+
expiresIn?: number;
|
|
440
|
+
filterRules?: FilterRule[];
|
|
441
|
+
}): Promise<EmbedTokenResult>;
|
|
442
|
+
listEmbedTokens(): Promise<EmbedToken[]>;
|
|
443
|
+
revokeEmbedToken(tokenId: string): Promise<void>;
|
|
444
|
+
private toQueryString;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Standalone embeddable dashboard viewer.
|
|
449
|
+
* Does NOT require SaaSProvider — creates its own transport with embedToken.
|
|
450
|
+
*/
|
|
451
|
+
export declare function ReportEmbed({ embedToken, dashboardId, baseUrl, refreshInterval, appearance }: ReportEmbedProps): JSX_2.Element;
|
|
452
|
+
|
|
453
|
+
export declare interface ReportEmbedProps {
|
|
454
|
+
embedToken: string;
|
|
455
|
+
dashboardId: string;
|
|
456
|
+
baseUrl?: string;
|
|
457
|
+
refreshInterval?: number;
|
|
458
|
+
appearance?: Appearance;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
export declare const SaaSContext: Context<SaaSContextValue | null>;
|
|
462
|
+
|
|
463
|
+
export declare interface SaaSContextValue {
|
|
464
|
+
client: SaaSSupport;
|
|
465
|
+
user: User | null;
|
|
466
|
+
isLoaded: boolean;
|
|
467
|
+
appearance?: Appearance;
|
|
468
|
+
settings: ProjectSettings | null;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
export declare class SaaSError extends Error {
|
|
472
|
+
code: number;
|
|
473
|
+
domain: 'auth' | 'billing' | 'report' | 'unknown';
|
|
474
|
+
constructor(code: number, message: string, domain?: 'auth' | 'billing' | 'report' | 'unknown');
|
|
475
|
+
get isNotFound(): boolean;
|
|
476
|
+
get isUnauthorized(): boolean;
|
|
477
|
+
get isForbidden(): boolean;
|
|
478
|
+
get isConflict(): boolean;
|
|
479
|
+
get isRateLimited(): boolean;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
declare interface SaaSEvents {
|
|
483
|
+
authStateChange: User | null;
|
|
484
|
+
error: SaaSError;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
export declare interface SaaSOptions {
|
|
488
|
+
/** Publishable key for auth (end-user facing, pub_live_ prefix) */
|
|
489
|
+
publishableKey?: string;
|
|
490
|
+
/** API key for billing/report operations */
|
|
491
|
+
apiKey?: string;
|
|
492
|
+
/** Override the default API base URL */
|
|
493
|
+
baseUrl?: string;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export declare function SaaSProvider({ publishableKey, apiKey, baseUrl, appearance, children }: SaaSProviderProps): JSX_2.Element;
|
|
497
|
+
|
|
498
|
+
export declare interface SaaSProviderProps {
|
|
499
|
+
publishableKey?: string;
|
|
500
|
+
apiKey?: string;
|
|
501
|
+
baseUrl?: string;
|
|
502
|
+
appearance?: Appearance;
|
|
503
|
+
children: ReactNode;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
export declare class SaaSSupport {
|
|
507
|
+
readonly auth: AuthClient;
|
|
508
|
+
readonly billing: BillingClient;
|
|
509
|
+
readonly report: ReportClient;
|
|
510
|
+
private tokenManager;
|
|
511
|
+
private emitter;
|
|
512
|
+
private loaded;
|
|
513
|
+
constructor(options: SaaSOptions);
|
|
514
|
+
load(): Promise<void>;
|
|
515
|
+
isLoaded(): boolean;
|
|
516
|
+
onError(callback: (error: SaaSError) => void): () => void;
|
|
517
|
+
destroy(): void;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
declare interface SavedQuery {
|
|
521
|
+
id: string;
|
|
522
|
+
projectId: string;
|
|
523
|
+
name: string;
|
|
524
|
+
naturalLanguage?: string;
|
|
525
|
+
generatedSql?: string;
|
|
526
|
+
chartType: string;
|
|
527
|
+
createdAt: string;
|
|
528
|
+
updatedAt: string;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export declare function SavedQueryList({ onSelectQuery, onRunQuery, appearance: localAppearance }: SavedQueryListProps): JSX_2.Element;
|
|
532
|
+
|
|
533
|
+
export declare interface SavedQueryListProps {
|
|
534
|
+
onSelectQuery?: (query: SavedQuery) => void;
|
|
535
|
+
onRunQuery?: (result: QueryResult) => void;
|
|
536
|
+
appearance?: Appearance;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export declare function SignIn({ appearance: localAppearance, signUpUrl, onSignUp }: SignInProps): JSX_2.Element;
|
|
540
|
+
|
|
541
|
+
export declare interface SignInProps {
|
|
542
|
+
appearance?: Appearance;
|
|
543
|
+
signUpUrl?: string;
|
|
544
|
+
afterSignInUrl?: string;
|
|
545
|
+
onSignUp?: () => void;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
export declare interface SignInResult {
|
|
549
|
+
user: User;
|
|
550
|
+
accessToken: string;
|
|
551
|
+
refreshToken: string;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
export declare function SignUp({ appearance: localAppearance, signInUrl, onSignIn }: SignUpProps): JSX_2.Element;
|
|
555
|
+
|
|
556
|
+
export declare interface SignUpProps {
|
|
557
|
+
appearance?: Appearance;
|
|
558
|
+
signInUrl?: string;
|
|
559
|
+
afterSignUpUrl?: string;
|
|
560
|
+
onSignIn?: () => void;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
export declare interface SignUpResult {
|
|
564
|
+
user: User;
|
|
565
|
+
accessToken: string;
|
|
566
|
+
refreshToken: string;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
declare interface Subscription {
|
|
570
|
+
id: string;
|
|
571
|
+
customerId: string;
|
|
572
|
+
planId: string;
|
|
573
|
+
projectId: string;
|
|
574
|
+
status: 'trialing' | 'active' | 'past_due' | 'paused' | 'canceled';
|
|
575
|
+
stripeSubscriptionId?: string;
|
|
576
|
+
cancelAtPeriodEnd: boolean;
|
|
577
|
+
trialEnd?: string;
|
|
578
|
+
currentPeriodStart: string;
|
|
579
|
+
currentPeriodEnd: string;
|
|
580
|
+
canceledAt?: string;
|
|
581
|
+
createdAt: string;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
export declare function SubscriptionStatus({ customerId, portalToken, onChangePlan, onCancel, appearance: localAppearance, }: SubscriptionStatusProps): JSX_2.Element;
|
|
585
|
+
|
|
586
|
+
export declare interface SubscriptionStatusProps {
|
|
587
|
+
customerId: string;
|
|
588
|
+
portalToken?: string;
|
|
589
|
+
onChangePlan?: () => void;
|
|
590
|
+
onCancel?: () => void;
|
|
591
|
+
appearance?: Appearance;
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
export declare interface ThemeVariables {
|
|
595
|
+
colorPrimary?: string;
|
|
596
|
+
colorBackground?: string;
|
|
597
|
+
colorText?: string;
|
|
598
|
+
colorInputBackground?: string;
|
|
599
|
+
colorInputBorder?: string;
|
|
600
|
+
colorError?: string;
|
|
601
|
+
colorSuccess?: string;
|
|
602
|
+
colorWarning?: string;
|
|
603
|
+
fontFamily?: string;
|
|
604
|
+
borderRadius?: string;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
declare class TokenManager {
|
|
608
|
+
private accessToken;
|
|
609
|
+
private refreshToken;
|
|
610
|
+
private refreshTimer;
|
|
611
|
+
private storageKey;
|
|
612
|
+
private onRefreshNeeded;
|
|
613
|
+
constructor(keyPrefix: string);
|
|
614
|
+
setRefreshCallback(cb: () => Promise<void>): void;
|
|
615
|
+
getAccessToken(): string | null;
|
|
616
|
+
getRefreshToken(): string | null;
|
|
617
|
+
hasRefreshToken(): boolean;
|
|
618
|
+
setTokens(accessToken: string, refreshToken: string): void;
|
|
619
|
+
clearTokens(): void;
|
|
620
|
+
destroy(): void;
|
|
621
|
+
private scheduleRefresh;
|
|
622
|
+
private getTokenExpiry;
|
|
623
|
+
private loadRefreshToken;
|
|
624
|
+
private saveRefreshToken;
|
|
625
|
+
private removeRefreshToken;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
declare class Transport {
|
|
629
|
+
private baseUrl;
|
|
630
|
+
private authMode;
|
|
631
|
+
constructor(baseUrl: string, authMode: AuthMode);
|
|
632
|
+
request<T>(method: string, path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
|
|
633
|
+
get<T>(path: string, headers?: Record<string, string>): Promise<T>;
|
|
634
|
+
post<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
|
|
635
|
+
patch<T>(path: string, body?: unknown, headers?: Record<string, string>): Promise<T>;
|
|
636
|
+
del<T>(path: string, headers?: Record<string, string>): Promise<T>;
|
|
637
|
+
private getAuthHeaders;
|
|
638
|
+
private inferDomain;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
export declare function UsageDisplay({ customerId, limits, portalToken, appearance: localAppearance }: UsageDisplayProps): JSX_2.Element;
|
|
642
|
+
|
|
643
|
+
export declare interface UsageDisplayProps {
|
|
644
|
+
customerId: string;
|
|
645
|
+
limits?: Record<string, number>;
|
|
646
|
+
portalToken?: string;
|
|
647
|
+
appearance?: Appearance;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
declare interface UsageSummary {
|
|
651
|
+
metric: string;
|
|
652
|
+
total: number;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
export declare function useAuth(): {
|
|
656
|
+
isLoaded: boolean;
|
|
657
|
+
isSignedIn: boolean;
|
|
658
|
+
user: User | null;
|
|
659
|
+
signOut: () => Promise<void>;
|
|
660
|
+
getToken: () => Promise<string | null>;
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
export declare function useBilling(): {
|
|
664
|
+
billing: BillingClient;
|
|
665
|
+
};
|
|
666
|
+
|
|
667
|
+
export declare function useDashboard(dashboardId: string): {
|
|
668
|
+
dashboard: Dashboard | null;
|
|
669
|
+
isLoading: boolean;
|
|
670
|
+
error: string | null;
|
|
671
|
+
refresh: () => Promise<void>;
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
export declare function useEmbedDashboard(embedToken: string, dashboardId: string, baseUrl?: string): {
|
|
675
|
+
dashboard: Dashboard | null;
|
|
676
|
+
reportClient: ReportClient;
|
|
677
|
+
isLoading: boolean;
|
|
678
|
+
error: string | null;
|
|
679
|
+
refresh: () => Promise<void>;
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
export declare function useInvoices(customerId: string, portalToken?: string): {
|
|
683
|
+
invoices: Invoice[];
|
|
684
|
+
isLoading: boolean;
|
|
685
|
+
error: string | null;
|
|
686
|
+
refresh: () => Promise<void>;
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
export declare function useOrg(): {
|
|
690
|
+
orgs: Org[];
|
|
691
|
+
selectedOrg: Org | null;
|
|
692
|
+
members: Member[];
|
|
693
|
+
isLoading: boolean;
|
|
694
|
+
error: string | null;
|
|
695
|
+
refresh: () => Promise<void>;
|
|
696
|
+
selectOrg: (orgId: string) => Promise<void>;
|
|
697
|
+
createOrg: (name: string, slug: string) => Promise<Org | null>;
|
|
698
|
+
};
|
|
699
|
+
|
|
700
|
+
export declare function useQuery(): {
|
|
701
|
+
result: QueryResult | null;
|
|
702
|
+
execute: (params: QueryParams) => Promise<QueryResult | null>;
|
|
703
|
+
isLoading: boolean;
|
|
704
|
+
error: string | null;
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
export declare interface User {
|
|
708
|
+
id: string;
|
|
709
|
+
email: string;
|
|
710
|
+
provider: string;
|
|
711
|
+
emailVerified: boolean;
|
|
712
|
+
metadata: Record<string, unknown>;
|
|
713
|
+
mfaEnabled?: boolean;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
export declare function UserButton({ appearance: localAppearance }: UserButtonProps): JSX_2.Element | null;
|
|
717
|
+
|
|
718
|
+
export declare interface UserButtonProps {
|
|
719
|
+
appearance?: Appearance;
|
|
720
|
+
afterSignOutUrl?: string;
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
export declare function useReport(): {
|
|
724
|
+
report: ReportClient;
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
export declare function UserProfile({ appearance: localAppearance }: UserProfileProps): JSX_2.Element | null;
|
|
728
|
+
|
|
729
|
+
export declare interface UserProfileProps {
|
|
730
|
+
appearance?: Appearance;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
export declare function useSaaSContext(): SaaSContextValue;
|
|
734
|
+
|
|
735
|
+
export declare function useSavedQueries(params?: ListParams): {
|
|
736
|
+
queries: SavedQuery[];
|
|
737
|
+
meta: {
|
|
738
|
+
page: number;
|
|
739
|
+
perPage: number;
|
|
740
|
+
total: number;
|
|
741
|
+
totalPages: number;
|
|
742
|
+
} | undefined;
|
|
743
|
+
isLoading: boolean;
|
|
744
|
+
error: string | null;
|
|
745
|
+
refresh: () => Promise<void>;
|
|
746
|
+
};
|
|
747
|
+
|
|
748
|
+
export declare function useSignIn(): {
|
|
749
|
+
signIn: (email: string, password: string) => Promise<AuthResult | null>;
|
|
750
|
+
signInWithOAuth: (provider: OAuthProvider) => Promise<SignInResult | null>;
|
|
751
|
+
submitMfaCode: (mfaToken: string, code: string) => Promise<SignInResult | null>;
|
|
752
|
+
isLoading: boolean;
|
|
753
|
+
error: string | null;
|
|
754
|
+
setError: Dispatch<SetStateAction<string | null>>;
|
|
755
|
+
};
|
|
756
|
+
|
|
757
|
+
export declare function useSignUp(): {
|
|
758
|
+
signUp: (email: string, password: string) => Promise<SignUpResult | null>;
|
|
759
|
+
isLoading: boolean;
|
|
760
|
+
error: string | null;
|
|
761
|
+
setError: Dispatch<SetStateAction<string | null>>;
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
export declare function useSubscription(customerId: string, portalToken?: string): {
|
|
765
|
+
customer: Customer | null;
|
|
766
|
+
isLoading: boolean;
|
|
767
|
+
error: string | null;
|
|
768
|
+
refresh: () => Promise<void>;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
export declare function useUsage(customerId: string, portalToken?: string): {
|
|
772
|
+
usage: UsageSummary[];
|
|
773
|
+
isLoading: boolean;
|
|
774
|
+
error: string | null;
|
|
775
|
+
refresh: () => Promise<void>;
|
|
776
|
+
};
|
|
777
|
+
|
|
778
|
+
export declare function useUser(): {
|
|
779
|
+
user: User | null;
|
|
780
|
+
isLoaded: boolean;
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
export { }
|