@howone/sdk 0.1.17 → 0.1.19

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.mts CHANGED
@@ -1,13 +1,15 @@
1
- import React, { Component, ReactNode } from 'react';
1
+ import React$1, { Component, ReactNode } from 'react';
2
+ import * as axios from 'axios';
2
3
  import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
3
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { ToastOptions } from 'react-toastify';
4
6
 
5
7
  interface FloatingButtonProps {
6
8
  text?: string;
7
9
  onClick?: () => void;
8
10
  className?: string;
9
11
  }
10
- declare const FloatingButton: React.FC<FloatingButtonProps>;
12
+ declare const FloatingButton: React$1.FC<FloatingButtonProps>;
11
13
 
12
14
  /**
13
15
  * 统一认证服务
@@ -161,8 +163,8 @@ declare class UnifiedAuthService {
161
163
  }>;
162
164
  private getSavedAuthData;
163
165
  /**
164
- * 保存认证数据到本地存储
165
- */
166
+ * 保存认证数据到本地存储
167
+ */
166
168
  private saveAuthData;
167
169
  /**
168
170
  * 退出登录
@@ -359,9 +361,9 @@ declare function createClient(opts?: {
359
361
  authRequired?: boolean;
360
362
  baseUrl?: string;
361
363
  aiBaseUrl?: string;
362
- mode?: 'auto' | 'standalone' | 'embedded';
364
+ mode?: "auto" | "standalone" | "embedded";
363
365
  auth?: {
364
- mode?: 'none' | 'managed' | 'headless';
366
+ mode?: "none" | "managed" | "headless";
365
367
  getToken?: () => Promise<string | null>;
366
368
  tokenInjection?: {
367
369
  allowedOrigins?: string[];
@@ -375,7 +377,17 @@ declare function createClient(opts?: {
375
377
  aiRequestInstance?: Request;
376
378
  }): {
377
379
  projectId: string | null;
378
- request: any;
380
+ request: {
381
+ instance: axios.AxiosInstance;
382
+ request: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
383
+ get: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
384
+ post: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
385
+ put: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
386
+ patch: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
387
+ delete: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
388
+ cancelRequest: (url: string) => void;
389
+ cancelAllRequests: () => void;
390
+ };
379
391
  aiRequest: Request;
380
392
  workflowRequest: Request;
381
393
  artifacts: {
@@ -409,7 +421,7 @@ interface LoginFormProps {
409
421
  appName?: string;
410
422
  className?: string;
411
423
  }
412
- declare const LoginForm: React.FC<LoginFormProps>;
424
+ declare const LoginForm: React$1.FC<LoginFormProps>;
413
425
 
414
426
  type AuthContextValue = {
415
427
  user: ReturnType<typeof parseUserFromToken> | null;
@@ -417,8 +429,8 @@ type AuthContextValue = {
417
429
  isAuthenticated: boolean;
418
430
  logout: () => void;
419
431
  };
420
- declare const AuthProvider: React.FC<{
421
- children: React.ReactNode;
432
+ declare const AuthProvider: React$1.FC<{
433
+ children: React$1.ReactNode;
422
434
  autoRedirect?: boolean;
423
435
  showFloatingButton?: boolean;
424
436
  projectId?: string;
@@ -454,50 +466,81 @@ interface LoadingProps {
454
466
  className?: string;
455
467
  fullScreen?: boolean;
456
468
  }
457
- declare const Loading: React.FC<LoadingProps>;
469
+ declare const Loading: React$1.FC<LoadingProps>;
458
470
  interface LoadingSpinnerProps {
459
471
  size?: 'sm' | 'md' | 'lg';
460
472
  className?: string;
461
473
  }
462
- declare const LoadingSpinner: React.FC<LoadingSpinnerProps>;
474
+ declare const LoadingSpinner: React$1.FC<LoadingSpinnerProps>;
463
475
 
464
476
  interface ErrorBoundaryState {
465
477
  hasError: boolean;
466
478
  error?: Error;
467
- errorInfo?: React.ErrorInfo;
479
+ errorInfo?: React$1.ErrorInfo;
468
480
  }
469
481
  interface ErrorBoundaryProps {
470
482
  children: ReactNode;
471
- fallback?: React.ComponentType<{
483
+ fallback?: React$1.ComponentType<{
472
484
  error?: Error;
473
485
  retry?: () => void;
474
486
  }>;
475
- onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
487
+ onError?: (error: Error, errorInfo: React$1.ErrorInfo) => void;
476
488
  }
477
489
  declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
478
490
  constructor(props: ErrorBoundaryProps);
479
491
  static getDerivedStateFromError(error: Error): ErrorBoundaryState;
480
- componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
492
+ componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
481
493
  handleRetry: () => void;
482
- render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | null | undefined;
494
+ render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React$1.ReactNode> | null | undefined;
483
495
  }
484
496
  interface ErrorFallbackProps {
485
497
  error?: Error;
486
498
  retry?: () => void;
487
499
  }
488
- declare const DefaultErrorFallback: React.FC<ErrorFallbackProps>;
500
+ declare const DefaultErrorFallback: React$1.FC<ErrorFallbackProps>;
501
+
502
+ type Theme = "dark" | "light" | "system";
503
+ type ThemeProviderProps = {
504
+ children: React.ReactNode;
505
+ defaultTheme?: Theme;
506
+ storageKey?: string;
507
+ };
508
+ type ThemeProviderState = {
509
+ theme: Theme;
510
+ setTheme: (theme: Theme) => void;
511
+ };
512
+ declare function ThemeProvider({ children, defaultTheme, storageKey, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
513
+ declare const useTheme: () => ThemeProviderState;
514
+
515
+ interface ThemeToggleProps {
516
+ className?: string;
517
+ }
518
+ declare function ThemeToggle({ className }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
519
+
520
+ declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
521
+
522
+ interface ToastParams {
523
+ title?: string;
524
+ message?: string;
525
+ component?: React$1.ReactNode;
526
+ options?: Partial<ToastOptions>;
527
+ }
528
+ declare const ClayxToast: {
529
+ success: (params: ToastParams) => void;
530
+ error: (params: ToastParams) => void;
531
+ warning: (params: ToastParams) => void;
532
+ info: (params: ToastParams) => void;
533
+ default: (params: ToastParams) => void;
534
+ };
489
535
 
490
536
  declare function useIsMobile(): boolean;
491
537
 
492
538
  declare function useDebounce<T>(value: T, delay: number): T;
493
539
 
494
540
  /**
495
- * Early error handler injector
496
- * This module provides a runtime function to inject the original
497
- * `error-handler.js` script into the page. The script is executed
498
- * as soon as it's injected, providing early capture of runtime and
499
- * Vite overlay errors for the host app.
541
+ * 在页面尽早注入错误处理脚本。
542
+ * 调用时机:应在应用入口尽早执行(例如在 root render 之前)。
500
543
  */
501
544
  declare function injectEarlyErrorHandler(): void;
502
545
 
503
- export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AxiosAIWorkflowOptions, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useAuthContext, useDebounce, useIsMobile, workflowRequest };
546
+ export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, ThemeProvider, ThemeToggle, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useAuthContext, useDebounce, useIsMobile, useTheme, workflowRequest };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,15 @@
1
- import React, { Component, ReactNode } from 'react';
1
+ import React$1, { Component, ReactNode } from 'react';
2
+ import * as axios from 'axios';
2
3
  import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
3
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { ToastOptions } from 'react-toastify';
4
6
 
5
7
  interface FloatingButtonProps {
6
8
  text?: string;
7
9
  onClick?: () => void;
8
10
  className?: string;
9
11
  }
10
- declare const FloatingButton: React.FC<FloatingButtonProps>;
12
+ declare const FloatingButton: React$1.FC<FloatingButtonProps>;
11
13
 
12
14
  /**
13
15
  * 统一认证服务
@@ -161,8 +163,8 @@ declare class UnifiedAuthService {
161
163
  }>;
162
164
  private getSavedAuthData;
163
165
  /**
164
- * 保存认证数据到本地存储
165
- */
166
+ * 保存认证数据到本地存储
167
+ */
166
168
  private saveAuthData;
167
169
  /**
168
170
  * 退出登录
@@ -359,9 +361,9 @@ declare function createClient(opts?: {
359
361
  authRequired?: boolean;
360
362
  baseUrl?: string;
361
363
  aiBaseUrl?: string;
362
- mode?: 'auto' | 'standalone' | 'embedded';
364
+ mode?: "auto" | "standalone" | "embedded";
363
365
  auth?: {
364
- mode?: 'none' | 'managed' | 'headless';
366
+ mode?: "none" | "managed" | "headless";
365
367
  getToken?: () => Promise<string | null>;
366
368
  tokenInjection?: {
367
369
  allowedOrigins?: string[];
@@ -375,7 +377,17 @@ declare function createClient(opts?: {
375
377
  aiRequestInstance?: Request;
376
378
  }): {
377
379
  projectId: string | null;
378
- request: any;
380
+ request: {
381
+ instance: axios.AxiosInstance;
382
+ request: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
383
+ get: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
384
+ post: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
385
+ put: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
386
+ patch: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
387
+ delete: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
388
+ cancelRequest: (url: string) => void;
389
+ cancelAllRequests: () => void;
390
+ };
379
391
  aiRequest: Request;
380
392
  workflowRequest: Request;
381
393
  artifacts: {
@@ -409,7 +421,7 @@ interface LoginFormProps {
409
421
  appName?: string;
410
422
  className?: string;
411
423
  }
412
- declare const LoginForm: React.FC<LoginFormProps>;
424
+ declare const LoginForm: React$1.FC<LoginFormProps>;
413
425
 
414
426
  type AuthContextValue = {
415
427
  user: ReturnType<typeof parseUserFromToken> | null;
@@ -417,8 +429,8 @@ type AuthContextValue = {
417
429
  isAuthenticated: boolean;
418
430
  logout: () => void;
419
431
  };
420
- declare const AuthProvider: React.FC<{
421
- children: React.ReactNode;
432
+ declare const AuthProvider: React$1.FC<{
433
+ children: React$1.ReactNode;
422
434
  autoRedirect?: boolean;
423
435
  showFloatingButton?: boolean;
424
436
  projectId?: string;
@@ -454,50 +466,81 @@ interface LoadingProps {
454
466
  className?: string;
455
467
  fullScreen?: boolean;
456
468
  }
457
- declare const Loading: React.FC<LoadingProps>;
469
+ declare const Loading: React$1.FC<LoadingProps>;
458
470
  interface LoadingSpinnerProps {
459
471
  size?: 'sm' | 'md' | 'lg';
460
472
  className?: string;
461
473
  }
462
- declare const LoadingSpinner: React.FC<LoadingSpinnerProps>;
474
+ declare const LoadingSpinner: React$1.FC<LoadingSpinnerProps>;
463
475
 
464
476
  interface ErrorBoundaryState {
465
477
  hasError: boolean;
466
478
  error?: Error;
467
- errorInfo?: React.ErrorInfo;
479
+ errorInfo?: React$1.ErrorInfo;
468
480
  }
469
481
  interface ErrorBoundaryProps {
470
482
  children: ReactNode;
471
- fallback?: React.ComponentType<{
483
+ fallback?: React$1.ComponentType<{
472
484
  error?: Error;
473
485
  retry?: () => void;
474
486
  }>;
475
- onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
487
+ onError?: (error: Error, errorInfo: React$1.ErrorInfo) => void;
476
488
  }
477
489
  declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
478
490
  constructor(props: ErrorBoundaryProps);
479
491
  static getDerivedStateFromError(error: Error): ErrorBoundaryState;
480
- componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
492
+ componentDidCatch(error: Error, errorInfo: React$1.ErrorInfo): void;
481
493
  handleRetry: () => void;
482
- render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | null | undefined;
494
+ render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React$1.ReactNode> | null | undefined;
483
495
  }
484
496
  interface ErrorFallbackProps {
485
497
  error?: Error;
486
498
  retry?: () => void;
487
499
  }
488
- declare const DefaultErrorFallback: React.FC<ErrorFallbackProps>;
500
+ declare const DefaultErrorFallback: React$1.FC<ErrorFallbackProps>;
501
+
502
+ type Theme = "dark" | "light" | "system";
503
+ type ThemeProviderProps = {
504
+ children: React.ReactNode;
505
+ defaultTheme?: Theme;
506
+ storageKey?: string;
507
+ };
508
+ type ThemeProviderState = {
509
+ theme: Theme;
510
+ setTheme: (theme: Theme) => void;
511
+ };
512
+ declare function ThemeProvider({ children, defaultTheme, storageKey, ...props }: ThemeProviderProps): react_jsx_runtime.JSX.Element;
513
+ declare const useTheme: () => ThemeProviderState;
514
+
515
+ interface ThemeToggleProps {
516
+ className?: string;
517
+ }
518
+ declare function ThemeToggle({ className }: ThemeToggleProps): react_jsx_runtime.JSX.Element;
519
+
520
+ declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
521
+
522
+ interface ToastParams {
523
+ title?: string;
524
+ message?: string;
525
+ component?: React$1.ReactNode;
526
+ options?: Partial<ToastOptions>;
527
+ }
528
+ declare const ClayxToast: {
529
+ success: (params: ToastParams) => void;
530
+ error: (params: ToastParams) => void;
531
+ warning: (params: ToastParams) => void;
532
+ info: (params: ToastParams) => void;
533
+ default: (params: ToastParams) => void;
534
+ };
489
535
 
490
536
  declare function useIsMobile(): boolean;
491
537
 
492
538
  declare function useDebounce<T>(value: T, delay: number): T;
493
539
 
494
540
  /**
495
- * Early error handler injector
496
- * This module provides a runtime function to inject the original
497
- * `error-handler.js` script into the page. The script is executed
498
- * as soon as it's injected, providing early capture of runtime and
499
- * Vite overlay errors for the host app.
541
+ * 在页面尽早注入错误处理脚本。
542
+ * 调用时机:应在应用入口尽早执行(例如在 root render 之前)。
500
543
  */
501
544
  declare function injectEarlyErrorHandler(): void;
502
545
 
503
- export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AxiosAIWorkflowOptions, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useAuthContext, useDebounce, useIsMobile, workflowRequest };
546
+ export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthProvider, type AxiosAIWorkflowOptions, ClayxToast, DefaultErrorFallback, type EmailLoginRequest, type EmailLoginResponse, ErrorBoundary, FloatingButton, GlobalToastContainer, Loading, LoadingSpinner, LoginForm, type SendCodeRequest, type SendCodeResponse, ThemeProvider, ThemeToggle, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, injectEarlyErrorHandler, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useAuthContext, useDebounce, useIsMobile, useTheme, workflowRequest };