@howone/sdk 0.1.0
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 +129 -0
- package/dist/index.d.mts +434 -0
- package/dist/index.d.ts +434 -0
- package/dist/index.js +1499 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1438 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# HowOne Client Library
|
|
2
|
+
|
|
3
|
+
A comprehensive client library for AI templates with reusable components, hooks, and services.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
### Auth Components
|
|
8
|
+
|
|
9
|
+
#### LoginForm
|
|
10
|
+
|
|
11
|
+
A simplified login form component with email/code authentication and social login buttons.
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { LoginForm } from "howone-client";
|
|
15
|
+
|
|
16
|
+
function LoginPage() {
|
|
17
|
+
return <LoginForm />;
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
# @howone/sdk — Howone 客户端(中文使用手册)
|
|
22
|
+
|
|
23
|
+
本包为 Howone 提供前端 SDK,公开用于创建客户端实例的工厂函数:`createClient`。
|
|
24
|
+
|
|
25
|
+
本说明以 `createClient` 为中心,示例展示如何通过 `createClient` 创建并使用客户端实例来调用业务 API、执行 AI workflow、管理 token 与操作 artifacts。
|
|
26
|
+
|
|
27
|
+
目录
|
|
28
|
+
|
|
29
|
+
- 快速概览
|
|
30
|
+
- 安装
|
|
31
|
+
- 快速开始(以 howone 为主)
|
|
32
|
+
- howone 对象详解
|
|
33
|
+
- Auth / token 注入(iframe 与 standalone)
|
|
34
|
+
- Artifacts 使用
|
|
35
|
+
- 进阶指引与常见问题
|
|
36
|
+
- 开发与构建
|
|
37
|
+
|
|
38
|
+
## 快速概览
|
|
39
|
+
|
|
40
|
+
@howone/sdk — Howone 客户端(简明使用手册)
|
|
41
|
+
|
|
42
|
+
本包提供 Howone 前端 SDK 的核心工厂:`createClient`,用于创建并配置客户端实例。
|
|
43
|
+
|
|
44
|
+
## 快速概览
|
|
45
|
+
|
|
46
|
+
- `createClient(opts)`:创建自定义客户端实例(包含 `request`、`workflowRequest`、`executeWorkflow`、`artifacts`、`auth`)。
|
|
47
|
+
|
|
48
|
+
## 安装
|
|
49
|
+
|
|
50
|
+
工作区(monorepo)开发:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pnpm -w install
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
外部项目:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pnpm add @howone/sdk
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## 快速开始
|
|
63
|
+
|
|
64
|
+
在应用启动时创建并使用客户端实例:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { createClient } from "@howone/sdk";
|
|
68
|
+
|
|
69
|
+
const client = createClient({
|
|
70
|
+
projectId: "demo",
|
|
71
|
+
baseUrl: "https://your-business.api",
|
|
72
|
+
aiBaseUrl: "https://your-ai.api",
|
|
73
|
+
authRequired: false,
|
|
74
|
+
auth: {
|
|
75
|
+
getToken: async () => localStorage.getItem("howone_token") ?? null,
|
|
76
|
+
tokenInjection: {
|
|
77
|
+
allowedOrigins: ["https://parent.example.com"],
|
|
78
|
+
waitMs: 3000,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// 业务请求
|
|
84
|
+
await client.request.post({ url: "/items", data: { name: "hello" } });
|
|
85
|
+
|
|
86
|
+
// 执行 AI workflow(使用 workflowRequest)
|
|
87
|
+
// 直接调用独立的 AI 请求实例,POST 到 /workflow/{id}/execute
|
|
88
|
+
await client.workflowRequest.post({
|
|
89
|
+
url: `/workflow/${encodeURIComponent("workflow-id")}/execute`,
|
|
90
|
+
data: { input: { text: "hi" } },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Auth helper
|
|
94
|
+
client.auth.setToken("Bearer xxx");
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## API 概览
|
|
98
|
+
|
|
99
|
+
- `client.request` — 业务 API 的 Request 实例(基于 axios 的包装器)。
|
|
100
|
+
- `client.workflowRequest` — AI workflow 的 Request 实例(独立于业务 API)。
|
|
101
|
+
- `client.workflowRequest` — 用于直接调用 AI workflow 后端,请构造 POST 到 `/workflow/{id}/execute`(或使用 `createAIWorkflowClientAxios` / `createAIWorkflowClient` 提供的高阶 helper)。
|
|
102
|
+
- `client.artifacts` — artifacts 客户端:{ create, list, get, setVisibility, delete }。
|
|
103
|
+
- `client.auth` — 轻量 auth 辅助:{ setToken, getToken, isAuthenticated, login, logout }。
|
|
104
|
+
|
|
105
|
+
## Auth / token 注入
|
|
106
|
+
|
|
107
|
+
初始化 token 优先级(createClient 默认行为):
|
|
108
|
+
|
|
109
|
+
1. `auth.getToken()` 回调(最高优先级)
|
|
110
|
+
2. 嵌入式场景下的父页面 postMessage 注入(当配置了 `auth.tokenInjection`)
|
|
111
|
+
3. 否则不自动设置 token,需手动 `client.auth.setToken`
|
|
112
|
+
|
|
113
|
+
注意:SDK 只在内存中写入 axios header;持久化请在 `getToken`/`setToken` 中实现或使用后端 HttpOnly cookie。
|
|
114
|
+
|
|
115
|
+
## 开发与构建
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pnpm -w install
|
|
119
|
+
pnpm -w -F @howone/sdk build
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 代码结构(快速浏览)
|
|
123
|
+
|
|
124
|
+
- `src/services/index.ts` — createClient 与请求实例构造
|
|
125
|
+
- `src/services/ai-workflow.ts` / `ai-workflow-axios.ts` — AI workflow 客户端实现
|
|
126
|
+
- `src/services/artifacts-client.ts` — artifacts 封装
|
|
127
|
+
|
|
128
|
+
如需完整示例(iframe 注入、redirect 登录、后端交换)请告知,我可以把示例代码直接添加到 template。
|
|
129
|
+
工作区内(monorepo):
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
import React, { Component, ReactNode } from 'react';
|
|
2
|
+
import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
interface FloatingButtonProps {
|
|
6
|
+
text?: string;
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const FloatingButton: React.FC<FloatingButtonProps>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 统一认证服务
|
|
14
|
+
*
|
|
15
|
+
* 提供多种认证功能,包括:
|
|
16
|
+
* - Google OAuth 认证
|
|
17
|
+
* - GitHub OAuth 认证
|
|
18
|
+
* - 邮箱验证码认证
|
|
19
|
+
* - Token 验证和管理
|
|
20
|
+
* - 退出登录
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* 发送验证码请求接口
|
|
24
|
+
*/
|
|
25
|
+
interface SendCodeRequest {
|
|
26
|
+
/** 邮箱地址 */
|
|
27
|
+
email: string;
|
|
28
|
+
/** 来源 URL */
|
|
29
|
+
from_url: string;
|
|
30
|
+
/** 应用 ID(可选) */
|
|
31
|
+
app_id?: string;
|
|
32
|
+
/** 应用名称(可选) */
|
|
33
|
+
app_name?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 发送验证码响应接口
|
|
37
|
+
*/
|
|
38
|
+
interface SendCodeResponse {
|
|
39
|
+
/** 是否成功 */
|
|
40
|
+
success: boolean;
|
|
41
|
+
/** 消息(可选) */
|
|
42
|
+
message?: string;
|
|
43
|
+
/** 过期时间(秒)(可选) */
|
|
44
|
+
expiresIn?: number;
|
|
45
|
+
/** 状态码(可选,用于处理业务逻辑错误) */
|
|
46
|
+
code?: number;
|
|
47
|
+
/** 数据对象(可选,用于处理业务逻辑错误) */
|
|
48
|
+
data?: {
|
|
49
|
+
success: boolean;
|
|
50
|
+
message?: string;
|
|
51
|
+
code?: number;
|
|
52
|
+
};
|
|
53
|
+
/** 追踪 ID(可选) */
|
|
54
|
+
traceId?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 邮箱登录请求接口
|
|
58
|
+
*/
|
|
59
|
+
interface EmailLoginRequest {
|
|
60
|
+
/** 邮箱地址 */
|
|
61
|
+
email: string;
|
|
62
|
+
/** 验证码 */
|
|
63
|
+
code: string;
|
|
64
|
+
/** 来源 URL */
|
|
65
|
+
from_url: string;
|
|
66
|
+
/** 应用 ID(可选) */
|
|
67
|
+
app_id?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 邮箱登录响应接口
|
|
71
|
+
*/
|
|
72
|
+
interface EmailLoginResponse {
|
|
73
|
+
/** 是否成功 */
|
|
74
|
+
success: boolean;
|
|
75
|
+
/** JWT token(可选) */
|
|
76
|
+
token?: string;
|
|
77
|
+
/** 用户信息(可选) */
|
|
78
|
+
user?: {
|
|
79
|
+
email: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
};
|
|
82
|
+
/** 重定向 URL(可选) */
|
|
83
|
+
redirect_url?: string;
|
|
84
|
+
/** 消息(可选) */
|
|
85
|
+
message?: string;
|
|
86
|
+
/** 状态码(可选,用于处理业务逻辑错误) */
|
|
87
|
+
code?: number;
|
|
88
|
+
/** 数据对象(可选,用于处理业务逻辑错误) */
|
|
89
|
+
data?: {
|
|
90
|
+
success: boolean;
|
|
91
|
+
message?: string;
|
|
92
|
+
code?: number;
|
|
93
|
+
};
|
|
94
|
+
/** 追踪 ID(可选) */
|
|
95
|
+
traceId?: number;
|
|
96
|
+
}
|
|
97
|
+
declare class UnifiedAuthService {
|
|
98
|
+
private readonly API_BASE_URL;
|
|
99
|
+
/**
|
|
100
|
+
* 初始化 Google 登录流程
|
|
101
|
+
* @returns 包含 token 和用户信息的 Promise
|
|
102
|
+
*/
|
|
103
|
+
initiateGoogleLogin(): Promise<{
|
|
104
|
+
token: string;
|
|
105
|
+
user?: any;
|
|
106
|
+
}>;
|
|
107
|
+
/**
|
|
108
|
+
* 打开 OAuth 认证弹窗
|
|
109
|
+
* @param authUrl 认证 URL
|
|
110
|
+
* @returns 包含 token 和用户信息的 Promise
|
|
111
|
+
*/
|
|
112
|
+
private openOAuthPopup;
|
|
113
|
+
/**
|
|
114
|
+
* 初始化 GitHub 登录流程
|
|
115
|
+
* @returns 包含 token 和用户信息的 Promise
|
|
116
|
+
*/
|
|
117
|
+
initiateGitHubLogin(): Promise<{
|
|
118
|
+
token: string;
|
|
119
|
+
user?: any;
|
|
120
|
+
}>;
|
|
121
|
+
/**
|
|
122
|
+
* 发送邮箱验证码
|
|
123
|
+
* @param email 邮箱地址
|
|
124
|
+
* @param appName 应用名称(可选)
|
|
125
|
+
* @returns 发送结果 Promise
|
|
126
|
+
*/
|
|
127
|
+
sendEmailVerificationCode(email: string, appName?: string): Promise<SendCodeResponse>;
|
|
128
|
+
/**
|
|
129
|
+
* 邮箱验证码登录
|
|
130
|
+
* @param email 邮箱地址
|
|
131
|
+
* @param code 验证码
|
|
132
|
+
* @returns 登录结果 Promise
|
|
133
|
+
*/
|
|
134
|
+
loginWithEmailCode(email: string, code: string): Promise<EmailLoginResponse>;
|
|
135
|
+
/**
|
|
136
|
+
* 获取验证码状态(调试用)
|
|
137
|
+
* @param email 邮箱地址
|
|
138
|
+
* @returns 验证码状态 Promise
|
|
139
|
+
*/
|
|
140
|
+
getCodeStatus(email: string): Promise<any>;
|
|
141
|
+
private generateAppId;
|
|
142
|
+
/**
|
|
143
|
+
* 检查 OAuth 回调
|
|
144
|
+
* 从 URL 参数中获取 token 和错误信息
|
|
145
|
+
* @returns 包含 token、用户信息和错误的对象
|
|
146
|
+
*/
|
|
147
|
+
checkOAuthCallback(): {
|
|
148
|
+
success: boolean;
|
|
149
|
+
token?: string;
|
|
150
|
+
error?: string;
|
|
151
|
+
user?: any;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* 验证 token 是否有效
|
|
155
|
+
* @param token JWT token
|
|
156
|
+
* @returns 包含有效状态和用户信息的 Promise
|
|
157
|
+
*/
|
|
158
|
+
verifyToken(token: string): Promise<{
|
|
159
|
+
valid: boolean;
|
|
160
|
+
user?: any;
|
|
161
|
+
}>;
|
|
162
|
+
/**
|
|
163
|
+
* 从本地存储获取认证数据
|
|
164
|
+
*/
|
|
165
|
+
private getSavedAuthData;
|
|
166
|
+
/**
|
|
167
|
+
* 保存认证数据到本地存储
|
|
168
|
+
*/
|
|
169
|
+
private saveAuthData;
|
|
170
|
+
/**
|
|
171
|
+
* 退出登录
|
|
172
|
+
* @param token JWT token
|
|
173
|
+
*/
|
|
174
|
+
logout(token: string): Promise<void>;
|
|
175
|
+
}
|
|
176
|
+
declare const unifiedAuth: UnifiedAuthService;
|
|
177
|
+
declare const unifiedOAuth: UnifiedAuthService;
|
|
178
|
+
declare function sendEmailVerificationCode(email: string, appName?: string): Promise<SendCodeResponse>;
|
|
179
|
+
declare function loginWithEmailCode(email: string, code: string): Promise<EmailLoginResponse>;
|
|
180
|
+
declare function getCodeStatus(email: string): Promise<any>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* AI Workflow 服务(精简版,仅支持按 ID 的 path 风格执行)
|
|
184
|
+
*
|
|
185
|
+
* 说明:模板仅需要一种执行接口,形如 POST {baseUrl}/workflow/{workflowId}/execute
|
|
186
|
+
*/
|
|
187
|
+
interface AIWorkflowResponse {
|
|
188
|
+
success: boolean;
|
|
189
|
+
output?: Record<string, unknown>;
|
|
190
|
+
error?: string;
|
|
191
|
+
metadata?: Record<string, unknown>;
|
|
192
|
+
}
|
|
193
|
+
interface AIWorkflowClientOptions {
|
|
194
|
+
baseUrl?: string;
|
|
195
|
+
apiKey?: string;
|
|
196
|
+
headers?: Record<string, string>;
|
|
197
|
+
fetchImpl?: typeof fetch;
|
|
198
|
+
}
|
|
199
|
+
declare class AIWorkflowClient {
|
|
200
|
+
private readonly baseUrl;
|
|
201
|
+
private readonly apiKey?;
|
|
202
|
+
private readonly headers;
|
|
203
|
+
private readonly fetchImpl;
|
|
204
|
+
constructor(options?: AIWorkflowClientOptions);
|
|
205
|
+
private buildHeaders;
|
|
206
|
+
private safeJson;
|
|
207
|
+
/**
|
|
208
|
+
* 按 ID 执行工作流:POST {baseUrl}/workflow/{workflowId}/execute
|
|
209
|
+
* body: { input, options }
|
|
210
|
+
*/
|
|
211
|
+
executeWorkflow(workflowId: string, input: Record<string, unknown>, options?: Record<string, unknown>): Promise<AIWorkflowResponse>;
|
|
212
|
+
}
|
|
213
|
+
declare function createAIWorkflowClient(options?: AIWorkflowClientOptions): AIWorkflowClient;
|
|
214
|
+
declare const aiWorkflow: AIWorkflowClient;
|
|
215
|
+
|
|
216
|
+
interface RequestInterceptors<T = AxiosResponse> {
|
|
217
|
+
requestInterceptor?: (config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig;
|
|
218
|
+
requestInterceptorCatch?: (error: any) => any;
|
|
219
|
+
responseInterceptor?: (res: T) => T;
|
|
220
|
+
responseInterceptorCatch?: (error: any) => any;
|
|
221
|
+
}
|
|
222
|
+
interface RequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
|
|
223
|
+
interceptors?: RequestInterceptors<T>;
|
|
224
|
+
showLoading?: boolean;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
declare class Request {
|
|
228
|
+
instance: AxiosInstance;
|
|
229
|
+
interceptors?: RequestInterceptors;
|
|
230
|
+
abortControllers: Map<string, AbortController>;
|
|
231
|
+
constructor(config: RequestConfig);
|
|
232
|
+
cancelRequest(url: string): void;
|
|
233
|
+
cancelAllRequests(): void;
|
|
234
|
+
request<T = any>(config: RequestConfig<T>): Promise<T>;
|
|
235
|
+
get<T = any>(config: RequestConfig<T>): Promise<T>;
|
|
236
|
+
post<T = any>(config: RequestConfig<T>): Promise<T>;
|
|
237
|
+
delete<T = any>(config: RequestConfig<T>): Promise<T>;
|
|
238
|
+
put<T = any>(config: RequestConfig<T>): Promise<T>;
|
|
239
|
+
patch<T = any>(config: RequestConfig<T>): Promise<T>;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
interface AxiosAIWorkflowOptions {
|
|
243
|
+
baseUrl?: string;
|
|
244
|
+
basePath?: string;
|
|
245
|
+
apiKey?: string;
|
|
246
|
+
timeout?: number;
|
|
247
|
+
headers?: Record<string, string>;
|
|
248
|
+
requestInstance?: Request;
|
|
249
|
+
/** 'body' (default) or 'path' for /workflow/{id}/execute */
|
|
250
|
+
workflowEndpointStyle?: 'body' | 'path';
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Create an AI workflow client backed by the project's Request (axios) wrapper.
|
|
254
|
+
* If `requestInstance` is provided it will be used directly; otherwise a new Request will be created.
|
|
255
|
+
*/
|
|
256
|
+
declare function createAIWorkflowClientAxios(options?: AxiosAIWorkflowOptions): {
|
|
257
|
+
executeWorkflow(workflowId: string, input: Record<string, unknown>, opts?: Record<string, unknown>): Promise<AIWorkflowResponse>;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
type Visibility = 'private' | 'project' | 'public' | 'shared';
|
|
261
|
+
interface Artifact {
|
|
262
|
+
id: string;
|
|
263
|
+
ownerId?: string | null;
|
|
264
|
+
projectId?: string | null;
|
|
265
|
+
visibility: Visibility;
|
|
266
|
+
storageUrl: string;
|
|
267
|
+
thumbnailUrl?: string;
|
|
268
|
+
input?: any;
|
|
269
|
+
output?: any;
|
|
270
|
+
model?: string;
|
|
271
|
+
metadata?: Record<string, any>;
|
|
272
|
+
createdAt?: string;
|
|
273
|
+
likes?: number;
|
|
274
|
+
stats?: {
|
|
275
|
+
views?: number;
|
|
276
|
+
};
|
|
277
|
+
sharedWith?: string[];
|
|
278
|
+
}
|
|
279
|
+
interface ArtifactCreateInput {
|
|
280
|
+
storageUrl: string;
|
|
281
|
+
thumbnailUrl?: string;
|
|
282
|
+
visibility?: Visibility;
|
|
283
|
+
metadata?: Record<string, any>;
|
|
284
|
+
model?: string;
|
|
285
|
+
ownerId?: string;
|
|
286
|
+
projectId?: string;
|
|
287
|
+
}
|
|
288
|
+
interface ArtifactListQuery {
|
|
289
|
+
ownerId?: string;
|
|
290
|
+
projectId?: string;
|
|
291
|
+
visibility?: Visibility;
|
|
292
|
+
limit?: number;
|
|
293
|
+
cursor?: string;
|
|
294
|
+
}
|
|
295
|
+
interface AccessContext {
|
|
296
|
+
userId?: string | null;
|
|
297
|
+
projectId?: string | null;
|
|
298
|
+
tokenScopes?: string[];
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Basic client-side permission check for an artifact.
|
|
302
|
+
* Note: final authorization must be enforced on the server. This is a convenience helper.
|
|
303
|
+
*/
|
|
304
|
+
declare function canAccessArtifact(a: Artifact, ctx?: AccessContext): boolean;
|
|
305
|
+
|
|
306
|
+
declare function createArtifactsClient(req: Request): {
|
|
307
|
+
create(input: ArtifactCreateInput): Promise<Artifact>;
|
|
308
|
+
list(query?: ArtifactListQuery): Promise<Artifact[]>;
|
|
309
|
+
get(id: string): Promise<Artifact>;
|
|
310
|
+
setVisibility(id: string, visibility: string): Promise<void>;
|
|
311
|
+
delete(id: string): Promise<void>;
|
|
312
|
+
canAccessLocal(a: Artifact, ctx: AccessContext): boolean;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
declare const request: Request;
|
|
316
|
+
declare const aiRequest: Request;
|
|
317
|
+
declare const workflowRequest: Request;
|
|
318
|
+
/**
|
|
319
|
+
* 简单工厂:返回一个对外友好的 client,封装业务 request 与 AI workflow request。
|
|
320
|
+
* 默认使用上面导出的 `request` 和 `aiRequest`,也可以通过 options 覆盖。
|
|
321
|
+
*/
|
|
322
|
+
/**
|
|
323
|
+
* Higher-level factory: createClient
|
|
324
|
+
* - minimal surface compatible with `createClient({ projectId, authRequired })`
|
|
325
|
+
* - returns executeWorkflow, request, aiRequest and a tiny auth helper (set/get token)
|
|
326
|
+
*/
|
|
327
|
+
declare function createClient(opts?: {
|
|
328
|
+
projectId?: string;
|
|
329
|
+
authRequired?: boolean;
|
|
330
|
+
baseUrl?: string;
|
|
331
|
+
aiBaseUrl?: string;
|
|
332
|
+
mode?: 'auto' | 'standalone' | 'embedded';
|
|
333
|
+
auth?: {
|
|
334
|
+
mode?: 'none' | 'managed' | 'headless';
|
|
335
|
+
getToken?: () => Promise<string | null>;
|
|
336
|
+
tokenInjection?: {
|
|
337
|
+
allowedOrigins?: string[];
|
|
338
|
+
waitMs?: number;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
requestInstance?: Request;
|
|
342
|
+
aiRequestInstance?: Request;
|
|
343
|
+
}): {
|
|
344
|
+
request: Request;
|
|
345
|
+
aiRequest: Request;
|
|
346
|
+
workflowRequest: Request;
|
|
347
|
+
artifacts: {
|
|
348
|
+
create(input: ArtifactCreateInput): Promise<Artifact>;
|
|
349
|
+
list(query?: ArtifactListQuery): Promise<Artifact[]>;
|
|
350
|
+
get(id: string): Promise<Artifact>;
|
|
351
|
+
setVisibility(id: string, visibility: string): Promise<void>;
|
|
352
|
+
delete(id: string): Promise<void>;
|
|
353
|
+
};
|
|
354
|
+
auth: {
|
|
355
|
+
setToken: (t: string | null) => void;
|
|
356
|
+
getToken: () => string | null;
|
|
357
|
+
isAuthenticated: () => boolean;
|
|
358
|
+
login: (redirect?: string) => void;
|
|
359
|
+
logout: () => void;
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
interface LoginFormProps {
|
|
364
|
+
onLoginSuccess?: () => void;
|
|
365
|
+
appName?: string;
|
|
366
|
+
className?: string;
|
|
367
|
+
}
|
|
368
|
+
declare const LoginForm: React.FC<LoginFormProps>;
|
|
369
|
+
|
|
370
|
+
interface AuthGuardProps {
|
|
371
|
+
children: React.ReactNode;
|
|
372
|
+
fallback?: React.ReactNode;
|
|
373
|
+
redirectTo?: string;
|
|
374
|
+
requireAuth?: boolean;
|
|
375
|
+
roles?: string[];
|
|
376
|
+
permissions?: string[];
|
|
377
|
+
}
|
|
378
|
+
declare const AuthGuard: React.FC<AuthGuardProps>;
|
|
379
|
+
|
|
380
|
+
interface LoadingProps {
|
|
381
|
+
size?: 'sm' | 'md' | 'lg';
|
|
382
|
+
text?: string;
|
|
383
|
+
className?: string;
|
|
384
|
+
fullScreen?: boolean;
|
|
385
|
+
}
|
|
386
|
+
declare const Loading: React.FC<LoadingProps>;
|
|
387
|
+
interface LoadingSpinnerProps {
|
|
388
|
+
size?: 'sm' | 'md' | 'lg';
|
|
389
|
+
className?: string;
|
|
390
|
+
}
|
|
391
|
+
declare const LoadingSpinner: React.FC<LoadingSpinnerProps>;
|
|
392
|
+
|
|
393
|
+
interface ErrorBoundaryState {
|
|
394
|
+
hasError: boolean;
|
|
395
|
+
error?: Error;
|
|
396
|
+
errorInfo?: React.ErrorInfo;
|
|
397
|
+
}
|
|
398
|
+
interface ErrorBoundaryProps {
|
|
399
|
+
children: ReactNode;
|
|
400
|
+
fallback?: React.ComponentType<{
|
|
401
|
+
error?: Error;
|
|
402
|
+
retry?: () => void;
|
|
403
|
+
}>;
|
|
404
|
+
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
405
|
+
}
|
|
406
|
+
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
407
|
+
constructor(props: ErrorBoundaryProps);
|
|
408
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
409
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
410
|
+
handleRetry: () => void;
|
|
411
|
+
render(): string | number | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | null | undefined;
|
|
412
|
+
}
|
|
413
|
+
interface ErrorFallbackProps {
|
|
414
|
+
error?: Error;
|
|
415
|
+
retry?: () => void;
|
|
416
|
+
}
|
|
417
|
+
declare const DefaultErrorFallback: React.FC<ErrorFallbackProps>;
|
|
418
|
+
|
|
419
|
+
declare function useIsMobile(): boolean;
|
|
420
|
+
|
|
421
|
+
declare function useLocalStorage<T>(key: string, initialValue: T): readonly [T, (value: T | ((val: T) => T)) => void, () => void];
|
|
422
|
+
|
|
423
|
+
declare function useDebounce<T>(value: T, delay: number): T;
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Early error handler injector
|
|
427
|
+
* This module provides a runtime function to inject the original
|
|
428
|
+
* `error-handler.js` script into the page. The script is executed
|
|
429
|
+
* as soon as it's injected, providing early capture of runtime and
|
|
430
|
+
* Vite overlay errors for the host app.
|
|
431
|
+
*/
|
|
432
|
+
declare function injectEarlyErrorHandler(): void;
|
|
433
|
+
|
|
434
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthGuard, 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, getCodeStatus, injectEarlyErrorHandler, loginWithEmailCode, request, sendEmailVerificationCode, unifiedAuth, unifiedOAuth, useDebounce, useIsMobile, useLocalStorage, workflowRequest };
|