@buildbase/sdk 0.0.7 → 0.0.9
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 +795 -36
- package/dist/index.d.ts +120 -3
- package/dist/index.esm.js +11 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/saas-os.css +2 -2
- package/dist/types/api/types.d.ts +1 -0
- package/dist/types/components/ErrorBoundary.d.ts +34 -0
- package/dist/types/components/features/index.d.ts +2 -0
- package/dist/types/components/ui/command.d.ts +7 -7
- package/dist/types/index.d.ts +5 -1
- package/dist/types/lib/error-handler.d.ts +60 -0
- package/dist/types/providers/auth/hooks.d.ts +1 -0
- package/dist/types/providers/user/hooks.d.ts +8 -0
- package/dist/types/providers/user/provider.d.ts +17 -0
- package/dist/types/providers/workspace/WorkspaceSettingsProvider.d.ts +9 -0
- package/dist/types/providers/workspace/settings-manager.d.ts +36 -0
- package/dist/types/providers/workspace/ui/SettingsDialog.d.ts +12 -3
- package/dist/types/providers/workspace/utils.d.ts +20 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import react__default, { ReactNode } from 'react';
|
|
2
|
+
import react__default, { ReactNode, Component } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
5
|
interface IDocument {
|
|
@@ -19,6 +19,7 @@ interface IUser extends IDocument {
|
|
|
19
19
|
timezone: string;
|
|
20
20
|
language: string;
|
|
21
21
|
currency: string;
|
|
22
|
+
attributes?: Record<string, string | number | boolean>;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
interface IWorkspace {
|
|
@@ -222,6 +223,8 @@ interface IProps {
|
|
|
222
223
|
}
|
|
223
224
|
declare const WhenWorkspaceFeatureEnabled: (props: IProps) => react.ReactNode;
|
|
224
225
|
declare const WhenWorkspaceFeatureDisabled: (props: IProps) => react.ReactNode;
|
|
226
|
+
declare const WhenUserFeatureEnabled: (props: IProps) => react.ReactNode;
|
|
227
|
+
declare const WhenUserFeatureDisabled: (props: IProps) => react.ReactNode;
|
|
225
228
|
|
|
226
229
|
declare function useSaaSAuth(): {
|
|
227
230
|
user: AuthUser | undefined;
|
|
@@ -232,6 +235,7 @@ declare function useSaaSAuth(): {
|
|
|
232
235
|
status: AuthStatus;
|
|
233
236
|
signIn: () => Promise<void>;
|
|
234
237
|
signOut: () => Promise<void>;
|
|
238
|
+
openWorkspaceSettings: (section?: "profile" | "general" | "users" | "features" | "danger") => void;
|
|
235
239
|
};
|
|
236
240
|
|
|
237
241
|
declare function useSaaSSettings(): {
|
|
@@ -239,6 +243,26 @@ declare function useSaaSSettings(): {
|
|
|
239
243
|
getSettings: () => Promise<ISettings | null>;
|
|
240
244
|
};
|
|
241
245
|
|
|
246
|
+
interface UserContextValue {
|
|
247
|
+
attributes: Record<string, string | number | boolean>;
|
|
248
|
+
features: Record<string, boolean>;
|
|
249
|
+
isLoading: boolean;
|
|
250
|
+
error: Error | null;
|
|
251
|
+
updateAttributes: (updates: Record<string, string | number | boolean>) => Promise<IUser>;
|
|
252
|
+
updateAttribute: (attributeKey: string, value: string | number | boolean) => Promise<IUser>;
|
|
253
|
+
refreshAttributes: () => Promise<void>;
|
|
254
|
+
refreshFeatures: () => Promise<void>;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
declare function useUserAttributes(): UserContextValue;
|
|
258
|
+
declare function useUserFeatures(): {
|
|
259
|
+
features: Record<string, boolean>;
|
|
260
|
+
isLoading: boolean;
|
|
261
|
+
error: Error | null;
|
|
262
|
+
refreshFeatures: () => Promise<void>;
|
|
263
|
+
isFeatureEnabled: (featureId: string) => boolean;
|
|
264
|
+
};
|
|
265
|
+
|
|
242
266
|
declare function WorkspaceSwitcher(props: {
|
|
243
267
|
trigger: (isLoading: boolean, currentWorkspace: IWorkspace | null) => ReactNode;
|
|
244
268
|
onWorkspaceChange: (workspace: IWorkspace) => Promise<void>;
|
|
@@ -364,5 +388,98 @@ declare class EventEmitter {
|
|
|
364
388
|
}
|
|
365
389
|
declare const eventEmitter: EventEmitter;
|
|
366
390
|
|
|
367
|
-
|
|
368
|
-
|
|
391
|
+
interface ErrorBoundaryProps {
|
|
392
|
+
children: ReactNode;
|
|
393
|
+
/**
|
|
394
|
+
* Fallback UI to render when an error occurs
|
|
395
|
+
*/
|
|
396
|
+
fallback?: ReactNode | ((error: Error, resetError: () => void) => ReactNode);
|
|
397
|
+
/**
|
|
398
|
+
* Called when an error is caught
|
|
399
|
+
*/
|
|
400
|
+
onError?: (error: Error, errorInfo: react__default.ErrorInfo) => void;
|
|
401
|
+
/**
|
|
402
|
+
* Whether to reset error state when children change
|
|
403
|
+
* @default true
|
|
404
|
+
*/
|
|
405
|
+
resetOnPropsChange?: boolean;
|
|
406
|
+
}
|
|
407
|
+
interface ErrorBoundaryState {
|
|
408
|
+
hasError: boolean;
|
|
409
|
+
error: Error | null;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* Error Boundary component for catching React component errors
|
|
413
|
+
* Wraps SDK components to prevent crashes from propagating
|
|
414
|
+
*/
|
|
415
|
+
declare class SDKErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
416
|
+
constructor(props: ErrorBoundaryProps);
|
|
417
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
418
|
+
componentDidCatch(error: Error, errorInfo: react__default.ErrorInfo): void;
|
|
419
|
+
componentDidUpdate(prevProps: ErrorBoundaryProps): void;
|
|
420
|
+
resetError: () => void;
|
|
421
|
+
render(): ReactNode;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Centralized Error Handler for SDK
|
|
426
|
+
* Provides consistent error handling, logging, and user-facing error management
|
|
427
|
+
*/
|
|
428
|
+
interface SDKErrorContext {
|
|
429
|
+
component?: string;
|
|
430
|
+
action?: string;
|
|
431
|
+
metadata?: Record<string, unknown>;
|
|
432
|
+
}
|
|
433
|
+
declare class SDKError extends Error {
|
|
434
|
+
readonly code?: string | undefined;
|
|
435
|
+
readonly context?: SDKErrorContext | undefined;
|
|
436
|
+
readonly originalError?: Error | undefined;
|
|
437
|
+
constructor(message: string, code?: string | undefined, context?: SDKErrorContext | undefined, originalError?: Error | undefined);
|
|
438
|
+
}
|
|
439
|
+
interface ErrorHandlerConfig {
|
|
440
|
+
/**
|
|
441
|
+
* Custom error callback for handling errors
|
|
442
|
+
* @param error - The error that occurred
|
|
443
|
+
* @param context - Additional context about where the error occurred
|
|
444
|
+
*/
|
|
445
|
+
onError?: (error: Error, context: SDKErrorContext) => void;
|
|
446
|
+
/**
|
|
447
|
+
* Whether to log errors to console in development
|
|
448
|
+
* @default true
|
|
449
|
+
*/
|
|
450
|
+
enableConsoleLogging?: boolean;
|
|
451
|
+
/**
|
|
452
|
+
* Whether to show user-facing error notifications
|
|
453
|
+
* @default false
|
|
454
|
+
*/
|
|
455
|
+
showUserNotifications?: boolean;
|
|
456
|
+
}
|
|
457
|
+
declare class ErrorHandler {
|
|
458
|
+
private config;
|
|
459
|
+
/**
|
|
460
|
+
* Configure the error handler
|
|
461
|
+
*/
|
|
462
|
+
configure(config: Partial<ErrorHandlerConfig>): void;
|
|
463
|
+
/**
|
|
464
|
+
* Handle an error with context
|
|
465
|
+
*/
|
|
466
|
+
handleError(error: Error | unknown, context?: SDKErrorContext): void;
|
|
467
|
+
/**
|
|
468
|
+
* Notify user of error (placeholder for notification system)
|
|
469
|
+
*/
|
|
470
|
+
private notifyUser;
|
|
471
|
+
/**
|
|
472
|
+
* Create a safe error handler wrapper for async functions
|
|
473
|
+
*/
|
|
474
|
+
wrapAsync<T extends (...args: any[]) => Promise<any>>(fn: T, context: SDKErrorContext): T;
|
|
475
|
+
/**
|
|
476
|
+
* Create a safe error handler wrapper for sync functions
|
|
477
|
+
*/
|
|
478
|
+
wrapSync<T extends (...args: any[]) => any>(fn: T, context: SDKErrorContext): T;
|
|
479
|
+
}
|
|
480
|
+
declare const errorHandler: ErrorHandler;
|
|
481
|
+
declare function handleError(error: Error | unknown, context?: SDKErrorContext): void;
|
|
482
|
+
declare function createSDKError(message: string, code?: string, context?: SDKErrorContext, originalError?: Error): SDKError;
|
|
483
|
+
|
|
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 };
|