@howone/sdk 0.1.28 → 0.2.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/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React$1, { Component, ReactNode } from 'react';
2
2
  import * as axios from 'axios';
3
- import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
3
+ import { AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig, AxiosInstance } from 'axios';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ToastOptions } from 'react-toastify';
6
6
 
@@ -185,6 +185,7 @@ declare function getCodeStatus(email: string): Promise<any>;
185
185
  */
186
186
  interface AIWorkflowResponse {
187
187
  success: boolean;
188
+ status?: number;
188
189
  output?: Record<string, unknown>;
189
190
  error?: string;
190
191
  metadata?: Record<string, unknown>;
@@ -207,7 +208,7 @@ declare class AIWorkflowClient {
207
208
  * 按 ID 执行工作流:POST {baseUrl}/workflow/{workflowId}/execute
208
209
  * body: { input, options }
209
210
  */
210
- executeWorkflow(workflowId: string, inputs: Record<string, unknown>, options?: Record<string, unknown>): Promise<AIWorkflowResponse>;
211
+ executeWorkflow(workflowId: string, inputs: Record<string, unknown>, options?: Record<string, unknown>): Promise<AIWorkflowResponse | null>;
211
212
  }
212
213
  declare function createAIWorkflowClient(options?: AIWorkflowClientOptions): AIWorkflowClient;
213
214
  declare const aiWorkflow: AIWorkflowClient;
@@ -338,29 +339,28 @@ type AuthState$1 = {
338
339
  };
339
340
  declare function onAuthStateChanged(cb: (state: AuthState$1) => void): () => void;
340
341
 
341
- declare function setAuthRoot(url: string): void;
342
- declare function getAuthRoot(): string;
343
- declare const AUTH_ROOT: string;
342
+ type Environment = 'local' | 'dev' | 'prod';
343
+ type envs = {
344
+ AUTH_ROOT_VALUE: string;
345
+ baseUrl: string;
346
+ aiBaseUrl: string;
347
+ };
348
+ declare function setEnvironment(e: Environment): envs;
349
+ declare function getEnvironment(): Environment;
350
+ declare function getEnvs(): envs;
344
351
  declare function setDefaultProjectId(id: string | null): void;
345
352
  declare function getDefaultProjectId(): string | null;
353
+ declare function getGlobalEnvironment(): Environment | null;
346
354
 
347
- declare const request: Request;
348
- declare const aiRequest: Request;
349
- declare const workflowRequest: Request;
350
- /**
351
- * 简单工厂:返回一个对外友好的 client,封装业务 request 与 AI workflow request。
352
- * 默认使用上面导出的 `request` 和 `aiRequest`,也可以通过 options 覆盖。
353
- */
354
355
  /**
355
356
  * Higher-level factory: createClient
356
357
  * - minimal surface compatible with `createClient({ projectId, authRequired })`
357
358
  * - returns executeWorkflow, request, aiRequest and a tiny auth helper (set/get token)
358
359
  */
359
- declare function createClient(opts?: {
360
- projectId?: string;
360
+ declare function createClient(opts: {
361
+ projectId: string;
362
+ env?: 'local' | 'dev' | 'prod';
361
363
  authRequired?: boolean;
362
- baseUrl?: string;
363
- aiBaseUrl?: string;
364
364
  mode?: "auto" | "standalone" | "embedded";
365
365
  auth?: {
366
366
  mode?: "none" | "managed" | "headless";
@@ -373,10 +373,8 @@ declare function createClient(opts?: {
373
373
  sensitiveParams?: string[];
374
374
  };
375
375
  };
376
- requestInstance?: Request;
377
- aiRequestInstance?: Request;
378
376
  }): {
379
- projectId: string | null;
377
+ projectId: string;
380
378
  request: {
381
379
  instance: axios.AxiosInstance;
382
380
  request: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
@@ -536,6 +534,18 @@ interface ErrorFallbackProps {
536
534
  }
537
535
  declare const DefaultErrorFallback: React$1.FC<ErrorFallbackProps>;
538
536
 
537
+ type ButtonSize = "sm" | "md" | "lg";
538
+ type ButtonVariant = "solid" | "ghost" | "flat";
539
+ interface ClayxButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
540
+ isIconOnly?: boolean;
541
+ size?: ButtonSize;
542
+ variant?: ButtonVariant;
543
+ children?: React$1.ReactNode;
544
+ }
545
+ declare const ClayxButton: React$1.FC<ClayxButtonProps>;
546
+
547
+ declare function showLimitUpgradeToast(message: string, onUpgrade: () => void): void;
548
+
539
549
  type Theme = "dark" | "light" | "system";
540
550
  type ThemeProviderProps = {
541
551
  children: React.ReactNode;
@@ -564,6 +574,7 @@ declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
564
574
  interface ToastParams {
565
575
  title?: string;
566
576
  message?: string;
577
+ render?: (closeToast: () => void) => React$1.ReactNode;
567
578
  component?: React$1.ReactNode;
568
579
  options?: Partial<ToastOptions>;
569
580
  }
@@ -920,4 +931,74 @@ declare class SimpleErrorHandler {
920
931
  captureError(error: Error, details?: any): void;
921
932
  }
922
933
 
923
- export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DEFAULT_SELECTOR_CONFIG, DefaultErrorFallback, ERROR_CONFIG, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type EnhancedErrorConfig, ErrorBoundary, ErrorHandler, type ErrorPayload, type ErrorSeverity, type ErrorStats, type ErrorType, FloatingButton, GLOBAL_CONFIG, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type MessageType, type SelectorState, type SendCodeRequest, type SendCodeResponse, type SimpleErrorConfig, SimpleErrorHandler, type SourceLocation, ThemeProvider, ThemeToggle, type UseElementSelectorReturn, type UserInteraction, type ViewInfo, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendElementSelectionToParent, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useElementSelector, useHowoneContext, useIsMobile, useTheme, workflowRequest };
934
+ /**
935
+ * iframe navigation and element selector utilities
936
+ * Replaces the standalone iframe.js script
937
+ */
938
+ declare function customGoBack(): boolean;
939
+ declare function customGoForward(): boolean;
940
+ declare function triggerElementSelection(): void;
941
+ declare function cancelElementSelection(): void;
942
+ /**
943
+ * Initialize iframe navigation system
944
+ * Call this once when your app starts
945
+ */
946
+ declare function initIframeNavigation(): void;
947
+ /**
948
+ * Public API for iframe navigation
949
+ */
950
+ declare const iframeNavigation: {
951
+ /**
952
+ * Initialize the navigation system
953
+ */
954
+ init: typeof initIframeNavigation;
955
+ /**
956
+ * Add a page to navigation history
957
+ */
958
+ addPage: (url?: string, title?: string) => void;
959
+ /**
960
+ * Get current navigation state
961
+ */
962
+ getState: () => {
963
+ canGoBack: boolean;
964
+ canGoForward: boolean;
965
+ historyLength: number;
966
+ currentIndex: number;
967
+ currentPage: {
968
+ url: string;
969
+ title: string;
970
+ timestamp: number;
971
+ };
972
+ };
973
+ /**
974
+ * Update navigation state (send to parent)
975
+ */
976
+ updateState: () => void;
977
+ /**
978
+ * Go back in history
979
+ */
980
+ goBack: typeof customGoBack;
981
+ /**
982
+ * Go forward in history
983
+ */
984
+ goForward: typeof customGoForward;
985
+ };
986
+ /**
987
+ * Public API for element selector
988
+ */
989
+ declare const elementSelector: {
990
+ /**
991
+ * Start element selection mode
992
+ */
993
+ startSelection: typeof triggerElementSelection;
994
+ /**
995
+ * Cancel element selection mode
996
+ */
997
+ cancel: typeof cancelElementSelection;
998
+ /**
999
+ * Check if selector is active
1000
+ */
1001
+ isActive: () => boolean;
1002
+ };
1003
+
1004
+ export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxButton, ClayxToast, DEFAULT_SELECTOR_CONFIG, DefaultErrorFallback, ERROR_CONFIG, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type EnhancedErrorConfig, type Environment, ErrorBoundary, ErrorHandler, type ErrorPayload, type ErrorSeverity, type ErrorStats, type ErrorType, FloatingButton, GLOBAL_CONFIG, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type MessageType, type SelectorState, type SendCodeRequest, type SendCodeResponse, type SimpleErrorConfig, SimpleErrorHandler, type SourceLocation, ThemeProvider, ThemeToggle, type UseElementSelectorReturn, type UserInteraction, type ViewInfo, type Visibility, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, elementSelector, type envs, 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 };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React$1, { Component, ReactNode } from 'react';
2
2
  import * as axios from 'axios';
3
- import { AxiosResponse, InternalAxiosRequestConfig, AxiosRequestConfig, AxiosInstance } from 'axios';
3
+ import { AxiosResponse, AxiosRequestConfig, InternalAxiosRequestConfig, AxiosInstance } from 'axios';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
5
  import { ToastOptions } from 'react-toastify';
6
6
 
@@ -185,6 +185,7 @@ declare function getCodeStatus(email: string): Promise<any>;
185
185
  */
186
186
  interface AIWorkflowResponse {
187
187
  success: boolean;
188
+ status?: number;
188
189
  output?: Record<string, unknown>;
189
190
  error?: string;
190
191
  metadata?: Record<string, unknown>;
@@ -207,7 +208,7 @@ declare class AIWorkflowClient {
207
208
  * 按 ID 执行工作流:POST {baseUrl}/workflow/{workflowId}/execute
208
209
  * body: { input, options }
209
210
  */
210
- executeWorkflow(workflowId: string, inputs: Record<string, unknown>, options?: Record<string, unknown>): Promise<AIWorkflowResponse>;
211
+ executeWorkflow(workflowId: string, inputs: Record<string, unknown>, options?: Record<string, unknown>): Promise<AIWorkflowResponse | null>;
211
212
  }
212
213
  declare function createAIWorkflowClient(options?: AIWorkflowClientOptions): AIWorkflowClient;
213
214
  declare const aiWorkflow: AIWorkflowClient;
@@ -338,29 +339,28 @@ type AuthState$1 = {
338
339
  };
339
340
  declare function onAuthStateChanged(cb: (state: AuthState$1) => void): () => void;
340
341
 
341
- declare function setAuthRoot(url: string): void;
342
- declare function getAuthRoot(): string;
343
- declare const AUTH_ROOT: string;
342
+ type Environment = 'local' | 'dev' | 'prod';
343
+ type envs = {
344
+ AUTH_ROOT_VALUE: string;
345
+ baseUrl: string;
346
+ aiBaseUrl: string;
347
+ };
348
+ declare function setEnvironment(e: Environment): envs;
349
+ declare function getEnvironment(): Environment;
350
+ declare function getEnvs(): envs;
344
351
  declare function setDefaultProjectId(id: string | null): void;
345
352
  declare function getDefaultProjectId(): string | null;
353
+ declare function getGlobalEnvironment(): Environment | null;
346
354
 
347
- declare const request: Request;
348
- declare const aiRequest: Request;
349
- declare const workflowRequest: Request;
350
- /**
351
- * 简单工厂:返回一个对外友好的 client,封装业务 request 与 AI workflow request。
352
- * 默认使用上面导出的 `request` 和 `aiRequest`,也可以通过 options 覆盖。
353
- */
354
355
  /**
355
356
  * Higher-level factory: createClient
356
357
  * - minimal surface compatible with `createClient({ projectId, authRequired })`
357
358
  * - returns executeWorkflow, request, aiRequest and a tiny auth helper (set/get token)
358
359
  */
359
- declare function createClient(opts?: {
360
- projectId?: string;
360
+ declare function createClient(opts: {
361
+ projectId: string;
362
+ env?: 'local' | 'dev' | 'prod';
361
363
  authRequired?: boolean;
362
- baseUrl?: string;
363
- aiBaseUrl?: string;
364
364
  mode?: "auto" | "standalone" | "embedded";
365
365
  auth?: {
366
366
  mode?: "none" | "managed" | "headless";
@@ -373,10 +373,8 @@ declare function createClient(opts?: {
373
373
  sensitiveParams?: string[];
374
374
  };
375
375
  };
376
- requestInstance?: Request;
377
- aiRequestInstance?: Request;
378
376
  }): {
379
- projectId: string | null;
377
+ projectId: string;
380
378
  request: {
381
379
  instance: axios.AxiosInstance;
382
380
  request: (config: RequestConfig) => Promise<AxiosResponse<any, any>>;
@@ -536,6 +534,18 @@ interface ErrorFallbackProps {
536
534
  }
537
535
  declare const DefaultErrorFallback: React$1.FC<ErrorFallbackProps>;
538
536
 
537
+ type ButtonSize = "sm" | "md" | "lg";
538
+ type ButtonVariant = "solid" | "ghost" | "flat";
539
+ interface ClayxButtonProps extends React$1.ButtonHTMLAttributes<HTMLButtonElement> {
540
+ isIconOnly?: boolean;
541
+ size?: ButtonSize;
542
+ variant?: ButtonVariant;
543
+ children?: React$1.ReactNode;
544
+ }
545
+ declare const ClayxButton: React$1.FC<ClayxButtonProps>;
546
+
547
+ declare function showLimitUpgradeToast(message: string, onUpgrade: () => void): void;
548
+
539
549
  type Theme = "dark" | "light" | "system";
540
550
  type ThemeProviderProps = {
541
551
  children: React.ReactNode;
@@ -564,6 +574,7 @@ declare function GlobalToastContainer(): react_jsx_runtime.JSX.Element;
564
574
  interface ToastParams {
565
575
  title?: string;
566
576
  message?: string;
577
+ render?: (closeToast: () => void) => React$1.ReactNode;
567
578
  component?: React$1.ReactNode;
568
579
  options?: Partial<ToastOptions>;
569
580
  }
@@ -920,4 +931,74 @@ declare class SimpleErrorHandler {
920
931
  captureError(error: Error, details?: any): void;
921
932
  }
922
933
 
923
- export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxToast, DEFAULT_SELECTOR_CONFIG, DefaultErrorFallback, ERROR_CONFIG, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type EnhancedErrorConfig, ErrorBoundary, ErrorHandler, type ErrorPayload, type ErrorSeverity, type ErrorStats, type ErrorType, FloatingButton, GLOBAL_CONFIG, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type MessageType, type SelectorState, type SendCodeRequest, type SendCodeResponse, type SimpleErrorConfig, SimpleErrorHandler, type SourceLocation, ThemeProvider, ThemeToggle, type UseElementSelectorReturn, type UserInteraction, type ViewInfo, type Visibility, aiRequest, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, getAuthRoot, getCodeStatus, getDefaultProjectId, getToken, howone, isTokenValid, loginWithEmailCode, onAuthStateChanged, parseUserFromToken, request, sendElementSelectionToParent, sendEmailVerificationCode, setAuthRoot, setDefaultProjectId, setToken, unifiedAuth, unifiedOAuth, useAuth, useDebounce, useElementSelector, useHowoneContext, useIsMobile, useTheme, workflowRequest };
934
+ /**
935
+ * iframe navigation and element selector utilities
936
+ * Replaces the standalone iframe.js script
937
+ */
938
+ declare function customGoBack(): boolean;
939
+ declare function customGoForward(): boolean;
940
+ declare function triggerElementSelection(): void;
941
+ declare function cancelElementSelection(): void;
942
+ /**
943
+ * Initialize iframe navigation system
944
+ * Call this once when your app starts
945
+ */
946
+ declare function initIframeNavigation(): void;
947
+ /**
948
+ * Public API for iframe navigation
949
+ */
950
+ declare const iframeNavigation: {
951
+ /**
952
+ * Initialize the navigation system
953
+ */
954
+ init: typeof initIframeNavigation;
955
+ /**
956
+ * Add a page to navigation history
957
+ */
958
+ addPage: (url?: string, title?: string) => void;
959
+ /**
960
+ * Get current navigation state
961
+ */
962
+ getState: () => {
963
+ canGoBack: boolean;
964
+ canGoForward: boolean;
965
+ historyLength: number;
966
+ currentIndex: number;
967
+ currentPage: {
968
+ url: string;
969
+ title: string;
970
+ timestamp: number;
971
+ };
972
+ };
973
+ /**
974
+ * Update navigation state (send to parent)
975
+ */
976
+ updateState: () => void;
977
+ /**
978
+ * Go back in history
979
+ */
980
+ goBack: typeof customGoBack;
981
+ /**
982
+ * Go forward in history
983
+ */
984
+ goForward: typeof customGoForward;
985
+ };
986
+ /**
987
+ * Public API for element selector
988
+ */
989
+ declare const elementSelector: {
990
+ /**
991
+ * Start element selection mode
992
+ */
993
+ startSelection: typeof triggerElementSelection;
994
+ /**
995
+ * Cancel element selection mode
996
+ */
997
+ cancel: typeof cancelElementSelection;
998
+ /**
999
+ * Check if selector is active
1000
+ */
1001
+ isActive: () => boolean;
1002
+ };
1003
+
1004
+ export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, type AxiosAIWorkflowOptions, ClayxButton, ClayxToast, DEFAULT_SELECTOR_CONFIG, DefaultErrorFallback, ERROR_CONFIG, type ElementSelectionData, ElementSelector, ElementSelectorProvider, type EmailLoginRequest, type EmailLoginResponse, type EnhancedErrorConfig, type Environment, ErrorBoundary, ErrorHandler, type ErrorPayload, type ErrorSeverity, type ErrorStats, type ErrorType, FloatingButton, GLOBAL_CONFIG, GlobalToastContainer, HowOneProvider, type HowOneProviderProps, Loading, LoadingSpinner, LoginForm, type MessageType, type SelectorState, type SendCodeRequest, type SendCodeResponse, type SimpleErrorConfig, SimpleErrorHandler, type SourceLocation, ThemeProvider, ThemeToggle, type UseElementSelectorReturn, type UserInteraction, type ViewInfo, type Visibility, aiWorkflow, canAccessArtifact, createAIWorkflowClient, createAIWorkflowClientAxios, createArtifactsClient, createClient, elementSelector, type envs, 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 };