@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.
@@ -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,6 @@
1
+ import React from 'react';
2
+ import { IWorkspace } from '../types';
3
+ declare const WorkspaceSettingsSubscription: React.FC<{
4
+ workspace: IWorkspace;
5
+ }>;
6
+ export default WorkspaceSettingsSubscription;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buildbase/sdk",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "description": "A SDK for Buildbase",
6
6
  "main": "dist/index.js",