@howone/sdk 0.1.0 → 0.1.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 +77 -1
- package/dist/index.d.ts +77 -1
- package/dist/index.js +620 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +615 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -3
package/dist/index.d.mts
CHANGED
|
@@ -312,6 +312,39 @@ declare function createArtifactsClient(req: Request): {
|
|
|
312
312
|
canAccessLocal(a: Artifact, ctx: AccessContext): boolean;
|
|
313
313
|
};
|
|
314
314
|
|
|
315
|
+
declare const AUTH_TOKEN_KEY = "auth_token";
|
|
316
|
+
declare function setToken(token: string | null): void;
|
|
317
|
+
declare function getToken(): string | null;
|
|
318
|
+
declare function parseUserFromToken(token: string | null): {
|
|
319
|
+
id: string;
|
|
320
|
+
email: string;
|
|
321
|
+
name: string;
|
|
322
|
+
avatar: string;
|
|
323
|
+
} | null;
|
|
324
|
+
declare function isTokenValid(token: string | null): boolean;
|
|
325
|
+
declare function useAuth(): {
|
|
326
|
+
token: string | null;
|
|
327
|
+
user: {
|
|
328
|
+
id: string;
|
|
329
|
+
email: string;
|
|
330
|
+
name: string;
|
|
331
|
+
avatar: string;
|
|
332
|
+
} | null;
|
|
333
|
+
isAuthenticated: boolean;
|
|
334
|
+
logout: () => void;
|
|
335
|
+
};
|
|
336
|
+
type AuthState$1 = {
|
|
337
|
+
user: ReturnType<typeof parseUserFromToken> | null;
|
|
338
|
+
isLoading: boolean;
|
|
339
|
+
};
|
|
340
|
+
declare function onAuthStateChanged(cb: (state: AuthState$1) => void): () => void;
|
|
341
|
+
|
|
342
|
+
declare function setAuthRoot(url: string): void;
|
|
343
|
+
declare function getAuthRoot(): string;
|
|
344
|
+
declare const AUTH_ROOT: string;
|
|
345
|
+
declare function setDefaultProjectId(id: string | null): void;
|
|
346
|
+
declare function getDefaultProjectId(): string | null;
|
|
347
|
+
|
|
315
348
|
declare const request: Request;
|
|
316
349
|
declare const aiRequest: Request;
|
|
317
350
|
declare const workflowRequest: Request;
|
|
@@ -341,6 +374,7 @@ declare function createClient(opts?: {
|
|
|
341
374
|
requestInstance?: Request;
|
|
342
375
|
aiRequestInstance?: Request;
|
|
343
376
|
}): {
|
|
377
|
+
projectId: string | null;
|
|
344
378
|
request: Request;
|
|
345
379
|
aiRequest: Request;
|
|
346
380
|
workflowRequest: Request;
|
|
@@ -377,6 +411,48 @@ interface AuthGuardProps {
|
|
|
377
411
|
}
|
|
378
412
|
declare const AuthGuard: React.FC<AuthGuardProps>;
|
|
379
413
|
|
|
414
|
+
declare const AuthRedirector: React.FC<{
|
|
415
|
+
fallback?: React.ReactNode;
|
|
416
|
+
}>;
|
|
417
|
+
|
|
418
|
+
type AuthContextValue = {
|
|
419
|
+
user: ReturnType<typeof parseUserFromToken> | null;
|
|
420
|
+
token: string | null;
|
|
421
|
+
isAuthenticated: boolean;
|
|
422
|
+
isLoading: boolean;
|
|
423
|
+
logout: () => void;
|
|
424
|
+
};
|
|
425
|
+
declare const AuthProvider: React.FC<{
|
|
426
|
+
children: React.ReactNode;
|
|
427
|
+
autoRedirect?: boolean;
|
|
428
|
+
showFloatingButton?: boolean;
|
|
429
|
+
projectId?: string;
|
|
430
|
+
}>;
|
|
431
|
+
declare function useAuthContext(): AuthContextValue;
|
|
432
|
+
|
|
433
|
+
type AuthState = {
|
|
434
|
+
user: Record<string, unknown> | null;
|
|
435
|
+
isLoading: boolean;
|
|
436
|
+
};
|
|
437
|
+
declare class HowoneAuthClient {
|
|
438
|
+
private listeners;
|
|
439
|
+
private loading;
|
|
440
|
+
private emit;
|
|
441
|
+
onAuthStateChanged(listener: (state: AuthState) => void): () => void;
|
|
442
|
+
login(): void;
|
|
443
|
+
logout(): void;
|
|
444
|
+
getUser(): {
|
|
445
|
+
id: string;
|
|
446
|
+
email: string;
|
|
447
|
+
name: string;
|
|
448
|
+
avatar: string;
|
|
449
|
+
} | null;
|
|
450
|
+
setToken(token: string | null): void;
|
|
451
|
+
}
|
|
452
|
+
declare const howone: {
|
|
453
|
+
auth: HowoneAuthClient;
|
|
454
|
+
};
|
|
455
|
+
|
|
380
456
|
interface LoadingProps {
|
|
381
457
|
size?: 'sm' | 'md' | 'lg';
|
|
382
458
|
text?: string;
|
|
@@ -431,4 +507,4 @@ declare function useDebounce<T>(value: T, delay: number): T;
|
|
|
431
507
|
*/
|
|
432
508
|
declare function injectEarlyErrorHandler(): void;
|
|
433
509
|
|
|
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 };
|
|
510
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthGuard, AuthProvider, AuthRedirector, AuthRedirector as AuthRedirectorDefault, 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, useLocalStorage, workflowRequest };
|
package/dist/index.d.ts
CHANGED
|
@@ -312,6 +312,39 @@ declare function createArtifactsClient(req: Request): {
|
|
|
312
312
|
canAccessLocal(a: Artifact, ctx: AccessContext): boolean;
|
|
313
313
|
};
|
|
314
314
|
|
|
315
|
+
declare const AUTH_TOKEN_KEY = "auth_token";
|
|
316
|
+
declare function setToken(token: string | null): void;
|
|
317
|
+
declare function getToken(): string | null;
|
|
318
|
+
declare function parseUserFromToken(token: string | null): {
|
|
319
|
+
id: string;
|
|
320
|
+
email: string;
|
|
321
|
+
name: string;
|
|
322
|
+
avatar: string;
|
|
323
|
+
} | null;
|
|
324
|
+
declare function isTokenValid(token: string | null): boolean;
|
|
325
|
+
declare function useAuth(): {
|
|
326
|
+
token: string | null;
|
|
327
|
+
user: {
|
|
328
|
+
id: string;
|
|
329
|
+
email: string;
|
|
330
|
+
name: string;
|
|
331
|
+
avatar: string;
|
|
332
|
+
} | null;
|
|
333
|
+
isAuthenticated: boolean;
|
|
334
|
+
logout: () => void;
|
|
335
|
+
};
|
|
336
|
+
type AuthState$1 = {
|
|
337
|
+
user: ReturnType<typeof parseUserFromToken> | null;
|
|
338
|
+
isLoading: boolean;
|
|
339
|
+
};
|
|
340
|
+
declare function onAuthStateChanged(cb: (state: AuthState$1) => void): () => void;
|
|
341
|
+
|
|
342
|
+
declare function setAuthRoot(url: string): void;
|
|
343
|
+
declare function getAuthRoot(): string;
|
|
344
|
+
declare const AUTH_ROOT: string;
|
|
345
|
+
declare function setDefaultProjectId(id: string | null): void;
|
|
346
|
+
declare function getDefaultProjectId(): string | null;
|
|
347
|
+
|
|
315
348
|
declare const request: Request;
|
|
316
349
|
declare const aiRequest: Request;
|
|
317
350
|
declare const workflowRequest: Request;
|
|
@@ -341,6 +374,7 @@ declare function createClient(opts?: {
|
|
|
341
374
|
requestInstance?: Request;
|
|
342
375
|
aiRequestInstance?: Request;
|
|
343
376
|
}): {
|
|
377
|
+
projectId: string | null;
|
|
344
378
|
request: Request;
|
|
345
379
|
aiRequest: Request;
|
|
346
380
|
workflowRequest: Request;
|
|
@@ -377,6 +411,48 @@ interface AuthGuardProps {
|
|
|
377
411
|
}
|
|
378
412
|
declare const AuthGuard: React.FC<AuthGuardProps>;
|
|
379
413
|
|
|
414
|
+
declare const AuthRedirector: React.FC<{
|
|
415
|
+
fallback?: React.ReactNode;
|
|
416
|
+
}>;
|
|
417
|
+
|
|
418
|
+
type AuthContextValue = {
|
|
419
|
+
user: ReturnType<typeof parseUserFromToken> | null;
|
|
420
|
+
token: string | null;
|
|
421
|
+
isAuthenticated: boolean;
|
|
422
|
+
isLoading: boolean;
|
|
423
|
+
logout: () => void;
|
|
424
|
+
};
|
|
425
|
+
declare const AuthProvider: React.FC<{
|
|
426
|
+
children: React.ReactNode;
|
|
427
|
+
autoRedirect?: boolean;
|
|
428
|
+
showFloatingButton?: boolean;
|
|
429
|
+
projectId?: string;
|
|
430
|
+
}>;
|
|
431
|
+
declare function useAuthContext(): AuthContextValue;
|
|
432
|
+
|
|
433
|
+
type AuthState = {
|
|
434
|
+
user: Record<string, unknown> | null;
|
|
435
|
+
isLoading: boolean;
|
|
436
|
+
};
|
|
437
|
+
declare class HowoneAuthClient {
|
|
438
|
+
private listeners;
|
|
439
|
+
private loading;
|
|
440
|
+
private emit;
|
|
441
|
+
onAuthStateChanged(listener: (state: AuthState) => void): () => void;
|
|
442
|
+
login(): void;
|
|
443
|
+
logout(): void;
|
|
444
|
+
getUser(): {
|
|
445
|
+
id: string;
|
|
446
|
+
email: string;
|
|
447
|
+
name: string;
|
|
448
|
+
avatar: string;
|
|
449
|
+
} | null;
|
|
450
|
+
setToken(token: string | null): void;
|
|
451
|
+
}
|
|
452
|
+
declare const howone: {
|
|
453
|
+
auth: HowoneAuthClient;
|
|
454
|
+
};
|
|
455
|
+
|
|
380
456
|
interface LoadingProps {
|
|
381
457
|
size?: 'sm' | 'md' | 'lg';
|
|
382
458
|
text?: string;
|
|
@@ -431,4 +507,4 @@ declare function useDebounce<T>(value: T, delay: number): T;
|
|
|
431
507
|
*/
|
|
432
508
|
declare function injectEarlyErrorHandler(): void;
|
|
433
509
|
|
|
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 };
|
|
510
|
+
export { type AIWorkflowClientOptions, type AIWorkflowResponse, AUTH_ROOT, AUTH_TOKEN_KEY, type AccessContext, type Artifact, type ArtifactCreateInput, type ArtifactListQuery, AuthGuard, AuthProvider, AuthRedirector, AuthRedirector as AuthRedirectorDefault, 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, useLocalStorage, workflowRequest };
|