@saas-support/react 0.7.6 → 0.8.1

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/dist/react.d.ts CHANGED
@@ -12,13 +12,6 @@ export declare interface Appearance {
12
12
  fontUrl?: string | null;
13
13
  }
14
14
 
15
- declare interface ApplyCouponResult {
16
- applied: boolean;
17
- discountType: string;
18
- amount: number;
19
- duration: string;
20
- }
21
-
22
15
  declare class AuthClient {
23
16
  private transport;
24
17
  private tokenManager;
@@ -70,6 +63,12 @@ declare class AuthClient {
70
63
  avatarUrl?: string;
71
64
  }): Promise<Org>;
72
65
  deleteOrg(orgId: string): Promise<void>;
66
+ uploadOrgAvatar(orgId: string, imageBlob: Blob): Promise<{
67
+ avatarUrl: string;
68
+ small: string;
69
+ medium: string;
70
+ original: string;
71
+ }>;
73
72
  listMembers(orgId: string): Promise<Member[]>;
74
73
  sendInvite(orgId: string, email: string, role: string): Promise<Invite>;
75
74
  updateMemberRole(orgId: string, userId: string, role: string): Promise<void>;
@@ -112,109 +111,6 @@ export declare type AuthResult = SignInResult | MfaRequiredResult;
112
111
 
113
112
  declare type AuthStateCallback = (user: User | null) => void;
114
113
 
115
- declare class BillingClient {
116
- private transport;
117
- constructor(transport: Transport);
118
- createCustomer(params: {
119
- email: string;
120
- name?: string;
121
- metadata?: string;
122
- }): Promise<Customer>;
123
- getCustomer(customerId: string): Promise<Customer>;
124
- updateCustomer(customerId: string, params: {
125
- email?: string;
126
- name?: string;
127
- metadata?: string;
128
- }): Promise<Customer>;
129
- subscribe(customerId: string, planId: string): Promise<Subscription>;
130
- changePlan(customerId: string, planId: string): Promise<Subscription>;
131
- cancelSubscription(customerId: string): Promise<{
132
- canceledAtPeriodEnd: boolean;
133
- }>;
134
- getInvoices(customerId: string): Promise<Invoice[]>;
135
- ingestUsageEvent(params: {
136
- customerId: string;
137
- metric: string;
138
- quantity: number;
139
- timestamp?: string;
140
- idempotencyKey?: string;
141
- }): Promise<{
142
- id: string;
143
- ingested: boolean;
144
- }>;
145
- getCurrentUsage(customerId: string): Promise<UsageSummary[]>;
146
- createPortalToken(customerId: string, expiresIn?: number): Promise<PortalTokenResult>;
147
- applyCoupon(customerId: string, code: string): Promise<ApplyCouponResult>;
148
- }
149
-
150
- export declare function Chart({ type, data, title, width, height, appearance: localAppearance }: ChartProps): JSX_2.Element;
151
-
152
- export declare interface ChartProps {
153
- type: 'bar' | 'line' | 'pie';
154
- data: {
155
- labels: string[];
156
- values: number[];
157
- };
158
- title?: string;
159
- width?: number;
160
- height?: number;
161
- appearance?: Appearance;
162
- }
163
-
164
- export declare function CouponInput({ customerId, portalToken, onApplied, appearance: localAppearance }: CouponInputProps): JSX_2.Element;
165
-
166
- export declare interface CouponInputProps {
167
- customerId: string;
168
- portalToken?: string;
169
- onApplied?: (result: ApplyCouponResult) => void;
170
- appearance?: Appearance;
171
- }
172
-
173
- declare interface Customer {
174
- id: string;
175
- projectId: string;
176
- email: string;
177
- name?: string;
178
- stripeCustomerId?: string;
179
- balanceCents: number;
180
- metadata?: string;
181
- taxExempt: boolean;
182
- taxId?: string;
183
- createdAt: string;
184
- updatedAt: string;
185
- }
186
-
187
- declare interface Dashboard {
188
- id: string;
189
- projectId: string;
190
- name: string;
191
- layoutJson: string;
192
- isPublic: boolean;
193
- refreshIntervalSeconds: number;
194
- createdAt: string;
195
- updatedAt: string;
196
- }
197
-
198
- export declare function DashboardView({ dashboardId, embedToken, baseUrl, refreshInterval, appearance: localAppearance }: DashboardViewProps): JSX_2.Element;
199
-
200
- export declare interface DashboardViewProps {
201
- dashboardId: string;
202
- embedToken?: string;
203
- baseUrl?: string;
204
- refreshInterval?: number;
205
- appearance?: Appearance;
206
- }
207
-
208
- export declare function DataTable({ columns, rows, sortable, maxRows, appearance: localAppearance }: DataTableProps): JSX_2.Element;
209
-
210
- export declare interface DataTableProps {
211
- columns: string[];
212
- rows: Record<string, unknown>[];
213
- sortable?: boolean;
214
- maxRows?: number;
215
- appearance?: Appearance;
216
- }
217
-
218
114
  declare interface ElementOverrides {
219
115
  card?: React.CSSProperties;
220
116
  headerTitle?: React.CSSProperties;
@@ -241,22 +137,6 @@ declare interface ElementOverrides {
241
137
  profileHeader?: React.CSSProperties;
242
138
  }
243
139
 
244
- declare interface EmbedToken {
245
- id: string;
246
- projectId: string;
247
- dashboardId?: string;
248
- customerId?: string;
249
- filterRules?: FilterRule[];
250
- expiresAt: string;
251
- createdAt: string;
252
- revokedAt?: string;
253
- }
254
-
255
- declare interface EmbedTokenResult {
256
- embedToken: string;
257
- expiresAt: string;
258
- }
259
-
260
140
  declare class EventEmitter<Events extends Record<string, any>> {
261
141
  private listeners;
262
142
  on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): () => void;
@@ -264,13 +144,6 @@ declare class EventEmitter<Events extends Record<string, any>> {
264
144
  removeAll(): void;
265
145
  }
266
146
 
267
- declare interface FilterRule {
268
- table?: string;
269
- column: string;
270
- op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'between';
271
- value: string;
272
- }
273
-
274
147
  export declare interface Invite {
275
148
  inviteId: string;
276
149
  email: string;
@@ -279,40 +152,10 @@ export declare interface Invite {
279
152
  expiresAt: string;
280
153
  }
281
154
 
282
- declare interface Invoice {
283
- id: string;
284
- projectId: string;
285
- customerId: string;
286
- subscriptionId?: string;
287
- amountCents: number;
288
- status: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
289
- stripeInvoiceId?: string;
290
- pdfUrl?: string;
291
- dueDate?: string;
292
- paidAt?: string;
293
- createdAt: string;
294
- }
295
-
296
- export declare function InvoiceHistory({ customerId, portalToken, appearance: localAppearance }: InvoiceHistoryProps): JSX_2.Element;
297
-
298
- export declare interface InvoiceHistoryProps {
299
- customerId: string;
300
- portalToken?: string;
301
- appearance?: Appearance;
302
- }
303
-
304
155
  export declare function isMfaRequired(result: AuthResult): result is MfaRequiredResult;
305
156
 
306
157
  declare type Listener<T> = (data: T) => void;
307
158
 
308
- declare interface ListParams {
309
- page?: number;
310
- perPage?: number;
311
- sort?: string;
312
- order?: string;
313
- search?: string;
314
- }
315
-
316
159
  export declare interface Member {
317
160
  userId: string;
318
161
  email: string;
@@ -344,16 +187,6 @@ export declare interface MyPendingInvite {
344
187
 
345
188
  export declare type OAuthProvider = 'google' | 'github';
346
189
 
347
- declare interface OffsetPage<T> {
348
- data: T[];
349
- meta: {
350
- page: number;
351
- perPage: number;
352
- total: number;
353
- totalPages: number;
354
- };
355
- }
356
-
357
190
  export declare interface Org {
358
191
  id: string;
359
192
  projectId: string;
@@ -364,24 +197,6 @@ export declare interface Org {
364
197
  planName?: string;
365
198
  }
366
199
 
367
- export declare function OrgSwitcher({ appearance: localAppearance, onOrgChange }: OrgSwitcherProps): JSX_2.Element | null;
368
-
369
- export declare interface OrgSwitcherProps {
370
- appearance?: Appearance;
371
- onOrgChange?: (org: Org) => void;
372
- }
373
-
374
- export declare function PaymentPortal({ customerId, portalToken, limits, onChangePlan, onCancel, appearance: localAppearance, }: PaymentPortalProps): JSX_2.Element;
375
-
376
- export declare interface PaymentPortalProps {
377
- customerId: string;
378
- portalToken?: string;
379
- limits?: Record<string, number>;
380
- onChangePlan?: () => void;
381
- onCancel?: () => void;
382
- appearance?: Appearance;
383
- }
384
-
385
200
  export declare interface PendingInvite {
386
201
  id: string;
387
202
  email: string;
@@ -390,34 +205,6 @@ export declare interface PendingInvite {
390
205
  createdAt: string;
391
206
  }
392
207
 
393
- declare interface Plan {
394
- id: string;
395
- name: string;
396
- description?: string;
397
- amountCents: number;
398
- interval: 'month' | 'year';
399
- currency: string;
400
- trialDays: number;
401
- isFree: boolean;
402
- features: string[];
403
- isActive: boolean;
404
- }
405
-
406
- declare interface PortalTokenResult {
407
- portalToken: string;
408
- expiresAt: string;
409
- }
410
-
411
- export declare function PricingTable({ plans, currentPlanId, onSelectPlan, interval, appearance: localAppearance }: PricingTableProps): JSX_2.Element;
412
-
413
- export declare interface PricingTableProps {
414
- plans: Plan[];
415
- currentPlanId?: string;
416
- onSelectPlan: (planId: string) => void;
417
- interval?: 'month' | 'year';
418
- appearance?: Appearance;
419
- }
420
-
421
208
  declare interface ProjectSettings {
422
209
  googleEnabled: boolean;
423
210
  githubEnabled: boolean;
@@ -425,87 +212,8 @@ declare interface ProjectSettings {
425
212
  mfaEnforced: boolean;
426
213
  passwordMinLength: number;
427
214
  emailVerification: boolean;
428
- }
429
-
430
- export declare function QueryInput({ onResult, mode, placeholder, appearance: localAppearance }: QueryInputProps): JSX_2.Element;
431
-
432
- export declare interface QueryInputProps {
433
- onResult?: (result: QueryResult) => void;
434
- mode?: 'nl' | 'sql' | 'both';
435
- placeholder?: string;
436
- appearance?: Appearance;
437
- }
438
-
439
- declare interface QueryParams {
440
- naturalLanguage?: string;
441
- sql?: string;
442
- filterRules?: FilterRule[];
443
- }
444
-
445
- declare interface QueryResult {
446
- sql: string;
447
- columns: string[];
448
- rows: Record<string, unknown>[];
449
- rowCount: number;
450
- executionMs: number;
451
- chartType: string;
452
- cached: boolean;
453
- }
454
-
455
- declare class ReportClient {
456
- private transport;
457
- constructor(transport: Transport);
458
- executeQuery(params: QueryParams): Promise<QueryResult>;
459
- listQueries(params?: ListParams): Promise<OffsetPage<SavedQuery>>;
460
- saveQuery(params: {
461
- name: string;
462
- naturalLanguage?: string;
463
- generatedSql?: string;
464
- chartType?: string;
465
- }): Promise<SavedQuery>;
466
- updateQuery(queryId: string, params: {
467
- name?: string;
468
- chartType?: string;
469
- }): Promise<SavedQuery>;
470
- deleteQuery(queryId: string): Promise<void>;
471
- listDashboards(params?: ListParams): Promise<OffsetPage<Dashboard>>;
472
- createDashboard(params: {
473
- name: string;
474
- layoutJson?: string;
475
- isPublic?: boolean;
476
- refreshIntervalSeconds?: number;
477
- }): Promise<Dashboard>;
478
- getDashboard(dashboardId: string): Promise<Dashboard>;
479
- updateDashboard(dashboardId: string, params: {
480
- name?: string;
481
- layoutJson?: string;
482
- isPublic?: boolean;
483
- refreshIntervalSeconds?: number;
484
- }): Promise<Dashboard>;
485
- deleteDashboard(dashboardId: string): Promise<void>;
486
- createEmbedToken(params: {
487
- dashboardId?: string;
488
- customerId?: string;
489
- expiresIn?: number;
490
- filterRules?: FilterRule[];
491
- }): Promise<EmbedTokenResult>;
492
- listEmbedTokens(): Promise<EmbedToken[]>;
493
- revokeEmbedToken(tokenId: string): Promise<void>;
494
- private toQueryString;
495
- }
496
-
497
- /**
498
- * Standalone embeddable dashboard viewer.
499
- * Does NOT require SaaSProvider — creates its own transport with embedToken.
500
- */
501
- export declare function ReportEmbed({ embedToken, dashboardId, baseUrl, refreshInterval, appearance }: ReportEmbedProps): JSX_2.Element;
502
-
503
- export declare interface ReportEmbedProps {
504
- embedToken: string;
505
- dashboardId: string;
506
- baseUrl?: string;
507
- refreshInterval?: number;
508
- appearance?: Appearance;
215
+ privacyPolicyUrl?: string;
216
+ termsOfServiceUrl?: string;
509
217
  }
510
218
 
511
219
  export declare const SaaSContext: Context<SaaSContextValue | null>;
@@ -555,8 +263,6 @@ export declare interface SaaSProviderProps {
555
263
 
556
264
  export declare class SaaSSupport {
557
265
  readonly auth: AuthClient;
558
- readonly billing: BillingClient;
559
- readonly report: ReportClient;
560
266
  private tokenManager;
561
267
  private emitter;
562
268
  private loaded;
@@ -568,25 +274,6 @@ export declare class SaaSSupport {
568
274
  destroy(): void;
569
275
  }
570
276
 
571
- declare interface SavedQuery {
572
- id: string;
573
- projectId: string;
574
- name: string;
575
- naturalLanguage?: string;
576
- generatedSql?: string;
577
- chartType: string;
578
- createdAt: string;
579
- updatedAt: string;
580
- }
581
-
582
- export declare function SavedQueryList({ onSelectQuery, onRunQuery, appearance: localAppearance }: SavedQueryListProps): JSX_2.Element;
583
-
584
- export declare interface SavedQueryListProps {
585
- onSelectQuery?: (query: SavedQuery) => void;
586
- onRunQuery?: (result: QueryResult) => void;
587
- appearance?: Appearance;
588
- }
589
-
590
277
  export declare function SettingsPanel({ onClose, afterDeleteAccountUrl, defaultTab, onOrgDeleted, onOrgUpdated }: SettingsPanelProps): JSX_2.Element;
591
278
 
592
279
  export declare interface SettingsPanelProps {
@@ -599,13 +286,13 @@ export declare interface SettingsPanelProps {
599
286
 
600
287
  declare type SettingsTab = 'profile' | 'organization' | 'people' | 'invites' | 'billing';
601
288
 
602
- export declare function SignIn({ appearance: localAppearance, signUpUrl, onSignUp }: SignInProps): JSX_2.Element;
289
+ export declare function SignIn({ appearance: localAppearance, afterSignInUrl, afterSignUpUrl, initialMode, }: SignInProps): JSX_2.Element;
603
290
 
604
291
  export declare interface SignInProps {
605
292
  appearance?: Appearance;
606
- signUpUrl?: string;
607
293
  afterSignInUrl?: string;
608
- onSignUp?: () => void;
294
+ afterSignUpUrl?: string;
295
+ initialMode?: 'signIn' | 'signUp';
609
296
  }
610
297
 
611
298
  export declare interface SignInResult {
@@ -614,46 +301,12 @@ export declare interface SignInResult {
614
301
  refreshToken: string;
615
302
  }
616
303
 
617
- export declare function SignUp({ appearance: localAppearance, signInUrl, onSignIn }: SignUpProps): JSX_2.Element;
618
-
619
- export declare interface SignUpProps {
620
- appearance?: Appearance;
621
- signInUrl?: string;
622
- afterSignUpUrl?: string;
623
- onSignIn?: () => void;
624
- }
625
-
626
304
  export declare interface SignUpResult {
627
305
  user: User;
628
306
  accessToken: string;
629
307
  refreshToken: string;
630
308
  }
631
309
 
632
- declare interface Subscription {
633
- id: string;
634
- customerId: string;
635
- planId: string;
636
- projectId: string;
637
- status: 'trialing' | 'active' | 'past_due' | 'paused' | 'canceled';
638
- stripeSubscriptionId?: string;
639
- cancelAtPeriodEnd: boolean;
640
- trialEnd?: string;
641
- currentPeriodStart: string;
642
- currentPeriodEnd: string;
643
- canceledAt?: string;
644
- createdAt: string;
645
- }
646
-
647
- export declare function SubscriptionStatus({ customerId, portalToken, onChangePlan, onCancel, appearance: localAppearance, }: SubscriptionStatusProps): JSX_2.Element;
648
-
649
- export declare interface SubscriptionStatusProps {
650
- customerId: string;
651
- portalToken?: string;
652
- onChangePlan?: () => void;
653
- onCancel?: () => void;
654
- appearance?: Appearance;
655
- }
656
-
657
310
  export declare interface ThemeVariables {
658
311
  colorPrimary?: string;
659
312
  colorBackground?: string;
@@ -724,20 +377,6 @@ declare class Transport {
724
377
  private inferDomain;
725
378
  }
726
379
 
727
- export declare function UsageDisplay({ customerId, limits, portalToken, appearance: localAppearance }: UsageDisplayProps): JSX_2.Element;
728
-
729
- export declare interface UsageDisplayProps {
730
- customerId: string;
731
- limits?: Record<string, number>;
732
- portalToken?: string;
733
- appearance?: Appearance;
734
- }
735
-
736
- declare interface UsageSummary {
737
- metric: string;
738
- total: number;
739
- }
740
-
741
380
  export declare function useAuth(): {
742
381
  isLoaded: boolean;
743
382
  isSignedIn: boolean;
@@ -747,17 +386,6 @@ export declare function useAuth(): {
747
386
  refreshUser: () => Promise<User | null>;
748
387
  };
749
388
 
750
- export declare function useBilling(): {
751
- billing: BillingClient;
752
- };
753
-
754
- export declare function useDashboard(dashboardId: string): {
755
- dashboard: Dashboard | null;
756
- isLoading: boolean;
757
- error: string | null;
758
- refresh: () => Promise<void>;
759
- };
760
-
761
389
  export declare function useDeleteAccount(): {
762
390
  deleteAccount: () => Promise<boolean>;
763
391
  isLoading: boolean;
@@ -765,14 +393,6 @@ export declare function useDeleteAccount(): {
765
393
  setError: Dispatch<SetStateAction<string | null>>;
766
394
  };
767
395
 
768
- export declare function useEmbedDashboard(embedToken: string, dashboardId: string, baseUrl?: string): {
769
- dashboard: Dashboard | null;
770
- reportClient: ReportClient;
771
- isLoading: boolean;
772
- error: string | null;
773
- refresh: () => Promise<void>;
774
- };
775
-
776
396
  export declare function useInvites(): {
777
397
  invites: MyPendingInvite[];
778
398
  isLoading: boolean;
@@ -786,13 +406,6 @@ export declare function useInvites(): {
786
406
  decline: (inviteId: string) => Promise<boolean>;
787
407
  };
788
408
 
789
- export declare function useInvoices(customerId: string, portalToken?: string): {
790
- invoices: Invoice[];
791
- isLoading: boolean;
792
- error: string | null;
793
- refresh: () => Promise<void>;
794
- };
795
-
796
409
  export declare function useOrg(): {
797
410
  orgs: Org[];
798
411
  selectedOrg: Org | null;
@@ -815,6 +428,12 @@ export declare function useOrg(): {
815
428
  updateMemberRole: (orgId: string, userId: string, role: string) => Promise<boolean>;
816
429
  removeMember: (orgId: string, userId: string) => Promise<boolean>;
817
430
  refreshMembers: (orgId: string) => Promise<void>;
431
+ uploadOrgAvatar: (orgId: string, imageBlob: Blob) => Promise<{
432
+ avatarUrl: string;
433
+ small: string;
434
+ medium: string;
435
+ original: string;
436
+ } | null>;
818
437
  };
819
438
 
820
439
  export declare function useProfile(): {
@@ -838,13 +457,6 @@ export declare function useProfile(): {
838
457
  setSuccess: Dispatch<SetStateAction<string | null>>;
839
458
  };
840
459
 
841
- export declare function useQuery(): {
842
- result: QueryResult | null;
843
- execute: (params: QueryParams) => Promise<QueryResult | null>;
844
- isLoading: boolean;
845
- error: string | null;
846
- };
847
-
848
460
  export declare interface User {
849
461
  id: string;
850
462
  email: string;
@@ -867,31 +479,8 @@ export declare interface UserButtonProps {
867
479
  onOrgSettingsClick?: (org: Org) => void;
868
480
  }
869
481
 
870
- export declare function useReport(): {
871
- report: ReportClient;
872
- };
873
-
874
- export declare function UserProfile({ appearance: localAppearance }: UserProfileProps): JSX_2.Element | null;
875
-
876
- export declare interface UserProfileProps {
877
- appearance?: Appearance;
878
- }
879
-
880
482
  export declare function useSaaSContext(): SaaSContextValue;
881
483
 
882
- export declare function useSavedQueries(params?: ListParams): {
883
- queries: SavedQuery[];
884
- meta: {
885
- page: number;
886
- perPage: number;
887
- total: number;
888
- totalPages: number;
889
- } | undefined;
890
- isLoading: boolean;
891
- error: string | null;
892
- refresh: () => Promise<void>;
893
- };
894
-
895
484
  export declare function useSignIn(): {
896
485
  signIn: (email: string, password: string) => Promise<AuthResult | null>;
897
486
  signInWithOAuth: (provider: OAuthProvider) => Promise<SignInResult | null>;
@@ -908,20 +497,6 @@ export declare function useSignUp(): {
908
497
  setError: Dispatch<SetStateAction<string | null>>;
909
498
  };
910
499
 
911
- export declare function useSubscription(customerId: string, portalToken?: string): {
912
- customer: Customer | null;
913
- isLoading: boolean;
914
- error: string | null;
915
- refresh: () => Promise<void>;
916
- };
917
-
918
- export declare function useUsage(customerId: string, portalToken?: string): {
919
- usage: UsageSummary[];
920
- isLoading: boolean;
921
- error: string | null;
922
- refresh: () => Promise<void>;
923
- };
924
-
925
500
  export declare function useUser(): {
926
501
  user: User | null;
927
502
  isLoaded: boolean;