@saas-support/react 0.7.5 → 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>;
@@ -80,6 +79,12 @@ declare class AuthClient {
80
79
  }>;
81
80
  listInvites(orgId: string): Promise<PendingInvite[]>;
82
81
  revokeInvite(orgId: string, inviteId: string): Promise<void>;
82
+ listMyInvites(): Promise<MyPendingInvite[]>;
83
+ acceptInviteById(inviteId: string): Promise<{
84
+ orgId: string;
85
+ role: string;
86
+ }>;
87
+ declineInvite(inviteId: string): Promise<void>;
83
88
  deleteAccount(): Promise<void>;
84
89
  /* Excluded from this release type: handleExternalLogout */
85
90
  /* Excluded from this release type: performRefresh */
@@ -106,109 +111,6 @@ export declare type AuthResult = SignInResult | MfaRequiredResult;
106
111
 
107
112
  declare type AuthStateCallback = (user: User | null) => void;
108
113
 
109
- declare class BillingClient {
110
- private transport;
111
- constructor(transport: Transport);
112
- createCustomer(params: {
113
- email: string;
114
- name?: string;
115
- metadata?: string;
116
- }): Promise<Customer>;
117
- getCustomer(customerId: string): Promise<Customer>;
118
- updateCustomer(customerId: string, params: {
119
- email?: string;
120
- name?: string;
121
- metadata?: string;
122
- }): Promise<Customer>;
123
- subscribe(customerId: string, planId: string): Promise<Subscription>;
124
- changePlan(customerId: string, planId: string): Promise<Subscription>;
125
- cancelSubscription(customerId: string): Promise<{
126
- canceledAtPeriodEnd: boolean;
127
- }>;
128
- getInvoices(customerId: string): Promise<Invoice[]>;
129
- ingestUsageEvent(params: {
130
- customerId: string;
131
- metric: string;
132
- quantity: number;
133
- timestamp?: string;
134
- idempotencyKey?: string;
135
- }): Promise<{
136
- id: string;
137
- ingested: boolean;
138
- }>;
139
- getCurrentUsage(customerId: string): Promise<UsageSummary[]>;
140
- createPortalToken(customerId: string, expiresIn?: number): Promise<PortalTokenResult>;
141
- applyCoupon(customerId: string, code: string): Promise<ApplyCouponResult>;
142
- }
143
-
144
- export declare function Chart({ type, data, title, width, height, appearance: localAppearance }: ChartProps): JSX_2.Element;
145
-
146
- export declare interface ChartProps {
147
- type: 'bar' | 'line' | 'pie';
148
- data: {
149
- labels: string[];
150
- values: number[];
151
- };
152
- title?: string;
153
- width?: number;
154
- height?: number;
155
- appearance?: Appearance;
156
- }
157
-
158
- export declare function CouponInput({ customerId, portalToken, onApplied, appearance: localAppearance }: CouponInputProps): JSX_2.Element;
159
-
160
- export declare interface CouponInputProps {
161
- customerId: string;
162
- portalToken?: string;
163
- onApplied?: (result: ApplyCouponResult) => void;
164
- appearance?: Appearance;
165
- }
166
-
167
- declare interface Customer {
168
- id: string;
169
- projectId: string;
170
- email: string;
171
- name?: string;
172
- stripeCustomerId?: string;
173
- balanceCents: number;
174
- metadata?: string;
175
- taxExempt: boolean;
176
- taxId?: string;
177
- createdAt: string;
178
- updatedAt: string;
179
- }
180
-
181
- declare interface Dashboard {
182
- id: string;
183
- projectId: string;
184
- name: string;
185
- layoutJson: string;
186
- isPublic: boolean;
187
- refreshIntervalSeconds: number;
188
- createdAt: string;
189
- updatedAt: string;
190
- }
191
-
192
- export declare function DashboardView({ dashboardId, embedToken, baseUrl, refreshInterval, appearance: localAppearance }: DashboardViewProps): JSX_2.Element;
193
-
194
- export declare interface DashboardViewProps {
195
- dashboardId: string;
196
- embedToken?: string;
197
- baseUrl?: string;
198
- refreshInterval?: number;
199
- appearance?: Appearance;
200
- }
201
-
202
- export declare function DataTable({ columns, rows, sortable, maxRows, appearance: localAppearance }: DataTableProps): JSX_2.Element;
203
-
204
- export declare interface DataTableProps {
205
- columns: string[];
206
- rows: Record<string, unknown>[];
207
- sortable?: boolean;
208
- maxRows?: number;
209
- appearance?: Appearance;
210
- }
211
-
212
114
  declare interface ElementOverrides {
213
115
  card?: React.CSSProperties;
214
116
  headerTitle?: React.CSSProperties;
@@ -235,22 +137,6 @@ declare interface ElementOverrides {
235
137
  profileHeader?: React.CSSProperties;
236
138
  }
237
139
 
238
- declare interface EmbedToken {
239
- id: string;
240
- projectId: string;
241
- dashboardId?: string;
242
- customerId?: string;
243
- filterRules?: FilterRule[];
244
- expiresAt: string;
245
- createdAt: string;
246
- revokedAt?: string;
247
- }
248
-
249
- declare interface EmbedTokenResult {
250
- embedToken: string;
251
- expiresAt: string;
252
- }
253
-
254
140
  declare class EventEmitter<Events extends Record<string, any>> {
255
141
  private listeners;
256
142
  on<K extends keyof Events>(event: K, listener: Listener<Events[K]>): () => void;
@@ -258,13 +144,6 @@ declare class EventEmitter<Events extends Record<string, any>> {
258
144
  removeAll(): void;
259
145
  }
260
146
 
261
- declare interface FilterRule {
262
- table?: string;
263
- column: string;
264
- op: 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'between';
265
- value: string;
266
- }
267
-
268
147
  export declare interface Invite {
269
148
  inviteId: string;
270
149
  email: string;
@@ -273,40 +152,10 @@ export declare interface Invite {
273
152
  expiresAt: string;
274
153
  }
275
154
 
276
- declare interface Invoice {
277
- id: string;
278
- projectId: string;
279
- customerId: string;
280
- subscriptionId?: string;
281
- amountCents: number;
282
- status: 'draft' | 'open' | 'paid' | 'void' | 'uncollectible';
283
- stripeInvoiceId?: string;
284
- pdfUrl?: string;
285
- dueDate?: string;
286
- paidAt?: string;
287
- createdAt: string;
288
- }
289
-
290
- export declare function InvoiceHistory({ customerId, portalToken, appearance: localAppearance }: InvoiceHistoryProps): JSX_2.Element;
291
-
292
- export declare interface InvoiceHistoryProps {
293
- customerId: string;
294
- portalToken?: string;
295
- appearance?: Appearance;
296
- }
297
-
298
155
  export declare function isMfaRequired(result: AuthResult): result is MfaRequiredResult;
299
156
 
300
157
  declare type Listener<T> = (data: T) => void;
301
158
 
302
- declare interface ListParams {
303
- page?: number;
304
- perPage?: number;
305
- sort?: string;
306
- order?: string;
307
- search?: string;
308
- }
309
-
310
159
  export declare interface Member {
311
160
  userId: string;
312
161
  email: string;
@@ -327,18 +176,17 @@ declare interface MfaVerifyResult {
327
176
  backupCodes: string[];
328
177
  }
329
178
 
330
- export declare type OAuthProvider = 'google' | 'github';
331
-
332
- declare interface OffsetPage<T> {
333
- data: T[];
334
- meta: {
335
- page: number;
336
- perPage: number;
337
- total: number;
338
- totalPages: number;
339
- };
179
+ export declare interface MyPendingInvite {
180
+ id: string;
181
+ orgId: string;
182
+ orgName: string;
183
+ role: string;
184
+ expiresAt: string;
185
+ createdAt: string;
340
186
  }
341
187
 
188
+ export declare type OAuthProvider = 'google' | 'github';
189
+
342
190
  export declare interface Org {
343
191
  id: string;
344
192
  projectId: string;
@@ -349,24 +197,6 @@ export declare interface Org {
349
197
  planName?: string;
350
198
  }
351
199
 
352
- export declare function OrgSwitcher({ appearance: localAppearance, onOrgChange }: OrgSwitcherProps): JSX_2.Element | null;
353
-
354
- export declare interface OrgSwitcherProps {
355
- appearance?: Appearance;
356
- onOrgChange?: (org: Org) => void;
357
- }
358
-
359
- export declare function PaymentPortal({ customerId, portalToken, limits, onChangePlan, onCancel, appearance: localAppearance, }: PaymentPortalProps): JSX_2.Element;
360
-
361
- export declare interface PaymentPortalProps {
362
- customerId: string;
363
- portalToken?: string;
364
- limits?: Record<string, number>;
365
- onChangePlan?: () => void;
366
- onCancel?: () => void;
367
- appearance?: Appearance;
368
- }
369
-
370
200
  export declare interface PendingInvite {
371
201
  id: string;
372
202
  email: string;
@@ -375,34 +205,6 @@ export declare interface PendingInvite {
375
205
  createdAt: string;
376
206
  }
377
207
 
378
- declare interface Plan {
379
- id: string;
380
- name: string;
381
- description?: string;
382
- amountCents: number;
383
- interval: 'month' | 'year';
384
- currency: string;
385
- trialDays: number;
386
- isFree: boolean;
387
- features: string[];
388
- isActive: boolean;
389
- }
390
-
391
- declare interface PortalTokenResult {
392
- portalToken: string;
393
- expiresAt: string;
394
- }
395
-
396
- export declare function PricingTable({ plans, currentPlanId, onSelectPlan, interval, appearance: localAppearance }: PricingTableProps): JSX_2.Element;
397
-
398
- export declare interface PricingTableProps {
399
- plans: Plan[];
400
- currentPlanId?: string;
401
- onSelectPlan: (planId: string) => void;
402
- interval?: 'month' | 'year';
403
- appearance?: Appearance;
404
- }
405
-
406
208
  declare interface ProjectSettings {
407
209
  googleEnabled: boolean;
408
210
  githubEnabled: boolean;
@@ -410,87 +212,8 @@ declare interface ProjectSettings {
410
212
  mfaEnforced: boolean;
411
213
  passwordMinLength: number;
412
214
  emailVerification: boolean;
413
- }
414
-
415
- export declare function QueryInput({ onResult, mode, placeholder, appearance: localAppearance }: QueryInputProps): JSX_2.Element;
416
-
417
- export declare interface QueryInputProps {
418
- onResult?: (result: QueryResult) => void;
419
- mode?: 'nl' | 'sql' | 'both';
420
- placeholder?: string;
421
- appearance?: Appearance;
422
- }
423
-
424
- declare interface QueryParams {
425
- naturalLanguage?: string;
426
- sql?: string;
427
- filterRules?: FilterRule[];
428
- }
429
-
430
- declare interface QueryResult {
431
- sql: string;
432
- columns: string[];
433
- rows: Record<string, unknown>[];
434
- rowCount: number;
435
- executionMs: number;
436
- chartType: string;
437
- cached: boolean;
438
- }
439
-
440
- declare class ReportClient {
441
- private transport;
442
- constructor(transport: Transport);
443
- executeQuery(params: QueryParams): Promise<QueryResult>;
444
- listQueries(params?: ListParams): Promise<OffsetPage<SavedQuery>>;
445
- saveQuery(params: {
446
- name: string;
447
- naturalLanguage?: string;
448
- generatedSql?: string;
449
- chartType?: string;
450
- }): Promise<SavedQuery>;
451
- updateQuery(queryId: string, params: {
452
- name?: string;
453
- chartType?: string;
454
- }): Promise<SavedQuery>;
455
- deleteQuery(queryId: string): Promise<void>;
456
- listDashboards(params?: ListParams): Promise<OffsetPage<Dashboard>>;
457
- createDashboard(params: {
458
- name: string;
459
- layoutJson?: string;
460
- isPublic?: boolean;
461
- refreshIntervalSeconds?: number;
462
- }): Promise<Dashboard>;
463
- getDashboard(dashboardId: string): Promise<Dashboard>;
464
- updateDashboard(dashboardId: string, params: {
465
- name?: string;
466
- layoutJson?: string;
467
- isPublic?: boolean;
468
- refreshIntervalSeconds?: number;
469
- }): Promise<Dashboard>;
470
- deleteDashboard(dashboardId: string): Promise<void>;
471
- createEmbedToken(params: {
472
- dashboardId?: string;
473
- customerId?: string;
474
- expiresIn?: number;
475
- filterRules?: FilterRule[];
476
- }): Promise<EmbedTokenResult>;
477
- listEmbedTokens(): Promise<EmbedToken[]>;
478
- revokeEmbedToken(tokenId: string): Promise<void>;
479
- private toQueryString;
480
- }
481
-
482
- /**
483
- * Standalone embeddable dashboard viewer.
484
- * Does NOT require SaaSProvider — creates its own transport with embedToken.
485
- */
486
- export declare function ReportEmbed({ embedToken, dashboardId, baseUrl, refreshInterval, appearance }: ReportEmbedProps): JSX_2.Element;
487
-
488
- export declare interface ReportEmbedProps {
489
- embedToken: string;
490
- dashboardId: string;
491
- baseUrl?: string;
492
- refreshInterval?: number;
493
- appearance?: Appearance;
215
+ privacyPolicyUrl?: string;
216
+ termsOfServiceUrl?: string;
494
217
  }
495
218
 
496
219
  export declare const SaaSContext: Context<SaaSContextValue | null>;
@@ -540,8 +263,6 @@ export declare interface SaaSProviderProps {
540
263
 
541
264
  export declare class SaaSSupport {
542
265
  readonly auth: AuthClient;
543
- readonly billing: BillingClient;
544
- readonly report: ReportClient;
545
266
  private tokenManager;
546
267
  private emitter;
547
268
  private loaded;
@@ -553,25 +274,6 @@ export declare class SaaSSupport {
553
274
  destroy(): void;
554
275
  }
555
276
 
556
- declare interface SavedQuery {
557
- id: string;
558
- projectId: string;
559
- name: string;
560
- naturalLanguage?: string;
561
- generatedSql?: string;
562
- chartType: string;
563
- createdAt: string;
564
- updatedAt: string;
565
- }
566
-
567
- export declare function SavedQueryList({ onSelectQuery, onRunQuery, appearance: localAppearance }: SavedQueryListProps): JSX_2.Element;
568
-
569
- export declare interface SavedQueryListProps {
570
- onSelectQuery?: (query: SavedQuery) => void;
571
- onRunQuery?: (result: QueryResult) => void;
572
- appearance?: Appearance;
573
- }
574
-
575
277
  export declare function SettingsPanel({ onClose, afterDeleteAccountUrl, defaultTab, onOrgDeleted, onOrgUpdated }: SettingsPanelProps): JSX_2.Element;
576
278
 
577
279
  export declare interface SettingsPanelProps {
@@ -582,15 +284,15 @@ export declare interface SettingsPanelProps {
582
284
  onOrgUpdated?: () => void;
583
285
  }
584
286
 
585
- declare type SettingsTab = 'profile' | 'organization' | 'people' | 'billing';
287
+ declare type SettingsTab = 'profile' | 'organization' | 'people' | 'invites' | 'billing';
586
288
 
587
- 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;
588
290
 
589
291
  export declare interface SignInProps {
590
292
  appearance?: Appearance;
591
- signUpUrl?: string;
592
293
  afterSignInUrl?: string;
593
- onSignUp?: () => void;
294
+ afterSignUpUrl?: string;
295
+ initialMode?: 'signIn' | 'signUp';
594
296
  }
595
297
 
596
298
  export declare interface SignInResult {
@@ -599,46 +301,12 @@ export declare interface SignInResult {
599
301
  refreshToken: string;
600
302
  }
601
303
 
602
- export declare function SignUp({ appearance: localAppearance, signInUrl, onSignIn }: SignUpProps): JSX_2.Element;
603
-
604
- export declare interface SignUpProps {
605
- appearance?: Appearance;
606
- signInUrl?: string;
607
- afterSignUpUrl?: string;
608
- onSignIn?: () => void;
609
- }
610
-
611
304
  export declare interface SignUpResult {
612
305
  user: User;
613
306
  accessToken: string;
614
307
  refreshToken: string;
615
308
  }
616
309
 
617
- declare interface Subscription {
618
- id: string;
619
- customerId: string;
620
- planId: string;
621
- projectId: string;
622
- status: 'trialing' | 'active' | 'past_due' | 'paused' | 'canceled';
623
- stripeSubscriptionId?: string;
624
- cancelAtPeriodEnd: boolean;
625
- trialEnd?: string;
626
- currentPeriodStart: string;
627
- currentPeriodEnd: string;
628
- canceledAt?: string;
629
- createdAt: string;
630
- }
631
-
632
- export declare function SubscriptionStatus({ customerId, portalToken, onChangePlan, onCancel, appearance: localAppearance, }: SubscriptionStatusProps): JSX_2.Element;
633
-
634
- export declare interface SubscriptionStatusProps {
635
- customerId: string;
636
- portalToken?: string;
637
- onChangePlan?: () => void;
638
- onCancel?: () => void;
639
- appearance?: Appearance;
640
- }
641
-
642
310
  export declare interface ThemeVariables {
643
311
  colorPrimary?: string;
644
312
  colorBackground?: string;
@@ -709,20 +377,6 @@ declare class Transport {
709
377
  private inferDomain;
710
378
  }
711
379
 
712
- export declare function UsageDisplay({ customerId, limits, portalToken, appearance: localAppearance }: UsageDisplayProps): JSX_2.Element;
713
-
714
- export declare interface UsageDisplayProps {
715
- customerId: string;
716
- limits?: Record<string, number>;
717
- portalToken?: string;
718
- appearance?: Appearance;
719
- }
720
-
721
- declare interface UsageSummary {
722
- metric: string;
723
- total: number;
724
- }
725
-
726
380
  export declare function useAuth(): {
727
381
  isLoaded: boolean;
728
382
  isSignedIn: boolean;
@@ -732,17 +386,6 @@ export declare function useAuth(): {
732
386
  refreshUser: () => Promise<User | null>;
733
387
  };
734
388
 
735
- export declare function useBilling(): {
736
- billing: BillingClient;
737
- };
738
-
739
- export declare function useDashboard(dashboardId: string): {
740
- dashboard: Dashboard | null;
741
- isLoading: boolean;
742
- error: string | null;
743
- refresh: () => Promise<void>;
744
- };
745
-
746
389
  export declare function useDeleteAccount(): {
747
390
  deleteAccount: () => Promise<boolean>;
748
391
  isLoading: boolean;
@@ -750,19 +393,17 @@ export declare function useDeleteAccount(): {
750
393
  setError: Dispatch<SetStateAction<string | null>>;
751
394
  };
752
395
 
753
- export declare function useEmbedDashboard(embedToken: string, dashboardId: string, baseUrl?: string): {
754
- dashboard: Dashboard | null;
755
- reportClient: ReportClient;
756
- isLoading: boolean;
757
- error: string | null;
758
- refresh: () => Promise<void>;
759
- };
760
-
761
- export declare function useInvoices(customerId: string, portalToken?: string): {
762
- invoices: Invoice[];
396
+ export declare function useInvites(): {
397
+ invites: MyPendingInvite[];
763
398
  isLoading: boolean;
764
399
  error: string | null;
400
+ setError: Dispatch<SetStateAction<string | null>>;
765
401
  refresh: () => Promise<void>;
402
+ accept: (inviteId: string) => Promise<{
403
+ orgId: string;
404
+ role: string;
405
+ } | null>;
406
+ decline: (inviteId: string) => Promise<boolean>;
766
407
  };
767
408
 
768
409
  export declare function useOrg(): {
@@ -787,6 +428,12 @@ export declare function useOrg(): {
787
428
  updateMemberRole: (orgId: string, userId: string, role: string) => Promise<boolean>;
788
429
  removeMember: (orgId: string, userId: string) => Promise<boolean>;
789
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>;
790
437
  };
791
438
 
792
439
  export declare function useProfile(): {
@@ -810,13 +457,6 @@ export declare function useProfile(): {
810
457
  setSuccess: Dispatch<SetStateAction<string | null>>;
811
458
  };
812
459
 
813
- export declare function useQuery(): {
814
- result: QueryResult | null;
815
- execute: (params: QueryParams) => Promise<QueryResult | null>;
816
- isLoading: boolean;
817
- error: string | null;
818
- };
819
-
820
460
  export declare interface User {
821
461
  id: string;
822
462
  email: string;
@@ -839,31 +479,8 @@ export declare interface UserButtonProps {
839
479
  onOrgSettingsClick?: (org: Org) => void;
840
480
  }
841
481
 
842
- export declare function useReport(): {
843
- report: ReportClient;
844
- };
845
-
846
- export declare function UserProfile({ appearance: localAppearance }: UserProfileProps): JSX_2.Element | null;
847
-
848
- export declare interface UserProfileProps {
849
- appearance?: Appearance;
850
- }
851
-
852
482
  export declare function useSaaSContext(): SaaSContextValue;
853
483
 
854
- export declare function useSavedQueries(params?: ListParams): {
855
- queries: SavedQuery[];
856
- meta: {
857
- page: number;
858
- perPage: number;
859
- total: number;
860
- totalPages: number;
861
- } | undefined;
862
- isLoading: boolean;
863
- error: string | null;
864
- refresh: () => Promise<void>;
865
- };
866
-
867
484
  export declare function useSignIn(): {
868
485
  signIn: (email: string, password: string) => Promise<AuthResult | null>;
869
486
  signInWithOAuth: (provider: OAuthProvider) => Promise<SignInResult | null>;
@@ -880,20 +497,6 @@ export declare function useSignUp(): {
880
497
  setError: Dispatch<SetStateAction<string | null>>;
881
498
  };
882
499
 
883
- export declare function useSubscription(customerId: string, portalToken?: string): {
884
- customer: Customer | null;
885
- isLoading: boolean;
886
- error: string | null;
887
- refresh: () => Promise<void>;
888
- };
889
-
890
- export declare function useUsage(customerId: string, portalToken?: string): {
891
- usage: UsageSummary[];
892
- isLoading: boolean;
893
- error: string | null;
894
- refresh: () => Promise<void>;
895
- };
896
-
897
500
  export declare function useUser(): {
898
501
  user: User | null;
899
502
  isLoaded: boolean;