@buildbase/sdk 0.0.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/README.md +304 -0
- package/dist/index.d.ts +310 -0
- package/dist/index.esm.js +30 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/saas-os.css +3 -0
- package/dist/types/api/index.d.ts +1 -0
- package/dist/types/api/types.d.ts +49 -0
- package/dist/types/components/beta/BetaForm.d.ts +24 -0
- package/dist/types/components/beta/api.d.ts +49 -0
- package/dist/types/components/beta/hooks.d.ts +11 -0
- package/dist/types/components/beta/schema.d.ts +6 -0
- package/dist/types/components/beta/types.d.ts +8 -0
- package/dist/types/components/dropdowns/country/countries.d.ts +7 -0
- package/dist/types/components/dropdowns/country/selectCountry.d.ts +6 -0
- package/dist/types/components/dropdowns/currency/currencies.d.ts +6 -0
- package/dist/types/components/dropdowns/currency/selectCurrency.d.ts +6 -0
- package/dist/types/components/dropdowns/language/languages.d.ts +6 -0
- package/dist/types/components/dropdowns/language/selectLanguage.d.ts +6 -0
- package/dist/types/components/dropdowns/timezone/selectTimeZone.d.ts +6 -0
- package/dist/types/components/dropdowns/timezone/timezones.d.ts +8 -0
- package/dist/types/components/features/index.d.ts +7 -0
- package/dist/types/components/ui/accordion.d.ts +7 -0
- package/dist/types/components/ui/alert-dialog.d.ts +20 -0
- package/dist/types/components/ui/alert.d.ts +8 -0
- package/dist/types/components/ui/aspect-ratio.d.ts +3 -0
- package/dist/types/components/ui/avatar.d.ts +6 -0
- package/dist/types/components/ui/badge.d.ts +9 -0
- package/dist/types/components/ui/button.d.ts +18 -0
- package/dist/types/components/ui/buttonIcon.d.ts +9 -0
- package/dist/types/components/ui/calendar.d.ts +8 -0
- package/dist/types/components/ui/card.d.ts +8 -0
- package/dist/types/components/ui/checkbox.d.ts +4 -0
- package/dist/types/components/ui/collapsible.d.ts +5 -0
- package/dist/types/components/ui/command.d.ts +82 -0
- package/dist/types/components/ui/context-menu.d.ts +27 -0
- package/dist/types/components/ui/dateRangePicker.d.ts +9 -0
- package/dist/types/components/ui/dialog.d.ts +19 -0
- package/dist/types/components/ui/dropdown-menu.d.ts +27 -0
- package/dist/types/components/ui/form.d.ts +23 -0
- package/dist/types/components/ui/heading.d.ts +10 -0
- package/dist/types/components/ui/hover-card.d.ts +6 -0
- package/dist/types/components/ui/input.d.ts +5 -0
- package/dist/types/components/ui/label.d.ts +5 -0
- package/dist/types/components/ui/menubar.d.ts +33 -0
- package/dist/types/components/ui/navigation-menu.d.ts +12 -0
- package/dist/types/components/ui/popover.d.ts +6 -0
- package/dist/types/components/ui/progress.d.ts +4 -0
- package/dist/types/components/ui/radio-group.d.ts +5 -0
- package/dist/types/components/ui/scroll-area.d.ts +5 -0
- package/dist/types/components/ui/select.d.ts +11 -0
- package/dist/types/components/ui/separator.d.ts +4 -0
- package/dist/types/components/ui/sheet.d.ts +28 -0
- package/dist/types/components/ui/skeleton.d.ts +3 -0
- package/dist/types/components/ui/slider.d.ts +4 -0
- package/dist/types/components/ui/switch.d.ts +4 -0
- package/dist/types/components/ui/table.d.ts +10 -0
- package/dist/types/components/ui/tabs.d.ts +7 -0
- package/dist/types/components/ui/textarea.d.ts +5 -0
- package/dist/types/components/ui/toast.d.ts +15 -0
- package/dist/types/components/ui/toaster.d.ts +1 -0
- package/dist/types/components/ui/toggle.d.ts +12 -0
- package/dist/types/components/ui/tooltip.d.ts +7 -0
- package/dist/types/components/ui/use-toast.d.ts +44 -0
- package/dist/types/components/user/auth.d.ts +6 -0
- package/dist/types/components/user/role.d.ts +8 -0
- package/dist/types/contexts/AuthContext.d.ts +9 -0
- package/dist/types/contexts/OSContext.d.ts +9 -0
- package/dist/types/contexts/SDKContextProvider.d.ts +15 -0
- package/dist/types/contexts/WorkspaceContext.d.ts +8 -0
- package/dist/types/contexts/actionCreators.d.ts +29 -0
- package/dist/types/contexts/createContext.d.ts +27 -0
- package/dist/types/contexts/index.d.ts +10 -0
- package/dist/types/contexts/reducers/authReducer.d.ts +13 -0
- package/dist/types/contexts/reducers/index.d.ts +3 -0
- package/dist/types/contexts/reducers/osReducer.d.ts +11 -0
- package/dist/types/contexts/reducers/workspaceReducer.d.ts +10 -0
- package/dist/types/contexts/types.d.ts +74 -0
- package/dist/types/contexts/useAppDispatch.d.ts +28 -0
- package/dist/types/contexts/useAppSelector.d.ts +36 -0
- package/dist/types/contexts/utils/reducerHelpers.d.ts +11 -0
- package/dist/types/contexts/utils/storage.d.ts +23 -0
- package/dist/types/hooks/use-mobile.d.ts +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/lib/api-client.d.ts +29 -0
- package/dist/types/lib/utils.d.ts +2 -0
- package/dist/types/providers/ContextConfigProvider.d.ts +15 -0
- package/dist/types/providers/PortalContainer.d.ts +8 -0
- package/dist/types/providers/SaaSOSProvider.d.ts +7 -0
- package/dist/types/providers/auth/hooks.d.ts +10 -0
- package/dist/types/providers/auth/provider.d.ts +8 -0
- package/dist/types/providers/auth/types.d.ts +38 -0
- package/dist/types/providers/auth/utils.d.ts +10 -0
- package/dist/types/providers/os/types.d.ts +9 -0
- package/dist/types/providers/workspace/api.d.ts +33 -0
- package/dist/types/providers/workspace/hooks.d.ts +30 -0
- package/dist/types/providers/workspace/provider.d.ts +9 -0
- package/dist/types/providers/workspace/types.d.ts +38 -0
- package/dist/types/providers/workspace/ui/SettingsDialog.d.ts +8 -0
- package/dist/types/providers/workspace/ui/SettingsFeatures.d.ts +5 -0
- package/dist/types/providers/workspace/ui/SettingsGeneral.d.ts +6 -0
- package/dist/types/providers/workspace/ui/SettingsProfile.d.ts +6 -0
- package/dist/types/providers/workspace/ui/SettingsUsers.d.ts +6 -0
- package/dist/types/providers/workspace/ui/Sidebar.d.ts +10 -0
- package/dist/types/providers/workspace/ui/utils.d.ts +2 -0
- package/dist/types/providers/workspace/utils.d.ts +8 -0
- package/package.json +122 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AuthAction, OSAction, WorkspaceAction } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Combined SDK Dispatch
|
|
4
|
+
* Provides dispatch functions for all contexts
|
|
5
|
+
*/
|
|
6
|
+
export interface SDKDispatch {
|
|
7
|
+
auth: (action: AuthAction) => void;
|
|
8
|
+
os: (action: OSAction) => void;
|
|
9
|
+
workspaces: (action: WorkspaceAction) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Combined dispatch hook - dispatch actions to all contexts
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const dispatch = useAppDispatch();
|
|
17
|
+
*
|
|
18
|
+
* // Dispatch to auth context
|
|
19
|
+
* dispatch.auth(authActions.setSession(session));
|
|
20
|
+
*
|
|
21
|
+
* // Dispatch to workspace context
|
|
22
|
+
* dispatch.workspaces(workspaceActions.setCurrentWorkspace(workspace));
|
|
23
|
+
*
|
|
24
|
+
* // Dispatch to OS context
|
|
25
|
+
* dispatch.os(osActions.setSaaSOSConfig(config));
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useAppDispatch(): SDKDispatch;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IAuthState } from '../providers/auth/types';
|
|
2
|
+
import type { IOsState } from '../providers/os/types';
|
|
3
|
+
import type { WorkspaceState } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Combined SDK State
|
|
6
|
+
* Represents the complete state structure across all contexts
|
|
7
|
+
*/
|
|
8
|
+
export interface SDKState {
|
|
9
|
+
os: IOsState;
|
|
10
|
+
auth: IAuthState;
|
|
11
|
+
workspaces: WorkspaceState;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Combined selector hook - select from all contexts at once
|
|
15
|
+
*
|
|
16
|
+
* @param selector Function that selects a value from the combined SDK state
|
|
17
|
+
* @param equalityFn Optional equality function for comparison (default: Object.is)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // Get entire combined state
|
|
22
|
+
* const sdk = useAppSelector();
|
|
23
|
+
*
|
|
24
|
+
* // Get specific context
|
|
25
|
+
* const auth = useAppSelector(state => state.auth);
|
|
26
|
+
* const user = useAppSelector(state => state.auth.user);
|
|
27
|
+
*
|
|
28
|
+
* // Get multiple fields across contexts
|
|
29
|
+
* const { user, currentWorkspace, serverUrl } = useAppSelector(state => ({
|
|
30
|
+
* user: state.auth.user,
|
|
31
|
+
* currentWorkspace: state.workspaces.currentWorkspace,
|
|
32
|
+
* serverUrl: state.os.serverUrl,
|
|
33
|
+
* }));
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function useAppSelector<Selected = SDKState>(selector?: (state: SDKState) => Selected, equalityFn?: (a: Selected, b: Selected) => boolean): Selected;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reducer helper utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Creates a simple reducer case that updates a single field
|
|
6
|
+
*/
|
|
7
|
+
export declare function updateField<State extends Record<string, any>>(state: State, field: keyof State, value: any): State;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a reducer case that updates multiple fields
|
|
10
|
+
*/
|
|
11
|
+
export declare function updateFields<State extends Record<string, any>>(state: State, updates: Partial<State>): State;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared localStorage utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Safe localStorage getter
|
|
6
|
+
*/
|
|
7
|
+
export declare function getStorageItem(key: string): string | null;
|
|
8
|
+
/**
|
|
9
|
+
* Safe localStorage setter
|
|
10
|
+
*/
|
|
11
|
+
export declare function setStorageItem(key: string, value: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* Safe localStorage remover
|
|
14
|
+
*/
|
|
15
|
+
export declare function removeStorageItem(key: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Safe JSON parse from localStorage
|
|
18
|
+
*/
|
|
19
|
+
export declare function getStorageJSON<T>(key: string): T | null;
|
|
20
|
+
/**
|
|
21
|
+
* Safe JSON stringify to localStorage
|
|
22
|
+
*/
|
|
23
|
+
export declare function setStorageJSON<T>(key: string, value: T): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useIsMobile(): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './styles/globals.css';
|
|
2
|
+
export { SaaSOSProvider } from './providers/SaaSOSProvider';
|
|
3
|
+
export type { SaaSOSProviderProps } from './providers/SaaSOSProvider';
|
|
4
|
+
export { BetaForm } from './components/beta/BetaForm';
|
|
5
|
+
export { WhenAuthenticated, WhenUnauthenticated } from './components/user/auth';
|
|
6
|
+
export { WhenRoles, WhenWorkspaceRoles } from './components/user/role';
|
|
7
|
+
export { WhenWorkspaceFeatureDisabled, WhenWorkspaceFeatureEnabled } from './components/features';
|
|
8
|
+
export { useSaaSAuth } from './providers/auth/hooks';
|
|
9
|
+
export { useSaaSWorkspaces } from './providers/workspace/hooks';
|
|
10
|
+
export { WorkspaceSwitcher } from './providers/workspace/provider';
|
|
11
|
+
export { useAppSelector } from './contexts/useAppSelector';
|
|
12
|
+
export type { SDKState } from './contexts/useAppSelector';
|
|
13
|
+
export { useAppDispatch } from './contexts/useAppDispatch';
|
|
14
|
+
export type { SDKDispatch } from './contexts/useAppDispatch';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
export interface ApiClientConfig {
|
|
3
|
+
baseURL?: string;
|
|
4
|
+
timeout?: number;
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export interface ApiResponse<T = any> {
|
|
8
|
+
data: T;
|
|
9
|
+
status: number;
|
|
10
|
+
statusText: string;
|
|
11
|
+
headers: any;
|
|
12
|
+
}
|
|
13
|
+
export declare class ApiClient {
|
|
14
|
+
private client;
|
|
15
|
+
constructor(config?: ApiClientConfig);
|
|
16
|
+
private getAuthToken;
|
|
17
|
+
private handleUnauthorized;
|
|
18
|
+
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
19
|
+
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
20
|
+
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
21
|
+
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
22
|
+
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
23
|
+
setAuthToken(token: string): void;
|
|
24
|
+
removeAuthToken(): void;
|
|
25
|
+
setBaseURL(baseURL: string): void;
|
|
26
|
+
setHeader(key: string, value: string): void;
|
|
27
|
+
removeHeader(key: string): void;
|
|
28
|
+
}
|
|
29
|
+
export declare const defaultApiClient: ApiClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { IAuthConfig } from './auth/types';
|
|
3
|
+
import type { IOsState } from './os/types';
|
|
4
|
+
interface ContextConfigProviderProps {
|
|
5
|
+
config: IOsState;
|
|
6
|
+
auth?: IAuthConfig;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Context Config Provider
|
|
11
|
+
* Initializes OS configuration in Context API mode
|
|
12
|
+
* Similar to SaaSConfigProvider but for Context API
|
|
13
|
+
*/
|
|
14
|
+
export declare const ContextConfigProvider: React.FC<ContextConfigProviderProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const PortalContext: React.Context<{
|
|
3
|
+
container: HTMLDivElement | null;
|
|
4
|
+
setContainer: (container: HTMLDivElement | null) => void;
|
|
5
|
+
}>;
|
|
6
|
+
export default function PortalProvider({ children }: {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function useSaaSAuth(): {
|
|
2
|
+
user: import("./types").AuthUser | null;
|
|
3
|
+
session: import("./types").AuthSession | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
isAuthenticated: boolean;
|
|
6
|
+
isRedirecting: boolean;
|
|
7
|
+
status: import("./types").AuthStatus;
|
|
8
|
+
signIn: () => Promise<void>;
|
|
9
|
+
signOut: () => Promise<void>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { IAuthCallbacks } from './types';
|
|
3
|
+
interface IProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
callbacks?: IAuthCallbacks;
|
|
6
|
+
}
|
|
7
|
+
export declare function AuthProvider({ children, callbacks }: IProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare enum AuthStatus {
|
|
2
|
+
loading = "loading",
|
|
3
|
+
authenticated = "authenticated",
|
|
4
|
+
unauthenticated = "unauthenticated",
|
|
5
|
+
authenticating = "authenticating"
|
|
6
|
+
}
|
|
7
|
+
export interface AuthUser {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
org: string;
|
|
11
|
+
email: string;
|
|
12
|
+
emailVerified: boolean;
|
|
13
|
+
clientId: string;
|
|
14
|
+
role: string;
|
|
15
|
+
image?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AuthSession {
|
|
18
|
+
user: AuthUser;
|
|
19
|
+
accessToken: string;
|
|
20
|
+
expires: string;
|
|
21
|
+
}
|
|
22
|
+
export interface IAuthState {
|
|
23
|
+
user: AuthUser | null;
|
|
24
|
+
session: AuthSession | null;
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
isAuthenticated: boolean;
|
|
27
|
+
isRedirecting: boolean;
|
|
28
|
+
status: AuthStatus;
|
|
29
|
+
}
|
|
30
|
+
export interface IAuthConfig {
|
|
31
|
+
clientId: string;
|
|
32
|
+
redirectUrl: string;
|
|
33
|
+
callbacks?: IAuthCallbacks;
|
|
34
|
+
}
|
|
35
|
+
export interface IAuthCallbacks {
|
|
36
|
+
handleAuthentication: (token: string) => Promise<void>;
|
|
37
|
+
verifyToken: (token: string) => Promise<boolean>;
|
|
38
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AuthSession, AuthUser } from './types';
|
|
2
|
+
export declare const AUTH_TOKEN_KEY = "saas_os_auth_token";
|
|
3
|
+
export declare function getAccessToken(): string | null;
|
|
4
|
+
export declare function getTokenFromUrl(): string | null;
|
|
5
|
+
export declare function removeTokenFromUrl(): void;
|
|
6
|
+
export declare function createSession(user: AuthUser, token: string, hours?: number): AuthSession;
|
|
7
|
+
export declare const AUTH_CONSTANTS: {
|
|
8
|
+
TOKEN_PARAM: string;
|
|
9
|
+
AUTH_TOKEN_KEY: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { IUser } from '../../api/types';
|
|
2
|
+
import { IOsConfig } from '../os/types';
|
|
3
|
+
import type { IWorkspace, IWorkspaceFeature, IWorkspaceUser } from './types';
|
|
4
|
+
export declare class WorkspaceApi {
|
|
5
|
+
private version;
|
|
6
|
+
private orgId;
|
|
7
|
+
private serverUrl;
|
|
8
|
+
constructor(config: IOsConfig);
|
|
9
|
+
getAuthHeader(): Record<string, string>;
|
|
10
|
+
getWorkspaces(): Promise<IWorkspace[]>;
|
|
11
|
+
createWorkspace(data: {
|
|
12
|
+
name: string;
|
|
13
|
+
image?: string;
|
|
14
|
+
}): Promise<IWorkspace>;
|
|
15
|
+
updateWorkspace(id: string, data: Partial<IWorkspace>): Promise<IWorkspace>;
|
|
16
|
+
deleteWorkspace(id: string): Promise<{
|
|
17
|
+
success: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
getWorkspaceUsers(workspaceId: string): Promise<IWorkspaceUser[]>;
|
|
20
|
+
addUser(workspaceId: string, config: {
|
|
21
|
+
email: string;
|
|
22
|
+
role: string;
|
|
23
|
+
}): Promise<IWorkspaceUser>;
|
|
24
|
+
removeUser(workspaceId: string, userId: string): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
updateUser(workspaceId: string, userId: string, data: Partial<IWorkspaceUser>): Promise<IWorkspaceUser>;
|
|
28
|
+
getFeatures(): Promise<IWorkspaceFeature[]>;
|
|
29
|
+
updateFeature(workspaceId: string, key: string, value: boolean): Promise<IWorkspace>;
|
|
30
|
+
getWorkspace(workspaceId: string): Promise<IWorkspace>;
|
|
31
|
+
getProfile(): Promise<IUser>;
|
|
32
|
+
updateUserProfile(config: Partial<IUser>): Promise<IUser>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IUser } from '../../api/types';
|
|
2
|
+
import { WorkspaceSwitcher } from './provider';
|
|
3
|
+
import { IWorkspace, IWorkspaceUser } from './types';
|
|
4
|
+
export declare const useSaaSWorkspaces: () => {
|
|
5
|
+
workspaces: IWorkspace[];
|
|
6
|
+
loading: boolean;
|
|
7
|
+
error: string | null;
|
|
8
|
+
fetchWorkspaces: () => Promise<void>;
|
|
9
|
+
refreshWorkspaces: () => Promise<void>;
|
|
10
|
+
refreshing: boolean;
|
|
11
|
+
WorkspaceSwitcher: typeof WorkspaceSwitcher;
|
|
12
|
+
currentWorkspace: IWorkspace | null;
|
|
13
|
+
setCurrentWorkspace: (ws: IWorkspace) => void;
|
|
14
|
+
resetCurrentWorkspace: () => void;
|
|
15
|
+
createWorkspace: (name: string, image: string) => Promise<void>;
|
|
16
|
+
allFeatures: import("./types").IWorkspaceFeature[];
|
|
17
|
+
getFeatures: () => Promise<import("./types").IWorkspaceFeature[]>;
|
|
18
|
+
updateFeature: (workspaceId: string, key: string, value: boolean) => Promise<IWorkspace>;
|
|
19
|
+
getWorkspace: (workspaceId: string) => Promise<IWorkspace>;
|
|
20
|
+
switching: boolean;
|
|
21
|
+
updateWorkspace: (ws: IWorkspace, _data: Partial<IWorkspace>) => Promise<void>;
|
|
22
|
+
getUsers: (workspaceId: string) => Promise<IWorkspaceUser[]>;
|
|
23
|
+
addUser: (workspaceId: string, email: string, role: string) => Promise<IWorkspaceUser>;
|
|
24
|
+
removeUser: (workspaceId: string, userId: string) => Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
updateUser: (workspaceId: string, userId: string, config: Partial<IWorkspaceUser>) => Promise<IWorkspaceUser>;
|
|
28
|
+
getProfile: () => Promise<IUser>;
|
|
29
|
+
updateUserProfile: (config: Partial<IUser>) => Promise<IUser>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import type { IWorkspace } from './types';
|
|
3
|
+
export declare const WorkspaceProvider: ({ children }: {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function WorkspaceSwitcher(props: {
|
|
7
|
+
trigger: (currentWorkspace: IWorkspace | null) => ReactNode;
|
|
8
|
+
onWorkspaceChange: (workspace: IWorkspace) => Promise<void>;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface IWorkspace {
|
|
2
|
+
_id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
image?: string;
|
|
5
|
+
workspaceId: string;
|
|
6
|
+
users: IUser[];
|
|
7
|
+
roles: string[];
|
|
8
|
+
createdBy: string | IUser;
|
|
9
|
+
features: Record<string, boolean>;
|
|
10
|
+
}
|
|
11
|
+
export interface IWorkspaceFeature {
|
|
12
|
+
_id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
userManaged: boolean;
|
|
16
|
+
defaultValue: boolean;
|
|
17
|
+
slug: string;
|
|
18
|
+
category: string;
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
updatedAt: Date;
|
|
21
|
+
}
|
|
22
|
+
export interface IWorkspaceUser {
|
|
23
|
+
_id: string;
|
|
24
|
+
workspace: string | IWorkspace;
|
|
25
|
+
user: string | IUser;
|
|
26
|
+
role: string;
|
|
27
|
+
}
|
|
28
|
+
export interface WorkspaceContextValue {
|
|
29
|
+
workspaces: IWorkspace[];
|
|
30
|
+
currentWorkspace: IWorkspace | null;
|
|
31
|
+
loading: boolean;
|
|
32
|
+
switching: boolean;
|
|
33
|
+
refreshing: boolean;
|
|
34
|
+
error: string | null;
|
|
35
|
+
fetchWorkspaces: () => Promise<void>;
|
|
36
|
+
refreshWorkspaces: () => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
import type { IUser } from '../../api/types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IWorkspace } from '../types';
|
|
3
|
+
export type WorkspaceSettingsSection = 'profile' | 'general' | 'users' | 'features';
|
|
4
|
+
declare const WorkspaceSettingsDialog: React.FC<{
|
|
5
|
+
workspace: IWorkspace;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
}>;
|
|
8
|
+
export default WorkspaceSettingsDialog;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IWorkspace } from '../types';
|
|
3
|
+
import type { WorkspaceSettingsSection } from './SettingsDialog';
|
|
4
|
+
interface Props {
|
|
5
|
+
workspace: IWorkspace;
|
|
6
|
+
section: WorkspaceSettingsSection;
|
|
7
|
+
setSection: (section: WorkspaceSettingsSection) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const Sidebar: React.FC<Props>;
|
|
10
|
+
export default Sidebar;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IWorkspace } from './types';
|
|
2
|
+
export declare const workspaceStorage: {
|
|
3
|
+
saveCurrentWorkspace: (workspace: IWorkspace | null) => void;
|
|
4
|
+
loadCurrentWorkspace: () => string | null;
|
|
5
|
+
clearCurrentWorkspace: () => void;
|
|
6
|
+
isWorkspaceValid: (workspaceId: string | null, availableWorkspaces: IWorkspace[]) => boolean;
|
|
7
|
+
getStorageKey: () => string;
|
|
8
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@buildbase/sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A SDK for Buildbase",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"browser": "dist/index.esm.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "rollup -c",
|
|
16
|
+
"dev": "rollup -c -w",
|
|
17
|
+
"clean": "rimraf dist",
|
|
18
|
+
"prebuild": "npm run clean",
|
|
19
|
+
"prepublishOnly": "npm run build",
|
|
20
|
+
"publish:npm": "npm publish",
|
|
21
|
+
"publish:npm:beta": "npm publish --tag beta",
|
|
22
|
+
"publish:npm:dry-run": "npm publish --dry-run",
|
|
23
|
+
"yalc:add": "yalc add",
|
|
24
|
+
"yalc:push": "yalc push",
|
|
25
|
+
"yalc:remove": "yalc remove",
|
|
26
|
+
"format": "prettier --write . --plugin=prettier-plugin-organize-imports",
|
|
27
|
+
"push:sdk": "npm run build && yalc push",
|
|
28
|
+
"watch:push": "nodemon",
|
|
29
|
+
"watch:push:light": "chokidar \"src/**/*\" -c \"npm run push:sdk\" --initial --ignore dist"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"react": "^19.0.0",
|
|
33
|
+
"react-dom": "^19.0.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@radix-ui/react-icons": "^1.3.2",
|
|
37
|
+
"@radix-ui/react-toast": "^1.2.14",
|
|
38
|
+
"axios": "^1.6.0",
|
|
39
|
+
"class-variance-authority": "^0.7.0",
|
|
40
|
+
"clsx": "^2.0.0",
|
|
41
|
+
"cmdk": "^1.1.1",
|
|
42
|
+
"date-fns": "^4.1.0",
|
|
43
|
+
"javascript-time-ago": "^2.5.11",
|
|
44
|
+
"jwt-decode": "^4.0.0",
|
|
45
|
+
"lucide-react": "^0.544.0",
|
|
46
|
+
"luxon": "^3.7.2",
|
|
47
|
+
"moment": "^2.30.1",
|
|
48
|
+
"react-day-picker": "^9.7.0",
|
|
49
|
+
"react-hook-form": "^7.60.0",
|
|
50
|
+
"tailwind-merge": "^3.3.1",
|
|
51
|
+
"zod": "^4.1.8"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@hookform/resolvers": "^5.0.1",
|
|
55
|
+
"@radix-ui/react-accordion": "^1.2.10",
|
|
56
|
+
"@radix-ui/react-alert-dialog": "^1.1.13",
|
|
57
|
+
"@radix-ui/react-aspect-ratio": "^1.1.6",
|
|
58
|
+
"@radix-ui/react-avatar": "^1.1.9",
|
|
59
|
+
"@radix-ui/react-checkbox": "^1.3.1",
|
|
60
|
+
"@radix-ui/react-collapsible": "^1.1.10",
|
|
61
|
+
"@radix-ui/react-context-menu": "^2.2.14",
|
|
62
|
+
"@radix-ui/react-dialog": "^1.1.13",
|
|
63
|
+
"@radix-ui/react-dropdown-menu": "^2.1.14",
|
|
64
|
+
"@radix-ui/react-hover-card": "^1.1.13",
|
|
65
|
+
"@radix-ui/react-label": "^2.1.6",
|
|
66
|
+
"@radix-ui/react-menubar": "^1.1.14",
|
|
67
|
+
"@radix-ui/react-navigation-menu": "^1.2.12",
|
|
68
|
+
"@radix-ui/react-popover": "^1.1.13",
|
|
69
|
+
"@radix-ui/react-progress": "^1.1.6",
|
|
70
|
+
"@radix-ui/react-radio-group": "^1.3.6",
|
|
71
|
+
"@radix-ui/react-scroll-area": "^1.2.8",
|
|
72
|
+
"@radix-ui/react-select": "^2.2.4",
|
|
73
|
+
"@radix-ui/react-separator": "^1.1.6",
|
|
74
|
+
"@radix-ui/react-slider": "^1.3.4",
|
|
75
|
+
"@radix-ui/react-slot": "^1.2.2",
|
|
76
|
+
"@radix-ui/react-switch": "^1.2.4",
|
|
77
|
+
"@radix-ui/react-tabs": "^1.1.11",
|
|
78
|
+
"@radix-ui/react-toggle": "^1.1.8",
|
|
79
|
+
"@radix-ui/react-toggle-group": "^1.1.9",
|
|
80
|
+
"@radix-ui/react-tooltip": "^1.2.6",
|
|
81
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
82
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
83
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
84
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
85
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
86
|
+
"@types/luxon": "^3.7.1",
|
|
87
|
+
"@types/react": "^19.0.0",
|
|
88
|
+
"@types/react-dom": "^19.0.0",
|
|
89
|
+
"autoprefixer": "^10.4.16",
|
|
90
|
+
"chokidar-cli": "^3.0.0",
|
|
91
|
+
"eslint-config-prettier": "^10.1.8",
|
|
92
|
+
"nodemon": "^3.0.0",
|
|
93
|
+
"postcss": "^8.4.31",
|
|
94
|
+
"postcss-prefixwrap": "^1.55.0",
|
|
95
|
+
"prettier": "^3.0.3",
|
|
96
|
+
"prettier-plugin-organize-imports": "^4.1.0",
|
|
97
|
+
"prettier-plugin-tailwindcss": "^0.6.14",
|
|
98
|
+
"rimraf": "^6.0.1",
|
|
99
|
+
"rollup": "^4.0.0",
|
|
100
|
+
"rollup-plugin-dts": "^6.0.0",
|
|
101
|
+
"rollup-plugin-postcss": "^4.0.0",
|
|
102
|
+
"tailwindcss": "^3.4.17",
|
|
103
|
+
"tslib": "^2.8.1",
|
|
104
|
+
"typescript": "^5.2.0"
|
|
105
|
+
},
|
|
106
|
+
"keywords": [
|
|
107
|
+
"react",
|
|
108
|
+
"shadcn",
|
|
109
|
+
"tailwind",
|
|
110
|
+
"axios",
|
|
111
|
+
"ui-components"
|
|
112
|
+
],
|
|
113
|
+
"author": "Buildbase",
|
|
114
|
+
"license": "MIT",
|
|
115
|
+
"engines": {
|
|
116
|
+
"node": ">=16.0.0"
|
|
117
|
+
},
|
|
118
|
+
"publishConfig": {
|
|
119
|
+
"access": "public",
|
|
120
|
+
"registry": "https://registry.npmjs.org/"
|
|
121
|
+
}
|
|
122
|
+
}
|