@buildbase/sdk 0.0.9 → 0.0.10
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/index.d.ts +179 -2
- package/dist/index.esm.js +4 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/saas-os.css +1 -1
- package/dist/types/api/types.d.ts +128 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/providers/workspace/api.d.ts +22 -1
- package/dist/types/providers/workspace/subscription-hooks.d.ts +49 -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
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,134 @@ interface IUser extends IDocument {
|
|
|
21
21
|
currency: string;
|
|
22
22
|
attributes?: Record<string, string | number | boolean>;
|
|
23
23
|
}
|
|
24
|
+
interface ISubscription {
|
|
25
|
+
_id: string;
|
|
26
|
+
subscriptionStatus: 'active' | 'trialing' | 'canceled' | 'past_due';
|
|
27
|
+
cancelAtPeriodEnd: boolean;
|
|
28
|
+
createdAt: string;
|
|
29
|
+
updatedAt: string;
|
|
30
|
+
}
|
|
31
|
+
interface ISubscriptionItem {
|
|
32
|
+
_id: string;
|
|
33
|
+
type: 'feature' | 'limit' | 'quota';
|
|
34
|
+
name: string;
|
|
35
|
+
slug: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
category: string;
|
|
38
|
+
}
|
|
39
|
+
interface IQuotaValue {
|
|
40
|
+
included: number;
|
|
41
|
+
overage: number;
|
|
42
|
+
}
|
|
43
|
+
interface IPlanVersion {
|
|
44
|
+
_id: string;
|
|
45
|
+
version: number;
|
|
46
|
+
name: string;
|
|
47
|
+
status: 'draft' | 'published';
|
|
48
|
+
features?: Record<string, boolean>;
|
|
49
|
+
limits?: Record<string, number>;
|
|
50
|
+
quotas?: Record<string, number | IQuotaValue>;
|
|
51
|
+
stripePrices?: {
|
|
52
|
+
monthly?: string;
|
|
53
|
+
yearly?: string;
|
|
54
|
+
};
|
|
55
|
+
subscriptionItems?: ISubscriptionItem[];
|
|
56
|
+
isCurrent?: boolean;
|
|
57
|
+
isLegacy?: boolean;
|
|
58
|
+
archived?: boolean;
|
|
59
|
+
deleted?: boolean;
|
|
60
|
+
createdAt?: string;
|
|
61
|
+
updatedAt?: string;
|
|
62
|
+
id?: string;
|
|
63
|
+
}
|
|
64
|
+
interface IPlan {
|
|
65
|
+
_id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
slug: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
latestVersion?: IPlanVersion;
|
|
70
|
+
archived?: boolean;
|
|
71
|
+
deleted?: boolean;
|
|
72
|
+
createdAt?: string;
|
|
73
|
+
updatedAt?: string;
|
|
74
|
+
id?: string;
|
|
75
|
+
}
|
|
76
|
+
interface IPlanGroupLatestVersion {
|
|
77
|
+
_id: string;
|
|
78
|
+
version: number;
|
|
79
|
+
planVersionIds: string[];
|
|
80
|
+
requiredItems: string[];
|
|
81
|
+
status: 'draft' | 'published';
|
|
82
|
+
isCurrent?: boolean;
|
|
83
|
+
isLegacy?: boolean;
|
|
84
|
+
archived?: boolean;
|
|
85
|
+
deleted?: boolean;
|
|
86
|
+
createdAt?: string;
|
|
87
|
+
updatedAt?: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
}
|
|
90
|
+
interface IPlanGroup {
|
|
91
|
+
_id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
slug: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
latestVersion?: IPlanGroupLatestVersion;
|
|
96
|
+
archived?: boolean;
|
|
97
|
+
deleted?: boolean;
|
|
98
|
+
createdAt?: string;
|
|
99
|
+
updatedAt?: string;
|
|
100
|
+
id?: string;
|
|
101
|
+
}
|
|
102
|
+
interface IPlanGroupVersion {
|
|
103
|
+
_id: string;
|
|
104
|
+
version: number;
|
|
105
|
+
description?: string;
|
|
106
|
+
group?: {
|
|
107
|
+
_id: string;
|
|
108
|
+
name: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
};
|
|
111
|
+
planVersionIds: IPlanVersionWithPlan[] | string[];
|
|
112
|
+
requiredItems?: string[];
|
|
113
|
+
status?: 'draft' | 'published';
|
|
114
|
+
isCurrent?: boolean;
|
|
115
|
+
isLegacy?: boolean;
|
|
116
|
+
archived?: boolean;
|
|
117
|
+
deleted?: boolean;
|
|
118
|
+
createdAt?: string;
|
|
119
|
+
updatedAt?: string;
|
|
120
|
+
id?: string;
|
|
121
|
+
}
|
|
122
|
+
interface ISubscriptionResponse {
|
|
123
|
+
subscription: ISubscription | null;
|
|
124
|
+
planVersion: IPlanVersion | null;
|
|
125
|
+
plan: IPlan | null;
|
|
126
|
+
group: IPlanGroup | null;
|
|
127
|
+
groupVersion: IPlanGroupVersion | null;
|
|
128
|
+
}
|
|
129
|
+
interface IPlanVersionWithPlan extends IPlanVersion {
|
|
130
|
+
plan: IPlan;
|
|
131
|
+
}
|
|
132
|
+
interface IPlanGroupResponse {
|
|
133
|
+
group: IPlanGroup;
|
|
134
|
+
groupVersion: IPlanGroupVersion;
|
|
135
|
+
plans: IPlanVersionWithPlan[];
|
|
136
|
+
}
|
|
137
|
+
interface ISubscriptionUpdateRequest {
|
|
138
|
+
planVersionId: string;
|
|
139
|
+
}
|
|
140
|
+
interface ISubscriptionUpdateResponse {
|
|
141
|
+
_id: string;
|
|
142
|
+
subscriptionStatus: string;
|
|
143
|
+
workspace: string;
|
|
144
|
+
planVersion: string;
|
|
145
|
+
plan: string;
|
|
146
|
+
planGroup?: string;
|
|
147
|
+
planGroupVersion?: string;
|
|
148
|
+
cancelAtPeriodEnd: boolean;
|
|
149
|
+
createdAt: string;
|
|
150
|
+
updatedAt: string;
|
|
151
|
+
}
|
|
24
152
|
|
|
25
153
|
interface IWorkspace {
|
|
26
154
|
_id: string;
|
|
@@ -309,6 +437,55 @@ declare const useSaaSWorkspaces: () => {
|
|
|
309
437
|
}>;
|
|
310
438
|
};
|
|
311
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Hook to get and manage the current subscription for a workspace
|
|
442
|
+
* @param workspaceId - The workspace ID to get subscription for
|
|
443
|
+
* @returns Subscription data and loading/error states
|
|
444
|
+
*/
|
|
445
|
+
declare const useSubscription: (workspaceId: string | null | undefined) => {
|
|
446
|
+
subscription: ISubscriptionResponse | null;
|
|
447
|
+
loading: boolean;
|
|
448
|
+
error: string | null;
|
|
449
|
+
refetch: () => Promise<void>;
|
|
450
|
+
};
|
|
451
|
+
/**
|
|
452
|
+
* Hook to get the plan group for a workspace
|
|
453
|
+
* Returns the plan group containing the current plan if subscription exists,
|
|
454
|
+
* otherwise returns the latest published group
|
|
455
|
+
* @param workspaceId - The workspace ID to get plan group for
|
|
456
|
+
* @returns Plan group data and loading/error states
|
|
457
|
+
*/
|
|
458
|
+
declare const usePlanGroup: (workspaceId: string | null | undefined) => {
|
|
459
|
+
planGroup: IPlanGroupResponse | null;
|
|
460
|
+
loading: boolean;
|
|
461
|
+
error: string | null;
|
|
462
|
+
refetch: () => Promise<void>;
|
|
463
|
+
};
|
|
464
|
+
/**
|
|
465
|
+
* Hook to update subscription (upgrade/downgrade)
|
|
466
|
+
* @param workspaceId - The workspace ID to update subscription for
|
|
467
|
+
* @returns Update function and loading/error states
|
|
468
|
+
*/
|
|
469
|
+
declare const useUpdateSubscription: (workspaceId: string | null | undefined) => {
|
|
470
|
+
updateSubscription: (planVersionId: string) => Promise<ISubscriptionUpdateResponse>;
|
|
471
|
+
loading: boolean;
|
|
472
|
+
error: string | null;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Combined hook that provides both subscription and plan group data
|
|
476
|
+
* Useful for subscription management pages
|
|
477
|
+
* @param workspaceId - The workspace ID
|
|
478
|
+
* @returns Combined subscription and plan group data with loading/error states
|
|
479
|
+
*/
|
|
480
|
+
declare const useSubscriptionManagement: (workspaceId: string | null | undefined) => {
|
|
481
|
+
subscription: ISubscriptionResponse | null;
|
|
482
|
+
planGroup: IPlanGroupResponse | null;
|
|
483
|
+
loading: boolean;
|
|
484
|
+
error: string | null;
|
|
485
|
+
updateSubscription: (planVersionId: string) => Promise<ISubscriptionUpdateResponse>;
|
|
486
|
+
refetch: () => Promise<void>;
|
|
487
|
+
};
|
|
488
|
+
|
|
312
489
|
/**
|
|
313
490
|
* EventEmitter class to handle and trigger event callbacks
|
|
314
491
|
* This class manages all event listeners and provides methods to trigger events
|
|
@@ -481,5 +658,5 @@ declare const errorHandler: ErrorHandler;
|
|
|
481
658
|
declare function handleError(error: Error | unknown, context?: SDKErrorContext): void;
|
|
482
659
|
declare function createSDKError(message: string, code?: string, context?: SDKErrorContext, originalError?: Error): SDKError;
|
|
483
660
|
|
|
484
|
-
export { ApiVersion, BetaForm, SDKErrorBoundary as ErrorBoundary, SDKError, SDKErrorBoundary, SaaSOSProvider, WhenAuthenticated, WhenRoles, WhenUnauthenticated, WhenUserFeatureDisabled, WhenUserFeatureEnabled, WhenWorkspaceFeatureDisabled, WhenWorkspaceFeatureEnabled, WhenWorkspaceRoles, WorkspaceSwitcher, createSDKError, errorHandler, eventEmitter, handleError, useSaaSAuth, useSaaSSettings, useSaaSWorkspaces, useUserAttributes, useUserFeatures };
|
|
485
|
-
export type { ErrorHandlerConfig, EventData, EventType, IEventCallbacks, SDKErrorContext, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|
|
661
|
+
export { ApiVersion, BetaForm, SDKErrorBoundary as ErrorBoundary, SDKError, SDKErrorBoundary, SaaSOSProvider, WhenAuthenticated, WhenRoles, WhenUnauthenticated, WhenUserFeatureDisabled, WhenUserFeatureEnabled, WhenWorkspaceFeatureDisabled, WhenWorkspaceFeatureEnabled, WhenWorkspaceRoles, WorkspaceSwitcher, createSDKError, errorHandler, eventEmitter, handleError, usePlanGroup, useSaaSAuth, useSaaSSettings, useSaaSWorkspaces, useSubscription, useSubscriptionManagement, useUpdateSubscription, useUserAttributes, useUserFeatures };
|
|
662
|
+
export type { ErrorHandlerConfig, EventData, EventType, IEventCallbacks, IPlan, IPlanGroup, IPlanGroupLatestVersion, IPlanGroupResponse, IPlanGroupVersion, IPlanVersion, IPlanVersionWithPlan, IQuotaValue, ISubscription, ISubscriptionItem, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, SDKErrorContext, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData };
|