@howone/sdk 0.7.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 +29 -3
- package/dist/index.d.ts +29 -3
- package/dist/index.js +499 -440
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +496 -440
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -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
|
-
|
|
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";
|
|
@@ -1351,4 +1377,4 @@ declare const elementSelector: {
|
|
|
1351
1377
|
isActive: () => boolean;
|
|
1352
1378
|
};
|
|
1353
1379
|
|
|
1354
|
-
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, DefaultErrorFallback, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type Environment, ErrorBoundary, type ExecutionResult, FloatingButton, type GenerateImageOptions, type GenerateImageResponse, GlobalToastContainer, 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 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, 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
|
@@ -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
|
-
|
|
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";
|
|
@@ -1351,4 +1377,4 @@ declare const elementSelector: {
|
|
|
1351
1377
|
isActive: () => boolean;
|
|
1352
1378
|
};
|
|
1353
1379
|
|
|
1354
|
-
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, DefaultErrorFallback, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type Environment, ErrorBoundary, type ExecutionResult, FloatingButton, type GenerateImageOptions, type GenerateImageResponse, GlobalToastContainer, 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 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, 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 };
|