@buildbase/sdk 0.0.23 → 0.0.25
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.esm.js +4 -5
- package/dist/index.js +4 -5
- package/dist/saas-os.css +1 -1
- package/package.json +3 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types/api/currency-utils.d.ts +0 -44
- package/dist/types/api/index.d.ts +0 -12
- package/dist/types/api/pricing-variant-utils.d.ts +0 -66
- package/dist/types/api/quota-utils.d.ts +0 -24
- package/dist/types/api/types.d.ts +0 -495
- package/dist/types/components/ErrorBoundary.d.ts +0 -81
- package/dist/types/components/beta/BetaForm.d.ts +0 -24
- package/dist/types/components/beta/api.d.ts +0 -48
- package/dist/types/components/beta/hooks.d.ts +0 -11
- package/dist/types/components/beta/schema.d.ts +0 -6
- package/dist/types/components/beta/types.d.ts +0 -8
- package/dist/types/components/dropdowns/country/countries.d.ts +0 -7
- package/dist/types/components/dropdowns/country/selectCountry.d.ts +0 -6
- package/dist/types/components/dropdowns/currency/currencies.d.ts +0 -6
- package/dist/types/components/dropdowns/currency/selectCurrency.d.ts +0 -6
- package/dist/types/components/dropdowns/language/languages.d.ts +0 -6
- package/dist/types/components/dropdowns/language/selectLanguage.d.ts +0 -6
- package/dist/types/components/dropdowns/timezone/selectTimeZone.d.ts +0 -6
- package/dist/types/components/dropdowns/timezone/timezones.d.ts +0 -8
- package/dist/types/components/features/index.d.ts +0 -130
- package/dist/types/components/pricing/PricingPage.d.ts +0 -49
- package/dist/types/components/pricing/index.d.ts +0 -2
- package/dist/types/components/quota/index.d.ts +0 -121
- package/dist/types/components/subscription/index.d.ts +0 -182
- package/dist/types/components/ui/alert-dialog.d.ts +0 -20
- package/dist/types/components/ui/avatar.d.ts +0 -6
- package/dist/types/components/ui/button.d.ts +0 -18
- package/dist/types/components/ui/command-select.d.ts +0 -13
- package/dist/types/components/ui/command.d.ts +0 -82
- package/dist/types/components/ui/dialog.d.ts +0 -19
- package/dist/types/components/ui/form.d.ts +0 -23
- package/dist/types/components/ui/input.d.ts +0 -5
- package/dist/types/components/ui/label.d.ts +0 -5
- package/dist/types/components/ui/popover.d.ts +0 -6
- package/dist/types/components/ui/radio-group.d.ts +0 -5
- package/dist/types/components/ui/scroll-area.d.ts +0 -5
- package/dist/types/components/ui/select.d.ts +0 -11
- package/dist/types/components/ui/separator.d.ts +0 -4
- package/dist/types/components/ui/skeleton.d.ts +0 -3
- package/dist/types/components/ui/switch.d.ts +0 -4
- package/dist/types/components/user/auth.d.ts +0 -76
- package/dist/types/components/user/role.d.ts +0 -84
- package/dist/types/contexts/AuthContext/AuthContext.d.ts +0 -9
- package/dist/types/contexts/AuthContext/actions.d.ts +0 -12
- package/dist/types/contexts/AuthContext/index.d.ts +0 -4
- package/dist/types/contexts/AuthContext/reducer.d.ts +0 -19
- package/dist/types/contexts/AuthContext/types.d.ts +0 -18
- package/dist/types/contexts/OSContext/OSContext.d.ts +0 -9
- package/dist/types/contexts/OSContext/actions.d.ts +0 -11
- package/dist/types/contexts/OSContext/index.d.ts +0 -4
- package/dist/types/contexts/OSContext/reducer.d.ts +0 -11
- package/dist/types/contexts/OSContext/types.d.ts +0 -16
- package/dist/types/contexts/QuotaUsageContext/QuotaUsageContext.d.ts +0 -22
- package/dist/types/contexts/QuotaUsageContext/index.d.ts +0 -2
- package/dist/types/contexts/QuotaUsageContext/quotaUsageInvalidation.d.ts +0 -21
- package/dist/types/contexts/QuotaUsageContext/types.d.ts +0 -14
- package/dist/types/contexts/SDKContext/SDKContextProvider.d.ts +0 -18
- package/dist/types/contexts/SDKContext/index.d.ts +0 -2
- package/dist/types/contexts/SDKContext/types.d.ts +0 -12
- package/dist/types/contexts/SubscriptionContext/SubscriptionContext.d.ts +0 -22
- package/dist/types/contexts/SubscriptionContext/index.d.ts +0 -2
- package/dist/types/contexts/SubscriptionContext/subscriptionInvalidation.d.ts +0 -21
- package/dist/types/contexts/SubscriptionContext/types.d.ts +0 -14
- package/dist/types/contexts/WorkspaceContext/WorkspaceContext.d.ts +0 -8
- package/dist/types/contexts/WorkspaceContext/actions.d.ts +0 -19
- package/dist/types/contexts/WorkspaceContext/index.d.ts +0 -4
- package/dist/types/contexts/WorkspaceContext/reducer.d.ts +0 -10
- package/dist/types/contexts/WorkspaceContext/types.d.ts +0 -52
- package/dist/types/contexts/index.d.ts +0 -14
- package/dist/types/contexts/shared/createContext.d.ts +0 -27
- package/dist/types/contexts/shared/types.d.ts +0 -21
- package/dist/types/contexts/shared/useAppDispatch.d.ts +0 -20
- package/dist/types/contexts/shared/useAppSelector.d.ts +0 -26
- package/dist/types/contexts/shared/useSelectWithEquality.d.ts +0 -10
- package/dist/types/contexts/shared/utils/reducerHelpers.d.ts +0 -11
- package/dist/types/contexts/shared/utils/storage.d.ts +0 -25
- package/dist/types/hooks/use-seat-status.d.ts +0 -42
- package/dist/types/hooks/use-trial-status.d.ts +0 -28
- package/dist/types/index.d.ts +0 -39
- package/dist/types/lib/api-base.d.ts +0 -49
- package/dist/types/lib/api-client.d.ts +0 -25
- package/dist/types/lib/api-utils.d.ts +0 -182
- package/dist/types/lib/error-handler.d.ts +0 -118
- package/dist/types/lib/logger.d.ts +0 -27
- package/dist/types/lib/useAsyncEffect.d.ts +0 -29
- package/dist/types/lib/utils.d.ts +0 -7
- package/dist/types/providers/ContextConfigProvider.d.ts +0 -15
- package/dist/types/providers/PortalContainer.d.ts +0 -9
- package/dist/types/providers/SaaSOSProvider.d.ts +0 -7
- package/dist/types/providers/auth/api.d.ts +0 -12
- package/dist/types/providers/auth/hooks.d.ts +0 -75
- package/dist/types/providers/auth/provider.d.ts +0 -13
- package/dist/types/providers/auth/types.d.ts +0 -62
- package/dist/types/providers/auth/utils.d.ts +0 -40
- package/dist/types/providers/constants.d.ts +0 -3
- package/dist/types/providers/events/EventEmitter.d.ts +0 -81
- package/dist/types/providers/events/index.d.ts +0 -2
- package/dist/types/providers/events/types.d.ts +0 -61
- package/dist/types/providers/os/api.d.ts +0 -11
- package/dist/types/providers/os/hooks.d.ts +0 -50
- package/dist/types/providers/os/types.d.ts +0 -19
- package/dist/types/providers/types.d.ts +0 -9
- package/dist/types/providers/user/api.d.ts +0 -16
- package/dist/types/providers/user/hooks.d.ts +0 -80
- package/dist/types/providers/user/provider.d.ts +0 -17
- package/dist/types/providers/workspace/WorkspaceSettingsProvider.d.ts +0 -9
- package/dist/types/providers/workspace/api.d.ts +0 -155
- package/dist/types/providers/workspace/hooks.d.ts +0 -161
- package/dist/types/providers/workspace/provider.d.ts +0 -8
- package/dist/types/providers/workspace/settings-manager.d.ts +0 -36
- package/dist/types/providers/workspace/subscription-hooks.d.ts +0 -741
- package/dist/types/providers/workspace/types.d.ts +0 -61
- package/dist/types/providers/workspace/ui/SettingsDanger.d.ts +0 -6
- package/dist/types/providers/workspace/ui/SettingsDialog.d.ts +0 -17
- package/dist/types/providers/workspace/ui/SettingsFeatures.d.ts +0 -5
- package/dist/types/providers/workspace/ui/SettingsGeneral.d.ts +0 -6
- package/dist/types/providers/workspace/ui/SettingsInvoices.d.ts +0 -12
- package/dist/types/providers/workspace/ui/SettingsProfile.d.ts +0 -6
- package/dist/types/providers/workspace/ui/SettingsSubscription.d.ts +0 -6
- package/dist/types/providers/workspace/ui/SettingsUsage.d.ts +0 -3
- package/dist/types/providers/workspace/ui/SettingsUsers.d.ts +0 -6
- package/dist/types/providers/workspace/ui/Sidebar.d.ts +0 -10
- package/dist/types/providers/workspace/ui/Skeleton.d.ts +0 -1
- package/dist/types/providers/workspace/ui/SubscriptionDialog.d.ts +0 -19
- package/dist/types/providers/workspace/ui/utils.d.ts +0 -2
- package/dist/types/providers/workspace/utils.d.ts +0 -28
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { IUser } from '../../api/types';
|
|
2
|
-
import type { IWorkspace } from '../workspace/types';
|
|
3
|
-
import type { IEventCallbacks } from './types';
|
|
4
|
-
/**
|
|
5
|
-
* EventEmitter class to handle and trigger event callbacks
|
|
6
|
-
* This class manages all event listeners and provides methods to trigger events
|
|
7
|
-
*/
|
|
8
|
-
export declare class EventEmitter {
|
|
9
|
-
private callbacks;
|
|
10
|
-
/**
|
|
11
|
-
* Set the event callbacks
|
|
12
|
-
* @param callbacks - The event callbacks to register
|
|
13
|
-
*/
|
|
14
|
-
setCallbacks(callbacks: IEventCallbacks | null): void;
|
|
15
|
-
/**
|
|
16
|
-
* Get the current event callbacks
|
|
17
|
-
* @returns The current event callbacks or null
|
|
18
|
-
*/
|
|
19
|
-
getCallbacks(): IEventCallbacks | null;
|
|
20
|
-
/**
|
|
21
|
-
* Emit an event
|
|
22
|
-
* @param eventType - The type of event
|
|
23
|
-
* @param data - The event data
|
|
24
|
-
*/
|
|
25
|
-
private emit;
|
|
26
|
-
/**
|
|
27
|
-
* Trigger user created event
|
|
28
|
-
* @param user - The newly created user
|
|
29
|
-
*/
|
|
30
|
-
emitUserCreated(user: IUser): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Trigger user updated event
|
|
33
|
-
* @param user - The updated user
|
|
34
|
-
* @param previousUser - The user data before the update (optional)
|
|
35
|
-
*/
|
|
36
|
-
emitUserUpdated(user: IUser, previousUser?: IUser): Promise<void>;
|
|
37
|
-
/**
|
|
38
|
-
* Trigger workspace changed event
|
|
39
|
-
* @param workspace - The newly selected workspace
|
|
40
|
-
* @param previousWorkspace - The previously selected workspace (optional)
|
|
41
|
-
*/
|
|
42
|
-
emitWorkspaceChanged(workspace: IWorkspace, previousWorkspace?: IWorkspace | null): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Trigger workspace updated event
|
|
45
|
-
* @param workspace - The updated workspace
|
|
46
|
-
*/
|
|
47
|
-
emitWorkspaceUpdated(workspace: IWorkspace): Promise<void>;
|
|
48
|
-
/**
|
|
49
|
-
* Trigger workspace user added event
|
|
50
|
-
* @param userId - The ID of the user that was added
|
|
51
|
-
* @param workspace - The workspace the user was added to
|
|
52
|
-
* @param role - The role assigned to the user
|
|
53
|
-
*/
|
|
54
|
-
emitWorkspaceUserAdded(userId: string, workspace: IWorkspace, role: string): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Trigger workspace user removed event
|
|
57
|
-
* @param userId - The ID of the user that was removed
|
|
58
|
-
* @param workspace - The workspace the user was removed from
|
|
59
|
-
* @param role - The role the user had in the workspace
|
|
60
|
-
*/
|
|
61
|
-
emitWorkspaceUserRemoved(userId: string, workspace: IWorkspace, role: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Trigger workspace user role changed event
|
|
64
|
-
* @param userId - The ID of the user whose role was changed
|
|
65
|
-
* @param workspace - The workspace where the role was changed
|
|
66
|
-
* @param previousRole - The previous role of the user
|
|
67
|
-
* @param newRole - The new role of the user
|
|
68
|
-
*/
|
|
69
|
-
emitWorkspaceUserRoleChanged(userId: string, workspace: IWorkspace, previousRole: string, newRole: string): Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Trigger workspace created event
|
|
72
|
-
* @param workspace - The newly created workspace
|
|
73
|
-
*/
|
|
74
|
-
emitWorkspaceCreated(workspace: IWorkspace): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Trigger workspace deleted event
|
|
77
|
-
* @param workspace - The deleted workspace
|
|
78
|
-
*/
|
|
79
|
-
emitWorkspaceDeleted(workspace: IWorkspace): Promise<void>;
|
|
80
|
-
}
|
|
81
|
-
export declare const eventEmitter: EventEmitter;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { EventEmitter, eventEmitter } from './EventEmitter';
|
|
2
|
-
export type { EventData, EventType, IEventCallbacks, UserCreatedEventData, UserUpdatedEventData, WorkspaceChangedEventData, WorkspaceCreatedEventData, WorkspaceDeletedEventData, WorkspaceUpdatedEventData, WorkspaceUserAddedEventData, WorkspaceUserRemovedEventData, WorkspaceUserRoleChangedEventData, } from './types';
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { IUser } from '../../api/types';
|
|
2
|
-
import type { IWorkspace } from '../workspace/types';
|
|
3
|
-
/**
|
|
4
|
-
* Event types for all SDK events
|
|
5
|
-
*/
|
|
6
|
-
export type EventType = 'user:created' | 'user:updated' | 'workspace:changed' | 'workspace:updated' | 'workspace:user-added' | 'workspace:user-removed' | 'workspace:user-role-changed' | 'workspace:created' | 'workspace:deleted';
|
|
7
|
-
/**
|
|
8
|
-
* Event data types for each event
|
|
9
|
-
*/
|
|
10
|
-
export interface UserCreatedEventData {
|
|
11
|
-
user: IUser;
|
|
12
|
-
}
|
|
13
|
-
export interface UserUpdatedEventData {
|
|
14
|
-
user: IUser;
|
|
15
|
-
previousUser?: IUser;
|
|
16
|
-
}
|
|
17
|
-
export interface WorkspaceChangedEventData {
|
|
18
|
-
workspace: IWorkspace;
|
|
19
|
-
previousWorkspace?: IWorkspace | null;
|
|
20
|
-
}
|
|
21
|
-
export interface WorkspaceUpdatedEventData {
|
|
22
|
-
workspace: IWorkspace;
|
|
23
|
-
}
|
|
24
|
-
export interface WorkspaceUserAddedEventData {
|
|
25
|
-
userId: string;
|
|
26
|
-
workspace: IWorkspace;
|
|
27
|
-
role: string;
|
|
28
|
-
}
|
|
29
|
-
export interface WorkspaceUserRemovedEventData {
|
|
30
|
-
userId: string;
|
|
31
|
-
workspace: IWorkspace;
|
|
32
|
-
role: string;
|
|
33
|
-
}
|
|
34
|
-
export interface WorkspaceUserRoleChangedEventData {
|
|
35
|
-
userId: string;
|
|
36
|
-
workspace: IWorkspace;
|
|
37
|
-
previousRole: string;
|
|
38
|
-
newRole: string;
|
|
39
|
-
}
|
|
40
|
-
export interface WorkspaceCreatedEventData {
|
|
41
|
-
workspace: IWorkspace;
|
|
42
|
-
}
|
|
43
|
-
export interface WorkspaceDeletedEventData {
|
|
44
|
-
workspace: IWorkspace;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Union type for all event data
|
|
48
|
-
*/
|
|
49
|
-
export type EventData = UserCreatedEventData | UserUpdatedEventData | WorkspaceChangedEventData | WorkspaceUpdatedEventData | WorkspaceUserAddedEventData | WorkspaceUserRemovedEventData | WorkspaceUserRoleChangedEventData | WorkspaceCreatedEventData | WorkspaceDeletedEventData;
|
|
50
|
-
/**
|
|
51
|
-
* Single event callback function
|
|
52
|
-
* Handles all events with conditional logic based on event type
|
|
53
|
-
*/
|
|
54
|
-
export interface IEventCallbacks {
|
|
55
|
-
/**
|
|
56
|
-
* Called when any event occurs
|
|
57
|
-
* @param eventType - The type of event that occurred
|
|
58
|
-
* @param data - The event data (type varies based on eventType)
|
|
59
|
-
*/
|
|
60
|
-
handleEvent?: (eventType: EventType, data: EventData) => void | Promise<void>;
|
|
61
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Centralized API client for organization (OS) settings.
|
|
3
|
-
* Extends BaseApi for shared URL/auth/request handling.
|
|
4
|
-
*/
|
|
5
|
-
import { BaseApi } from '../../lib/api-base';
|
|
6
|
-
import type { ISettings } from '../types';
|
|
7
|
-
import type { IOsConfig } from './types';
|
|
8
|
-
export declare class SettingsApi extends BaseApi {
|
|
9
|
-
constructor(config: IOsConfig);
|
|
10
|
-
getSettings(signal?: AbortSignal): Promise<ISettings>;
|
|
11
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { ISettings } from '../types';
|
|
2
|
-
import { type IOsState } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Hook to access OS (organization) state (serverUrl, version, orgId, auth, settings).
|
|
5
|
-
* Prefer useSaaSSettings() when you only need settings.
|
|
6
|
-
*/
|
|
7
|
-
export declare function useSaaSOs(): IOsState;
|
|
8
|
-
/**
|
|
9
|
-
* Hook to access organization settings from the OS context.
|
|
10
|
-
* Automatically fetches settings when OS config is ready.
|
|
11
|
-
*
|
|
12
|
-
* @returns An object containing:
|
|
13
|
-
* - `settings`: Organization settings object (null if not loaded)
|
|
14
|
-
* - `getSettings(signal?)`: Function to manually fetch settings (supports AbortSignal)
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* function SettingsDisplay() {
|
|
19
|
-
* const { settings } = useSaaSSettings();
|
|
20
|
-
*
|
|
21
|
-
* if (!settings) return <Loading />;
|
|
22
|
-
*
|
|
23
|
-
* return (
|
|
24
|
-
* <div>
|
|
25
|
-
* <p>Organization: {settings.name}</p>
|
|
26
|
-
* <p>Theme: {settings.theme}</p>
|
|
27
|
-
* </div>
|
|
28
|
-
* );
|
|
29
|
-
* }
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```tsx
|
|
34
|
-
* // Manual fetch with abort signal
|
|
35
|
-
* function SettingsLoader() {
|
|
36
|
-
* const { getSettings } = useSaaSSettings();
|
|
37
|
-
*
|
|
38
|
-
* useEffect(() => {
|
|
39
|
-
* const controller = new AbortController();
|
|
40
|
-
* getSettings(controller.signal);
|
|
41
|
-
*
|
|
42
|
-
* return () => controller.abort();
|
|
43
|
-
* }, [getSettings]);
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function useSaaSSettings(): {
|
|
48
|
-
settings: ISettings | null | undefined;
|
|
49
|
-
getSettings: (signal?: AbortSignal) => Promise<ISettings | null>;
|
|
50
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { IAuthConfig } from '../auth/types';
|
|
2
|
-
import type { ISettings } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* Supported API versions
|
|
5
|
-
*/
|
|
6
|
-
export declare enum ApiVersion {
|
|
7
|
-
V1 = "v1"
|
|
8
|
-
}
|
|
9
|
-
export interface IOsConfig {
|
|
10
|
-
serverUrl: string;
|
|
11
|
-
version: ApiVersion;
|
|
12
|
-
orgId: string;
|
|
13
|
-
}
|
|
14
|
-
/** True when OS config has serverUrl, version, and orgId (ready for API calls). */
|
|
15
|
-
export declare function isOsConfigReady(config: Pick<IOsConfig, 'serverUrl' | 'version' | 'orgId'> | null | undefined): boolean;
|
|
16
|
-
export interface IOsState extends IOsConfig {
|
|
17
|
-
auth?: IAuthConfig;
|
|
18
|
-
settings?: ISettings | null;
|
|
19
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IUser } from '../../api/types';
|
|
2
|
-
import { BaseApi } from '../../lib/api-base';
|
|
3
|
-
import type { IOsConfig } from '../os/types';
|
|
4
|
-
/**
|
|
5
|
-
* Centralized API client for user attributes and features.
|
|
6
|
-
* Extends BaseApi for shared URL/auth/request handling.
|
|
7
|
-
*/
|
|
8
|
-
export declare class UserApi extends BaseApi {
|
|
9
|
-
constructor(config: Pick<IOsConfig, 'serverUrl' | 'version'>);
|
|
10
|
-
getAttributes(signal?: AbortSignal): Promise<Record<string, string | number | boolean>>;
|
|
11
|
-
updateAttributes(updates: Record<string, string | number | boolean>): Promise<IUser>;
|
|
12
|
-
updateAttribute(attributeKey: string, value: string | number | boolean): Promise<IUser>;
|
|
13
|
-
getFeatures(signal?: AbortSignal): Promise<Record<string, boolean>>;
|
|
14
|
-
}
|
|
15
|
-
/** Memoized UserApi instance. Recreates only when serverUrl or version change. BaseApi.ensureReady() throws if config is not set. */
|
|
16
|
-
export declare function useUserApi(): UserApi;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export { useUserApi } from './api';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to access user attributes from the UserProvider.
|
|
4
|
-
* Must be used within a UserProvider component.
|
|
5
|
-
*
|
|
6
|
-
* @returns User context object containing:
|
|
7
|
-
* - `attributes`: Record of user attribute key-value pairs
|
|
8
|
-
* - `isLoading`: Boolean indicating if attributes are being loaded
|
|
9
|
-
* - `error`: Error message string (null if no error)
|
|
10
|
-
* - `refreshAttributes()`: Function to manually refresh attributes
|
|
11
|
-
*
|
|
12
|
-
* @throws {Error} If used outside of UserProvider
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* function UserProfile() {
|
|
17
|
-
* const { attributes, isLoading } = useUserAttributes();
|
|
18
|
-
*
|
|
19
|
-
* if (isLoading) return <Loading />;
|
|
20
|
-
*
|
|
21
|
-
* return (
|
|
22
|
-
* <div>
|
|
23
|
-
* <p>Plan: {attributes?.plan}</p>
|
|
24
|
-
* <p>Company: {attributes?.company}</p>
|
|
25
|
-
* </div>
|
|
26
|
-
* );
|
|
27
|
-
* }
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export declare function useUserAttributes(): import("./provider").UserContextValue;
|
|
31
|
-
/**
|
|
32
|
-
* Hook to access user feature flags from the UserProvider.
|
|
33
|
-
* Must be used within a UserProvider component.
|
|
34
|
-
*
|
|
35
|
-
* @returns An object containing:
|
|
36
|
-
* - `features`: Record of feature flag key-value pairs (boolean values)
|
|
37
|
-
* - `isLoading`: Boolean indicating if features are being loaded
|
|
38
|
-
* - `error`: Error message string (null if no error)
|
|
39
|
-
* - `refreshFeatures()`: Function to manually refresh features
|
|
40
|
-
* - `isFeatureEnabled(featureId)`: Function to check if a specific feature is enabled
|
|
41
|
-
*
|
|
42
|
-
* @throws {Error} If used outside of UserProvider
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```tsx
|
|
46
|
-
* function FeatureContent() {
|
|
47
|
-
* const { isFeatureEnabled, isLoading } = useUserFeatures();
|
|
48
|
-
*
|
|
49
|
-
* if (isLoading) return <Loading />;
|
|
50
|
-
*
|
|
51
|
-
* if (isFeatureEnabled('premium-feature')) {
|
|
52
|
-
* return <PremiumFeature />;
|
|
53
|
-
* }
|
|
54
|
-
*
|
|
55
|
-
* return <BasicFeature />;
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```tsx
|
|
61
|
-
* // Check multiple features
|
|
62
|
-
* function Dashboard() {
|
|
63
|
-
* const { isFeatureEnabled } = useUserFeatures();
|
|
64
|
-
*
|
|
65
|
-
* return (
|
|
66
|
-
* <div>
|
|
67
|
-
* {isFeatureEnabled('analytics') && <Analytics />}
|
|
68
|
-
* {isFeatureEnabled('reports') && <Reports />}
|
|
69
|
-
* </div>
|
|
70
|
-
* );
|
|
71
|
-
* }
|
|
72
|
-
* ```
|
|
73
|
-
*/
|
|
74
|
-
export declare function useUserFeatures(): {
|
|
75
|
-
features: Record<string, boolean>;
|
|
76
|
-
isLoading: boolean;
|
|
77
|
-
error: Error | null;
|
|
78
|
-
refreshFeatures: () => Promise<void>;
|
|
79
|
-
isFeatureEnabled: (featureId: string) => boolean;
|
|
80
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { IUser } from '../../api/types';
|
|
3
|
-
export interface UserContextValue {
|
|
4
|
-
attributes: Record<string, string | number | boolean>;
|
|
5
|
-
features: Record<string, boolean>;
|
|
6
|
-
isLoading: boolean;
|
|
7
|
-
error: Error | null;
|
|
8
|
-
updateAttributes: (updates: Record<string, string | number | boolean>) => Promise<IUser>;
|
|
9
|
-
updateAttribute: (attributeKey: string, value: string | number | boolean) => Promise<IUser>;
|
|
10
|
-
refreshAttributes: () => Promise<void>;
|
|
11
|
-
refreshFeatures: () => Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
declare const UserContext: React.Context<UserContextValue | undefined>;
|
|
14
|
-
export declare const UserProvider: React.FC<{
|
|
15
|
-
children: React.ReactNode;
|
|
16
|
-
}>;
|
|
17
|
-
export { UserContext };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* WorkspaceSettingsProvider
|
|
4
|
-
* Renders the settings dialog and manages its state internally
|
|
5
|
-
* Users can call openWorkspaceSettings() from useWorkspaceSettings hook
|
|
6
|
-
*/
|
|
7
|
-
export declare const WorkspaceSettingsProvider: React.FC<{
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
}>;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { IAllQuotaUsageResponse, CheckoutResult, ICheckoutSessionRequest, ICheckoutSessionResponse, IInvoiceListResponse, IInvoiceResponse, IPlanGroupResponse, IPlanGroupVersion, IPlanGroupVersionsResponse, IPublicPlansResponse, IQuotaUsageStatusResponse, IRecordUsageRequest, IRecordUsageResponse, ISubscriptionResponse, ISubscriptionUpdateRequest, ISubscriptionUpdateResponse, IUsageLogsQuery, IUsageLogsResponse, IUser } from '../../api/types';
|
|
2
|
-
import { BaseApi } from '../../lib/api-base';
|
|
3
|
-
import { IOsConfig } from '../os/types';
|
|
4
|
-
import type { IWorkspace, IWorkspaceFeature, IWorkspaceUser } from './types';
|
|
5
|
-
export declare class WorkspaceApi extends BaseApi {
|
|
6
|
-
constructor(config: IOsConfig);
|
|
7
|
-
getWorkspaces(): Promise<IWorkspace[]>;
|
|
8
|
-
createWorkspace(data: {
|
|
9
|
-
name: string;
|
|
10
|
-
image?: string;
|
|
11
|
-
}): Promise<IWorkspace>;
|
|
12
|
-
updateWorkspace(id: string, data: Partial<IWorkspace>): Promise<IWorkspace>;
|
|
13
|
-
deleteWorkspace(id: string): Promise<{
|
|
14
|
-
success: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
getWorkspaceUsers(workspaceId: string): Promise<IWorkspaceUser[]>;
|
|
17
|
-
addUser(workspaceId: string, config: {
|
|
18
|
-
email: string;
|
|
19
|
-
role: string;
|
|
20
|
-
}): Promise<{
|
|
21
|
-
userId: string;
|
|
22
|
-
workspace: IWorkspace;
|
|
23
|
-
message: string;
|
|
24
|
-
}>;
|
|
25
|
-
removeUser(workspaceId: string, userId: string): Promise<{
|
|
26
|
-
userId: string;
|
|
27
|
-
workspace: IWorkspace;
|
|
28
|
-
message: string;
|
|
29
|
-
}>;
|
|
30
|
-
updateUser(workspaceId: string, userId: string, data: Partial<IWorkspaceUser>): Promise<{
|
|
31
|
-
userId: string;
|
|
32
|
-
workspace: IWorkspace;
|
|
33
|
-
message: string;
|
|
34
|
-
}>;
|
|
35
|
-
getFeatures(): Promise<IWorkspaceFeature[]>;
|
|
36
|
-
updateFeature(workspaceId: string, key: string, value: boolean): Promise<IWorkspace>;
|
|
37
|
-
getWorkspace(workspaceId: string): Promise<IWorkspace>;
|
|
38
|
-
getProfile(): Promise<IUser>;
|
|
39
|
-
updateUserProfile(config: Partial<IUser>): Promise<IUser>;
|
|
40
|
-
/**
|
|
41
|
-
* Get current subscription for a workspace
|
|
42
|
-
* Returns subscription details including plan, plan version, and group information
|
|
43
|
-
*/
|
|
44
|
-
getCurrentSubscription(workspaceId: string): Promise<ISubscriptionResponse>;
|
|
45
|
-
/**
|
|
46
|
-
* Get plan group for a workspace
|
|
47
|
-
* Returns the plan group containing the current plan if subscription exists,
|
|
48
|
-
* otherwise returns the latest published group
|
|
49
|
-
*/
|
|
50
|
-
getPlanGroup(workspaceId: string): Promise<IPlanGroupResponse>;
|
|
51
|
-
/**
|
|
52
|
-
* Get plan group for a workspace with a specific version
|
|
53
|
-
* @param workspaceId - The workspace ID
|
|
54
|
-
* @param groupVersionId - The plan group version ID to fetch
|
|
55
|
-
* @returns Plan group response with the specified version
|
|
56
|
-
*/
|
|
57
|
-
getPlanGroupByVersion(workspaceId: string, groupVersionId: string): Promise<IPlanGroupResponse>;
|
|
58
|
-
/**
|
|
59
|
-
* Get current group version and available newer versions of the same group
|
|
60
|
-
* - If user has active subscription: returns their current group version + newer versions
|
|
61
|
-
* - If no subscription: returns the latest published group version
|
|
62
|
-
* Shows what's new in newer versions to help users upgrade
|
|
63
|
-
* Example: User on Group v1 (Basic Plan) can see Group v2 (Basic + Pro Plan)
|
|
64
|
-
* @param workspaceId - The workspace ID
|
|
65
|
-
* @returns Plan group versions response with currentVersion and availableVersions
|
|
66
|
-
*/
|
|
67
|
-
getPlanGroupVersions(workspaceId: string): Promise<IPlanGroupVersionsResponse>;
|
|
68
|
-
/**
|
|
69
|
-
* Get plan group versions by slug (public, no auth required).
|
|
70
|
-
* Returns the latest published plan group versions for the given plan group slug.
|
|
71
|
-
* Use this for public pricing pages when you want to show a specific plan group.
|
|
72
|
-
*
|
|
73
|
-
* @param slug - Plan group slug (e.g. 'default', 'enterprise')
|
|
74
|
-
* @returns Plan group versions response with currentVersion and availableVersions
|
|
75
|
-
*/
|
|
76
|
-
getPublicPlans(slug: string): Promise<IPublicPlansResponse>;
|
|
77
|
-
/**
|
|
78
|
-
* Get plan group version details by ID (public, no auth required).
|
|
79
|
-
* Returns the full plan group version with populated plan versions.
|
|
80
|
-
* Use this for public pricing pages when you have the groupVersionId (e.g. from config or URL).
|
|
81
|
-
*
|
|
82
|
-
* @param groupVersionId - The plan group version ID to fetch
|
|
83
|
-
* @returns Plan group version with populated plan versions
|
|
84
|
-
*/
|
|
85
|
-
getPlanGroupVersion(groupVersionId: string): Promise<IPlanGroupVersion>;
|
|
86
|
-
/**
|
|
87
|
-
* Create checkout session for new subscription
|
|
88
|
-
* @param workspaceId - The workspace ID
|
|
89
|
-
* @param request - Checkout session request with planVersionId and optional billing interval/URLs
|
|
90
|
-
* @returns Checkout session response with checkoutUrl to redirect user
|
|
91
|
-
*/
|
|
92
|
-
createCheckoutSession(workspaceId: string, request: ICheckoutSessionRequest): Promise<CheckoutResult>;
|
|
93
|
-
/**
|
|
94
|
-
* Update subscription (upgrade/downgrade)
|
|
95
|
-
* Only allows plan changes within the same plan group
|
|
96
|
-
* Returns checkout session if payment is required, otherwise returns subscription update response
|
|
97
|
-
*/
|
|
98
|
-
updateSubscription(workspaceId: string, request: ISubscriptionUpdateRequest): Promise<ISubscriptionUpdateResponse | ICheckoutSessionResponse>;
|
|
99
|
-
/**
|
|
100
|
-
* List invoices for a workspace subscription
|
|
101
|
-
* @param workspaceId - The workspace ID
|
|
102
|
-
* @param limit - Number of invoices to return (default: 10)
|
|
103
|
-
* @param startingAfter - Invoice ID to start after (for pagination)
|
|
104
|
-
* @returns List of invoices with pagination info
|
|
105
|
-
*/
|
|
106
|
-
listInvoices(workspaceId: string, limit?: number, startingAfter?: string): Promise<IInvoiceListResponse>;
|
|
107
|
-
/**
|
|
108
|
-
* Get a single invoice by ID
|
|
109
|
-
* @param workspaceId - The workspace ID
|
|
110
|
-
* @param invoiceId - The invoice ID
|
|
111
|
-
* @returns Invoice details
|
|
112
|
-
*/
|
|
113
|
-
getInvoice(workspaceId: string, invoiceId: string): Promise<IInvoiceResponse>;
|
|
114
|
-
/**
|
|
115
|
-
* Cancel subscription at the end of the current billing period
|
|
116
|
-
* Sets cancelAtPeriodEnd: true - subscription remains active until period ends
|
|
117
|
-
* @param workspaceId - The workspace ID
|
|
118
|
-
* @returns Updated subscription with cancelAtPeriodEnd and stripeCurrentPeriodEnd
|
|
119
|
-
*/
|
|
120
|
-
cancelSubscriptionAtPeriodEnd(workspaceId: string): Promise<ISubscriptionResponse>;
|
|
121
|
-
/**
|
|
122
|
-
* Resume a subscription that was scheduled for cancellation
|
|
123
|
-
* Sets cancelAtPeriodEnd: false - subscription will continue after period ends
|
|
124
|
-
* @param workspaceId - The workspace ID
|
|
125
|
-
* @returns Updated subscription with cancelAtPeriodEnd set to false
|
|
126
|
-
*/
|
|
127
|
-
resumeSubscription(workspaceId: string): Promise<ISubscriptionResponse>;
|
|
128
|
-
/**
|
|
129
|
-
* Record quota usage for a workspace
|
|
130
|
-
* @param workspaceId - The workspace ID
|
|
131
|
-
* @param request - Usage request with quotaSlug, quantity, and optional metadata/source
|
|
132
|
-
* @returns Usage result with consumed/included/available/overage
|
|
133
|
-
*/
|
|
134
|
-
recordUsage(workspaceId: string, request: IRecordUsageRequest): Promise<IRecordUsageResponse>;
|
|
135
|
-
/**
|
|
136
|
-
* Get usage status for a single quota
|
|
137
|
-
* @param workspaceId - The workspace ID
|
|
138
|
-
* @param quotaSlug - The quota slug to check
|
|
139
|
-
* @returns Quota usage status with consumed/included/available/overage/hasOverage
|
|
140
|
-
*/
|
|
141
|
-
getQuotaUsageStatus(workspaceId: string, quotaSlug: string): Promise<IQuotaUsageStatusResponse>;
|
|
142
|
-
/**
|
|
143
|
-
* Get usage status for all quotas in the workspace's current plan
|
|
144
|
-
* @param workspaceId - The workspace ID
|
|
145
|
-
* @returns All quota usage statuses keyed by quota slug
|
|
146
|
-
*/
|
|
147
|
-
getAllQuotaUsage(workspaceId: string): Promise<IAllQuotaUsageResponse>;
|
|
148
|
-
/**
|
|
149
|
-
* Get paginated usage logs for a workspace
|
|
150
|
-
* @param workspaceId - The workspace ID
|
|
151
|
-
* @param query - Optional filters: quotaSlug, from, to, source, page, limit
|
|
152
|
-
* @returns Paginated usage log entries
|
|
153
|
-
*/
|
|
154
|
-
getUsageLogs(workspaceId: string, query?: IUsageLogsQuery): Promise<IUsageLogsResponse>;
|
|
155
|
-
}
|