@buildbase/sdk 0.0.9 → 0.0.11
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 +2 -1
- package/dist/index.d.ts +323 -8
- package/dist/index.esm.js +6 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/saas-os.css +1 -1
- package/dist/types/api/types.d.ts +207 -0
- package/dist/types/contexts/AuthContext/actions.d.ts +1 -0
- package/dist/types/contexts/AuthContext/reducer.d.ts +9 -3
- package/dist/types/contexts/AuthContext/types.d.ts +2 -0
- package/dist/types/contexts/shared/useAppSelector.d.ts +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/providers/auth/hooks.d.ts +6 -6
- package/dist/types/providers/auth/types.d.ts +7 -3
- package/dist/types/providers/workspace/api.d.ts +62 -1
- package/dist/types/providers/workspace/subscription-hooks.d.ts +107 -0
- package/dist/types/providers/workspace/ui/SettingsDialog.d.ts +1 -1
- package/dist/types/providers/workspace/ui/SettingsSubscription.d.ts +6 -0
- package/dist/types/providers/workspace/ui/SubscriptionDialog.d.ts +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { BillingInterval, ICheckoutSessionRequest, ICheckoutSessionResponse, IInvoice, IPlanGroupResponse, IPlanGroupVersionsResponse, ISubscriptionResponse, ISubscriptionUpdateResponse } from '../../api/types';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to get and manage the current subscription for a workspace
|
|
4
|
+
* @param workspaceId - The workspace ID to get subscription for
|
|
5
|
+
* @returns Subscription data and loading/error states
|
|
6
|
+
*/
|
|
7
|
+
export declare const useSubscription: (workspaceId: string | null | undefined) => {
|
|
8
|
+
subscription: ISubscriptionResponse | null;
|
|
9
|
+
loading: boolean;
|
|
10
|
+
error: string | null;
|
|
11
|
+
refetch: () => Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Hook to get the plan group for a workspace
|
|
15
|
+
* Returns the plan group containing the current plan if subscription exists,
|
|
16
|
+
* otherwise returns the latest published group
|
|
17
|
+
* @param workspaceId - The workspace ID to get plan group for
|
|
18
|
+
* @param groupVersionId - Optional: specific group version ID to fetch
|
|
19
|
+
* @returns Plan group data and loading/error states
|
|
20
|
+
*/
|
|
21
|
+
export declare const usePlanGroup: (workspaceId: string | null | undefined, groupVersionId?: string | null) => {
|
|
22
|
+
planGroup: IPlanGroupResponse | null;
|
|
23
|
+
loading: boolean;
|
|
24
|
+
error: string | null;
|
|
25
|
+
refetch: () => Promise<void>;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Hook to get all available versions of a plan group for a workspace
|
|
29
|
+
* @param workspaceId - The workspace ID to get plan group versions for
|
|
30
|
+
* @returns Plan group versions data and loading/error states
|
|
31
|
+
*/
|
|
32
|
+
export declare const usePlanGroupVersions: (workspaceId: string | null | undefined) => {
|
|
33
|
+
versions: IPlanGroupVersionsResponse | null;
|
|
34
|
+
loading: boolean;
|
|
35
|
+
error: string | null;
|
|
36
|
+
refetch: () => Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Hook to create checkout session for new subscription
|
|
40
|
+
* @param workspaceId - The workspace ID to create checkout session for
|
|
41
|
+
* @returns Create checkout function and loading/error states
|
|
42
|
+
*/
|
|
43
|
+
export declare const useCreateCheckoutSession: (workspaceId: string | null | undefined) => {
|
|
44
|
+
createCheckoutSession: (request: ICheckoutSessionRequest) => Promise<ICheckoutSessionResponse>;
|
|
45
|
+
loading: boolean;
|
|
46
|
+
error: string | null;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Hook to update subscription (upgrade/downgrade)
|
|
50
|
+
* Returns checkout session if payment is required, otherwise returns subscription update response
|
|
51
|
+
* @param workspaceId - The workspace ID to update subscription for
|
|
52
|
+
* @returns Update function and loading/error states
|
|
53
|
+
*/
|
|
54
|
+
export declare const useUpdateSubscription: (workspaceId: string | null | undefined) => {
|
|
55
|
+
updateSubscription: (planVersionId: string, options?: {
|
|
56
|
+
billingInterval?: BillingInterval;
|
|
57
|
+
successUrl?: string;
|
|
58
|
+
cancelUrl?: string;
|
|
59
|
+
}) => Promise<ISubscriptionUpdateResponse | ICheckoutSessionResponse>;
|
|
60
|
+
loading: boolean;
|
|
61
|
+
error: string | null;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Combined hook that provides both subscription and plan group data
|
|
65
|
+
* Useful for subscription management pages
|
|
66
|
+
* @param workspaceId - The workspace ID
|
|
67
|
+
* @param groupVersionId - Optional: specific group version ID to fetch
|
|
68
|
+
* @returns Combined subscription and plan group data with loading/error states
|
|
69
|
+
*/
|
|
70
|
+
export declare const useSubscriptionManagement: (workspaceId: string | null | undefined, groupVersionId?: string | null) => {
|
|
71
|
+
subscription: ISubscriptionResponse | null;
|
|
72
|
+
planGroup: IPlanGroupResponse | null;
|
|
73
|
+
loading: boolean;
|
|
74
|
+
error: string | null;
|
|
75
|
+
updateSubscription: (planVersionId: string, options?: {
|
|
76
|
+
billingInterval?: BillingInterval;
|
|
77
|
+
successUrl?: string;
|
|
78
|
+
cancelUrl?: string;
|
|
79
|
+
}) => Promise<ISubscriptionUpdateResponse | ICheckoutSessionResponse>;
|
|
80
|
+
refetch: () => Promise<void>;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Hook to list invoices for a workspace subscription
|
|
84
|
+
* @param workspaceId - The workspace ID to get invoices for
|
|
85
|
+
* @param limit - Number of invoices to return (default: 10)
|
|
86
|
+
* @param startingAfter - Invoice ID to start after (for pagination)
|
|
87
|
+
* @returns Invoice list data and loading/error states
|
|
88
|
+
*/
|
|
89
|
+
export declare const useInvoices: (workspaceId: string | null | undefined, limit?: number, startingAfter?: string) => {
|
|
90
|
+
invoices: IInvoice[];
|
|
91
|
+
hasMore: boolean;
|
|
92
|
+
loading: boolean;
|
|
93
|
+
error: string | null;
|
|
94
|
+
refetch: () => Promise<void>;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Hook to get a single invoice by ID
|
|
98
|
+
* @param workspaceId - The workspace ID
|
|
99
|
+
* @param invoiceId - The invoice ID to fetch
|
|
100
|
+
* @returns Invoice data and loading/error states
|
|
101
|
+
*/
|
|
102
|
+
export declare const useInvoice: (workspaceId: string | null | undefined, invoiceId: string | null | undefined) => {
|
|
103
|
+
invoice: IInvoice | null;
|
|
104
|
+
loading: boolean;
|
|
105
|
+
error: string | null;
|
|
106
|
+
refetch: () => Promise<void>;
|
|
107
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IWorkspace } from '../types';
|
|
3
|
-
export type WorkspaceSettingsSection = 'profile' | 'general' | 'users' | 'features' | 'danger';
|
|
3
|
+
export type WorkspaceSettingsSection = 'profile' | 'general' | 'users' | 'subscription' | 'features' | 'danger';
|
|
4
4
|
export interface WorkspaceSettingsDialogProps {
|
|
5
5
|
workspace: IWorkspace;
|
|
6
6
|
onClose?: () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IPlanVersionWithPlan } from '../../../api/types';
|
|
3
|
+
interface SubscriptionDialogProps {
|
|
4
|
+
open: boolean;
|
|
5
|
+
onOpenChange: (open: boolean) => void;
|
|
6
|
+
planVersions: IPlanVersionWithPlan[];
|
|
7
|
+
currentPlanVersionId?: string | null;
|
|
8
|
+
onSelectPlan: (planVersionId: string) => Promise<void>;
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const SubscriptionDialog: React.FC<SubscriptionDialogProps>;
|
|
12
|
+
export default SubscriptionDialog;
|