@howone/sdk 0.6.0 → 0.7.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/dist/index.d.mts CHANGED
@@ -2,7 +2,7 @@ import React$1, { Component, ReactNode } from 'react';
2
2
  import * as axios from 'axios';
3
3
  import { AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig, AxiosInstance } from 'axios';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { GoeyToastOptions } from 'goey-toast';
5
+ import { ToastOptions } from 'react-toastify';
6
6
 
7
7
  interface FloatingButtonProps {
8
8
  text?: string;
@@ -56,6 +56,23 @@ interface BatchUploadResponse {
56
56
  total: number;
57
57
  }
58
58
 
59
+ type LimitExceededSource = "axios-response" | "workflow-executor-sse" | "workflow-executor-rest" | "sse-executor" | "ai-workflow";
60
+ interface LimitExceededContext {
61
+ source: LimitExceededSource;
62
+ message: string;
63
+ status?: number;
64
+ eventType?: string;
65
+ rawData?: unknown;
66
+ }
67
+ interface LimitExceededHandlerOptions {
68
+ onLimitExceeded?: (context: LimitExceededContext) => void;
69
+ showUpgradeToast?: boolean;
70
+ upgradeUrl?: string;
71
+ }
72
+ declare const DEFAULT_LIMIT_EXCEEDED_MESSAGE = "Your credits are exhausted. Please upgrade your plan to continue generating projects.";
73
+ declare function handleLimitExceeded(context: LimitExceededContext, options?: LimitExceededHandlerOptions): void;
74
+ declare function mergeLimitExceededOptions(base?: LimitExceededHandlerOptions, override?: LimitExceededHandlerOptions): LimitExceededHandlerOptions | undefined;
75
+
59
76
  /**
60
77
  * 统一的 SSE 工作流执行模块
61
78
  *
@@ -67,6 +84,7 @@ interface BatchUploadResponse {
67
84
  *
68
85
  * 提供统一的 API 给 client 使用
69
86
  */
87
+
70
88
  interface SSEEventPayload {
71
89
  type: string;
72
90
  data?: Record<string, unknown>;
@@ -103,6 +121,7 @@ interface SSEExecutionOptions {
103
121
  onError?: (error: Error) => void;
104
122
  onComplete?: (result: ExecutionResult) => void;
105
123
  signal?: AbortSignal;
124
+ limitExceeded?: LimitExceededHandlerOptions;
106
125
  }
107
126
  interface SSEWorkflowRequestInit {
108
127
  url: string;
@@ -158,6 +177,7 @@ interface SSEClientConfig {
158
177
  baseUrl: string;
159
178
  projectId?: string;
160
179
  getAuthToken?: () => string | null;
180
+ limitExceeded?: LimitExceededHandlerOptions;
161
181
  }
162
182
  interface SSEClient {
163
183
  /**
@@ -608,8 +628,9 @@ declare function getGlobalEnvironment(): Environment | null;
608
628
  * - POST /workflow/{projectId}/{workflowId}/execute (返回 SSE 流)
609
629
  * - 发送 JSON 格式的事件: data: {"type": "...", "data": {...}}
610
630
  */
631
+
611
632
  interface WorkflowStreamEvent {
612
- type: 'start' | 'progress' | 'stream' | 'log' | 'complete' | 'error';
633
+ type: 'start' | 'progress' | 'stream' | 'log' | 'complete' | 'error' | 'key_limit_exceed';
613
634
  data?: any;
614
635
  message?: string;
615
636
  progress?: number;
@@ -623,6 +644,7 @@ interface WorkflowStreamOptions {
623
644
  onLog?: (message: string) => void;
624
645
  onError?: (error: Error) => void;
625
646
  signal?: AbortSignal;
647
+ limitExceeded?: LimitExceededHandlerOptions;
626
648
  }
627
649
  interface WorkflowStreamResponse {
628
650
  success: boolean;
@@ -645,6 +667,7 @@ interface WorkflowStreamResponse {
645
667
  * - 统一的错误处理
646
668
  * - 支持所有事件类型
647
669
  */
670
+
648
671
  interface ExecutionLogData {
649
672
  log_type: 'node_start' | 'cost_update' | 'execution_complete' | 'stream' | 'log' | string;
650
673
  workflow_id: string;
@@ -695,6 +718,7 @@ interface WorkflowExecutorOptions {
695
718
  onComplete?: (result: ParsedWorkflowResult) => void;
696
719
  onError?: (error: Error) => void;
697
720
  signal?: AbortSignal;
721
+ limitExceeded?: LimitExceededHandlerOptions;
698
722
  }
699
723
  /**
700
724
  * 工作流执行器类
@@ -706,7 +730,8 @@ declare class WorkflowExecutor {
706
730
  private baseUrl;
707
731
  private projectId;
708
732
  private authToken?;
709
- constructor(baseUrl: string, projectId: string, authToken?: string);
733
+ private limitExceeded?;
734
+ constructor(baseUrl: string, projectId: string, authToken?: string, limitExceeded?: LimitExceededHandlerOptions);
710
735
  /**
711
736
  * 执行工作流 (SSE 模式)
712
737
  *
@@ -778,6 +803,7 @@ declare function createClient(opts: {
778
803
  env?: 'local' | 'dev' | 'prod';
779
804
  baseUrl?: string;
780
805
  authRequired?: boolean;
806
+ limitExceeded?: LimitExceededHandlerOptions;
781
807
  mode?: "auto" | "standalone" | "embedded";
782
808
  auth?: {
783
809
  mode?: "none" | "managed" | "headless";
@@ -1169,18 +1195,16 @@ declare function ThemeToggle({ className }: ThemeToggleProps): react_jsx_runtime
1169
1195
 
1170
1196
  declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
1171
1197
 
1172
- interface LegacyToastOptions {
1173
- autoClose?: number | false;
1174
- id?: string | number;
1175
- }
1198
+ type ToastType = "success" | "error" | "warning" | "info" | "default";
1176
1199
  interface ToastParams {
1177
1200
  title?: string;
1178
1201
  message?: string;
1179
1202
  render?: (closeToast: () => void) => React$1.ReactNode;
1180
1203
  component?: React$1.ReactNode;
1181
- options?: LegacyToastOptions & Partial<GoeyToastOptions>;
1204
+ options?: Partial<ToastOptions>;
1182
1205
  }
1183
- declare const GoeyToast: {
1206
+
1207
+ declare const ClayxToast: {
1184
1208
  success: (params: ToastParams) => void;
1185
1209
  error: (params: ToastParams) => void;
1186
1210
  warning: (params: ToastParams) => void;
@@ -1353,4 +1377,4 @@ declare const elementSelector: {
1353
1377
  isActive: () => boolean;
1354
1378
  };
1355
1379
 
1356
- export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, type BatchUploadOptions, type BatchUploadResponse, ClayxButton, type CostUpdate, DefaultErrorFallback, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type Environment, ErrorBoundary, type ExecutionResult, FloatingButton, type GenerateImageOptions, type GenerateImageResponse, GlobalToastContainer, GoeyToast, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type NodeExecution, type SSEClient, type SSEClientConfig, type SSEEventPayload, type SSEExecutionOptions, type SSERequest, type SSESession, type SSEStreamConfig, type SSEWorkflowOptions, type SSEWorkflowRequestInit, type SendCodeRequest, type SendCodeResponse, type SourceLocation, ThemeProvider, ThemeToggle, type UploadOptions, type UploadResponse, type UseElementSelectorReturn, type UseWorkflowStreamState, type Visibility, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, createSSEClient, createSSERequest, createUploadClient, elementSelector, type envs, executeSSEWorkflow, getCodeStatus, getDefaultProjectId, getEnvironment, getEnvs, getGlobalEnvironment, getToken, howone, iframeNavigation, initIframeNavigation, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, sendElementSelectionToParent, sendEmailVerificationCode, setDefaultProjectId, setEnvironment, setToken, showLimitUpgradeToast, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useElementSelector, useHowoneContext, useIsMobile, useTheme, useWorkflowStream };
1380
+ export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, type BatchUploadOptions, type BatchUploadResponse, ClayxButton, ClayxToast, type CostUpdate, DEFAULT_LIMIT_EXCEEDED_MESSAGE, DefaultErrorFallback, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type Environment, ErrorBoundary, type ExecutionResult, FloatingButton, type GenerateImageOptions, type GenerateImageResponse, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, type LimitExceededContext, type LimitExceededHandlerOptions, type LimitExceededSource, Loading, LoadingSpinner, LoginForm, type NodeExecution, type SSEClient, type SSEClientConfig, type SSEEventPayload, type SSEExecutionOptions, type SSERequest, type SSESession, type SSEStreamConfig, type SSEWorkflowOptions, type SSEWorkflowRequestInit, type SendCodeRequest, type SendCodeResponse, type SourceLocation, ThemeProvider, ThemeToggle, type ToastParams, type ToastType, type UploadOptions, type UploadResponse, type UseElementSelectorReturn, type UseWorkflowStreamState, type Visibility, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, createSSEClient, createSSERequest, createUploadClient, elementSelector, type envs, executeSSEWorkflow, getCodeStatus, getDefaultProjectId, getEnvironment, getEnvs, getGlobalEnvironment, getToken, handleLimitExceeded, howone, iframeNavigation, initIframeNavigation, isTokenValid, loginWithEmailCode, mergeLimitExceededOptions, onAuthStateChanged, parseUserFromToken, sendElementSelectionToParent, sendEmailVerificationCode, setDefaultProjectId, setEnvironment, setToken, showLimitUpgradeToast, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useElementSelector, useHowoneContext, useIsMobile, useTheme, useWorkflowStream };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import React$1, { Component, ReactNode } from 'react';
2
2
  import * as axios from 'axios';
3
3
  import { AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig, AxiosInstance } from 'axios';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import { GoeyToastOptions } from 'goey-toast';
5
+ import { ToastOptions } from 'react-toastify';
6
6
 
7
7
  interface FloatingButtonProps {
8
8
  text?: string;
@@ -56,6 +56,23 @@ interface BatchUploadResponse {
56
56
  total: number;
57
57
  }
58
58
 
59
+ type LimitExceededSource = "axios-response" | "workflow-executor-sse" | "workflow-executor-rest" | "sse-executor" | "ai-workflow";
60
+ interface LimitExceededContext {
61
+ source: LimitExceededSource;
62
+ message: string;
63
+ status?: number;
64
+ eventType?: string;
65
+ rawData?: unknown;
66
+ }
67
+ interface LimitExceededHandlerOptions {
68
+ onLimitExceeded?: (context: LimitExceededContext) => void;
69
+ showUpgradeToast?: boolean;
70
+ upgradeUrl?: string;
71
+ }
72
+ declare const DEFAULT_LIMIT_EXCEEDED_MESSAGE = "Your credits are exhausted. Please upgrade your plan to continue generating projects.";
73
+ declare function handleLimitExceeded(context: LimitExceededContext, options?: LimitExceededHandlerOptions): void;
74
+ declare function mergeLimitExceededOptions(base?: LimitExceededHandlerOptions, override?: LimitExceededHandlerOptions): LimitExceededHandlerOptions | undefined;
75
+
59
76
  /**
60
77
  * 统一的 SSE 工作流执行模块
61
78
  *
@@ -67,6 +84,7 @@ interface BatchUploadResponse {
67
84
  *
68
85
  * 提供统一的 API 给 client 使用
69
86
  */
87
+
70
88
  interface SSEEventPayload {
71
89
  type: string;
72
90
  data?: Record<string, unknown>;
@@ -103,6 +121,7 @@ interface SSEExecutionOptions {
103
121
  onError?: (error: Error) => void;
104
122
  onComplete?: (result: ExecutionResult) => void;
105
123
  signal?: AbortSignal;
124
+ limitExceeded?: LimitExceededHandlerOptions;
106
125
  }
107
126
  interface SSEWorkflowRequestInit {
108
127
  url: string;
@@ -158,6 +177,7 @@ interface SSEClientConfig {
158
177
  baseUrl: string;
159
178
  projectId?: string;
160
179
  getAuthToken?: () => string | null;
180
+ limitExceeded?: LimitExceededHandlerOptions;
161
181
  }
162
182
  interface SSEClient {
163
183
  /**
@@ -608,8 +628,9 @@ declare function getGlobalEnvironment(): Environment | null;
608
628
  * - POST /workflow/{projectId}/{workflowId}/execute (返回 SSE 流)
609
629
  * - 发送 JSON 格式的事件: data: {"type": "...", "data": {...}}
610
630
  */
631
+
611
632
  interface WorkflowStreamEvent {
612
- type: 'start' | 'progress' | 'stream' | 'log' | 'complete' | 'error';
633
+ type: 'start' | 'progress' | 'stream' | 'log' | 'complete' | 'error' | 'key_limit_exceed';
613
634
  data?: any;
614
635
  message?: string;
615
636
  progress?: number;
@@ -623,6 +644,7 @@ interface WorkflowStreamOptions {
623
644
  onLog?: (message: string) => void;
624
645
  onError?: (error: Error) => void;
625
646
  signal?: AbortSignal;
647
+ limitExceeded?: LimitExceededHandlerOptions;
626
648
  }
627
649
  interface WorkflowStreamResponse {
628
650
  success: boolean;
@@ -645,6 +667,7 @@ interface WorkflowStreamResponse {
645
667
  * - 统一的错误处理
646
668
  * - 支持所有事件类型
647
669
  */
670
+
648
671
  interface ExecutionLogData {
649
672
  log_type: 'node_start' | 'cost_update' | 'execution_complete' | 'stream' | 'log' | string;
650
673
  workflow_id: string;
@@ -695,6 +718,7 @@ interface WorkflowExecutorOptions {
695
718
  onComplete?: (result: ParsedWorkflowResult) => void;
696
719
  onError?: (error: Error) => void;
697
720
  signal?: AbortSignal;
721
+ limitExceeded?: LimitExceededHandlerOptions;
698
722
  }
699
723
  /**
700
724
  * 工作流执行器类
@@ -706,7 +730,8 @@ declare class WorkflowExecutor {
706
730
  private baseUrl;
707
731
  private projectId;
708
732
  private authToken?;
709
- constructor(baseUrl: string, projectId: string, authToken?: string);
733
+ private limitExceeded?;
734
+ constructor(baseUrl: string, projectId: string, authToken?: string, limitExceeded?: LimitExceededHandlerOptions);
710
735
  /**
711
736
  * 执行工作流 (SSE 模式)
712
737
  *
@@ -778,6 +803,7 @@ declare function createClient(opts: {
778
803
  env?: 'local' | 'dev' | 'prod';
779
804
  baseUrl?: string;
780
805
  authRequired?: boolean;
806
+ limitExceeded?: LimitExceededHandlerOptions;
781
807
  mode?: "auto" | "standalone" | "embedded";
782
808
  auth?: {
783
809
  mode?: "none" | "managed" | "headless";
@@ -1169,18 +1195,16 @@ declare function ThemeToggle({ className }: ThemeToggleProps): react_jsx_runtime
1169
1195
 
1170
1196
  declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
1171
1197
 
1172
- interface LegacyToastOptions {
1173
- autoClose?: number | false;
1174
- id?: string | number;
1175
- }
1198
+ type ToastType = "success" | "error" | "warning" | "info" | "default";
1176
1199
  interface ToastParams {
1177
1200
  title?: string;
1178
1201
  message?: string;
1179
1202
  render?: (closeToast: () => void) => React$1.ReactNode;
1180
1203
  component?: React$1.ReactNode;
1181
- options?: LegacyToastOptions & Partial<GoeyToastOptions>;
1204
+ options?: Partial<ToastOptions>;
1182
1205
  }
1183
- declare const GoeyToast: {
1206
+
1207
+ declare const ClayxToast: {
1184
1208
  success: (params: ToastParams) => void;
1185
1209
  error: (params: ToastParams) => void;
1186
1210
  warning: (params: ToastParams) => void;
@@ -1353,4 +1377,4 @@ declare const elementSelector: {
1353
1377
  isActive: () => boolean;
1354
1378
  };
1355
1379
 
1356
- export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, type BatchUploadOptions, type BatchUploadResponse, ClayxButton, type CostUpdate, DefaultErrorFallback, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type Environment, ErrorBoundary, type ExecutionResult, FloatingButton, type GenerateImageOptions, type GenerateImageResponse, GlobalToastContainer, GoeyToast, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type NodeExecution, type SSEClient, type SSEClientConfig, type SSEEventPayload, type SSEExecutionOptions, type SSERequest, type SSESession, type SSEStreamConfig, type SSEWorkflowOptions, type SSEWorkflowRequestInit, type SendCodeRequest, type SendCodeResponse, type SourceLocation, ThemeProvider, ThemeToggle, type UploadOptions, type UploadResponse, type UseElementSelectorReturn, type UseWorkflowStreamState, type Visibility, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, createSSEClient, createSSERequest, createUploadClient, elementSelector, type envs, executeSSEWorkflow, getCodeStatus, getDefaultProjectId, getEnvironment, getEnvs, getGlobalEnvironment, getToken, howone, iframeNavigation, initIframeNavigation, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, sendElementSelectionToParent, sendEmailVerificationCode, setDefaultProjectId, setEnvironment, setToken, showLimitUpgradeToast, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useElementSelector, useHowoneContext, useIsMobile, useTheme, useWorkflowStream };
1380
+ export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, type BatchUploadOptions, type BatchUploadResponse, ClayxButton, ClayxToast, type CostUpdate, DEFAULT_LIMIT_EXCEEDED_MESSAGE, DefaultErrorFallback, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type Environment, ErrorBoundary, type ExecutionResult, FloatingButton, type GenerateImageOptions, type GenerateImageResponse, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, type LimitExceededContext, type LimitExceededHandlerOptions, type LimitExceededSource, Loading, LoadingSpinner, LoginForm, type NodeExecution, type SSEClient, type SSEClientConfig, type SSEEventPayload, type SSEExecutionOptions, type SSERequest, type SSESession, type SSEStreamConfig, type SSEWorkflowOptions, type SSEWorkflowRequestInit, type SendCodeRequest, type SendCodeResponse, type SourceLocation, ThemeProvider, ThemeToggle, type ToastParams, type ToastType, type UploadOptions, type UploadResponse, type UseElementSelectorReturn, type UseWorkflowStreamState, type Visibility, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, createSSEClient, createSSERequest, createUploadClient, elementSelector, type envs, executeSSEWorkflow, getCodeStatus, getDefaultProjectId, getEnvironment, getEnvs, getGlobalEnvironment, getToken, handleLimitExceeded, howone, iframeNavigation, initIframeNavigation, isTokenValid, loginWithEmailCode, mergeLimitExceededOptions, onAuthStateChanged, parseUserFromToken, sendElementSelectionToParent, sendEmailVerificationCode, setDefaultProjectId, setEnvironment, setToken, showLimitUpgradeToast, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useElementSelector, useHowoneContext, useIsMobile, useTheme, useWorkflowStream };