@23blocks/react 1.1.2 → 1.1.3
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.ts +1 -0
- package/dist/index.esm.js +1306 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/lib/context.d.ts +114 -0
- package/dist/src/lib/context.d.ts.map +1 -0
- package/dist/src/lib/hooks/index.d.ts +5 -0
- package/dist/src/lib/hooks/index.d.ts.map +1 -0
- package/dist/src/lib/hooks/use-auth.d.ts +52 -0
- package/dist/src/lib/hooks/use-auth.d.ts.map +1 -0
- package/dist/src/lib/hooks/use-favorites.d.ts +41 -0
- package/dist/src/lib/hooks/use-favorites.d.ts.map +1 -0
- package/dist/src/lib/hooks/use-search.d.ts +55 -0
- package/dist/src/lib/hooks/use-search.d.ts.map +1 -0
- package/dist/src/lib/hooks/use-users.d.ts +44 -0
- package/dist/src/lib/hooks/use-users.d.ts.map +1 -0
- package/dist/src/lib/index.d.ts +4 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/simple-provider.d.ts +281 -0
- package/dist/src/lib/simple-provider.d.ts.map +1 -0
- package/package.json +10 -8
- package/dist/index.js +0 -3
- package/dist/index.js.map +0 -1
- package/dist/lib/context.js +0 -208
- package/dist/lib/context.js.map +0 -1
- package/dist/lib/hooks/index.js +0 -8
- package/dist/lib/hooks/index.js.map +0 -1
- package/dist/lib/hooks/use-auth.js +0 -159
- package/dist/lib/hooks/use-auth.js.map +0 -1
- package/dist/lib/hooks/use-favorites.js +0 -114
- package/dist/lib/hooks/use-favorites.js.map +0 -1
- package/dist/lib/hooks/use-search.js +0 -120
- package/dist/lib/hooks/use-search.js.map +0 -1
- package/dist/lib/hooks/use-users.js +0 -115
- package/dist/lib/hooks/use-users.js.map +0 -1
- package/dist/lib/index.js +0 -17
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/simple-provider.js +0 -622
- package/dist/lib/simple-provider.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { Transport } from '@23blocks/contracts';
|
|
3
|
+
import { type AuthenticationBlock, type AuthenticationBlockConfig } from '@23blocks/block-authentication';
|
|
4
|
+
import { type SearchBlock, type SearchBlockConfig } from '@23blocks/block-search';
|
|
5
|
+
import { type ProductsBlock, type ProductsBlockConfig } from '@23blocks/block-products';
|
|
6
|
+
import { type CrmBlock, type CrmBlockConfig } from '@23blocks/block-crm';
|
|
7
|
+
import { type ContentBlock, type ContentBlockConfig } from '@23blocks/block-content';
|
|
8
|
+
import { type GeolocationBlock, type GeolocationBlockConfig } from '@23blocks/block-geolocation';
|
|
9
|
+
import { type ConversationsBlock, type ConversationsBlockConfig } from '@23blocks/block-conversations';
|
|
10
|
+
import { type FilesBlock, type FilesBlockConfig } from '@23blocks/block-files';
|
|
11
|
+
import { type FormsBlock, type FormsBlockConfig } from '@23blocks/block-forms';
|
|
12
|
+
import { type AssetsBlock, type AssetsBlockConfig } from '@23blocks/block-assets';
|
|
13
|
+
import { type CampaignsBlock, type CampaignsBlockConfig } from '@23blocks/block-campaigns';
|
|
14
|
+
import { type CompanyBlock, type CompanyBlockConfig } from '@23blocks/block-company';
|
|
15
|
+
import { type RewardsBlock, type RewardsBlockConfig } from '@23blocks/block-rewards';
|
|
16
|
+
import { type SalesBlock, type SalesBlockConfig } from '@23blocks/block-sales';
|
|
17
|
+
import { type WalletBlock, type WalletBlockConfig } from '@23blocks/block-wallet';
|
|
18
|
+
import { type JarvisBlock, type JarvisBlockConfig } from '@23blocks/block-jarvis';
|
|
19
|
+
import { type OnboardingBlock, type OnboardingBlockConfig } from '@23blocks/block-onboarding';
|
|
20
|
+
import { type UniversityBlock, type UniversityBlockConfig } from '@23blocks/block-university';
|
|
21
|
+
export interface Blocks23Context {
|
|
22
|
+
transport: Transport;
|
|
23
|
+
authentication: AuthenticationBlock | null;
|
|
24
|
+
search: SearchBlock | null;
|
|
25
|
+
products: ProductsBlock | null;
|
|
26
|
+
crm: CrmBlock | null;
|
|
27
|
+
content: ContentBlock | null;
|
|
28
|
+
geolocation: GeolocationBlock | null;
|
|
29
|
+
conversations: ConversationsBlock | null;
|
|
30
|
+
files: FilesBlock | null;
|
|
31
|
+
forms: FormsBlock | null;
|
|
32
|
+
assets: AssetsBlock | null;
|
|
33
|
+
campaigns: CampaignsBlock | null;
|
|
34
|
+
company: CompanyBlock | null;
|
|
35
|
+
rewards: RewardsBlock | null;
|
|
36
|
+
sales: SalesBlock | null;
|
|
37
|
+
wallet: WalletBlock | null;
|
|
38
|
+
jarvis: JarvisBlock | null;
|
|
39
|
+
onboarding: OnboardingBlock | null;
|
|
40
|
+
university: UniversityBlock | null;
|
|
41
|
+
}
|
|
42
|
+
export interface Blocks23ProviderProps {
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
transport: Transport;
|
|
45
|
+
authentication?: AuthenticationBlockConfig;
|
|
46
|
+
search?: SearchBlockConfig;
|
|
47
|
+
products?: ProductsBlockConfig;
|
|
48
|
+
crm?: CrmBlockConfig;
|
|
49
|
+
content?: ContentBlockConfig;
|
|
50
|
+
geolocation?: GeolocationBlockConfig;
|
|
51
|
+
conversations?: ConversationsBlockConfig;
|
|
52
|
+
files?: FilesBlockConfig;
|
|
53
|
+
forms?: FormsBlockConfig;
|
|
54
|
+
assets?: AssetsBlockConfig;
|
|
55
|
+
campaigns?: CampaignsBlockConfig;
|
|
56
|
+
company?: CompanyBlockConfig;
|
|
57
|
+
rewards?: RewardsBlockConfig;
|
|
58
|
+
sales?: SalesBlockConfig;
|
|
59
|
+
wallet?: WalletBlockConfig;
|
|
60
|
+
jarvis?: JarvisBlockConfig;
|
|
61
|
+
onboarding?: OnboardingBlockConfig;
|
|
62
|
+
university?: UniversityBlockConfig;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Provider component for 23blocks services.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```tsx
|
|
69
|
+
* import { Blocks23Provider } from '@23blocks/react';
|
|
70
|
+
* import { createHttpTransport } from '@23blocks/transport-http';
|
|
71
|
+
*
|
|
72
|
+
* const transport = createHttpTransport({
|
|
73
|
+
* baseUrl: 'https://api.example.com',
|
|
74
|
+
* headers: () => ({
|
|
75
|
+
* 'Authorization': `Bearer ${localStorage.getItem('token')}`,
|
|
76
|
+
* }),
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* function App() {
|
|
80
|
+
* return (
|
|
81
|
+
* <Blocks23Provider
|
|
82
|
+
* transport={transport}
|
|
83
|
+
* authentication={{ appId: 'my-app' }}
|
|
84
|
+
* search={{ appId: 'my-app' }}
|
|
85
|
+
* products={{ appId: 'my-app' }}
|
|
86
|
+
* crm={{ appId: 'my-app' }}
|
|
87
|
+
* >
|
|
88
|
+
* <MyApp />
|
|
89
|
+
* </Blocks23Provider>
|
|
90
|
+
* );
|
|
91
|
+
* }
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function Blocks23Provider({ children, transport, authentication, search, products, crm, content, geolocation, conversations, files, forms, assets, campaigns, company, rewards, sales, wallet, jarvis, onboarding, university, }: Blocks23ProviderProps): any;
|
|
95
|
+
export declare function use23Blocks(): Blocks23Context;
|
|
96
|
+
export declare function useAuthenticationBlock(): AuthenticationBlock;
|
|
97
|
+
export declare function useSearchBlock(): SearchBlock;
|
|
98
|
+
export declare function useProductsBlock(): ProductsBlock;
|
|
99
|
+
export declare function useCrmBlock(): CrmBlock;
|
|
100
|
+
export declare function useContentBlock(): ContentBlock;
|
|
101
|
+
export declare function useGeolocationBlock(): GeolocationBlock;
|
|
102
|
+
export declare function useConversationsBlock(): ConversationsBlock;
|
|
103
|
+
export declare function useFilesBlock(): FilesBlock;
|
|
104
|
+
export declare function useFormsBlock(): FormsBlock;
|
|
105
|
+
export declare function useAssetsBlock(): AssetsBlock;
|
|
106
|
+
export declare function useCampaignsBlock(): CampaignsBlock;
|
|
107
|
+
export declare function useCompanyBlock(): CompanyBlock;
|
|
108
|
+
export declare function useRewardsBlock(): RewardsBlock;
|
|
109
|
+
export declare function useSalesBlock(): SalesBlock;
|
|
110
|
+
export declare function useWalletBlock(): WalletBlock;
|
|
111
|
+
export declare function useJarvisBlock(): JarvisBlock;
|
|
112
|
+
export declare function useOnboardingBlock(): OnboardingBlock;
|
|
113
|
+
export declare function useUniversityBlock(): UniversityBlock;
|
|
114
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/lib/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAA6B,KAAK,mBAAmB,EAAE,KAAK,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AACrI,OAAO,EAAqB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACrG,OAAO,EAAuB,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC7G,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAsB,KAAK,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACzG,OAAO,EAA0B,KAAK,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACzH,OAAO,EAA4B,KAAK,kBAAkB,EAAE,KAAK,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACjI,OAAO,EAAoB,KA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CAAC;CACpC;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,SAAS,EACT,cAAc,EACd,MAAM,EACN,QAAQ,EACR,GAAG,EACH,OAAO,EACP,WAAW,EACX,aAAa,EACb,KAAK,EACL,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,OAAO,EACP,KAAK,EACL,MAAM,EACN,MAAM,EACN,UAAU,EACV,UAAU,GACX,EAAE,qBAAqB,OA4BvB;AAMD,wBAAgB,WAAW,IAAI,eAAe,CAM7C;AAMD,wBAAgB,sBAAsB,IAAI,mBAAmB,CAI5D;AAED,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAIhD;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAItC;AAED,wBAAgB,eAAe,IAAI,YAAY,CAI9C;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAItD;AAED,wBAAgB,qBAAqB,IAAI,kBAAkB,CAI1D;AAED,wBAAgB,aAAa,IAAI,UAAU,CAI1C;AAED,wBAAgB,aAAa,IAAI,UAAU,CAI1C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAIlD;AAED,wBAAgB,eAAe,IAAI,YAAY,CAI9C;AAED,wBAAgB,eAAe,IAAI,YAAY,CAI9C;AAED,wBAAgB,aAAa,IAAI,UAAU,CAI1C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAI5C;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAIpD;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAIpD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { useAuth, type UseAuthReturn, type UseAuthState, type UseAuthActions } from './use-auth.js';
|
|
2
|
+
export { useUsers, type UseUsersReturn, type UseUsersState, type UseUsersActions } from './use-users.js';
|
|
3
|
+
export { useSearch, type UseSearchReturn, type UseSearchState, type UseSearchActions } from './use-search.js';
|
|
4
|
+
export { useFavorites, type UseFavoritesReturn, type UseFavoritesState, type UseFavoritesActions } from './use-favorites.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGzG,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { User, SignInRequest, SignInResponse, SignUpRequest, SignUpResponse, PasswordResetRequest, PasswordUpdateRequest } from '@23blocks/block-authentication';
|
|
2
|
+
export interface UseAuthState {
|
|
3
|
+
user: User | null;
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
isAuthenticated: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseAuthActions {
|
|
9
|
+
signIn: (request: SignInRequest) => Promise<SignInResponse>;
|
|
10
|
+
signUp: (request: SignUpRequest) => Promise<SignUpResponse>;
|
|
11
|
+
signOut: () => Promise<void>;
|
|
12
|
+
requestPasswordReset: (request: PasswordResetRequest) => Promise<void>;
|
|
13
|
+
updatePassword: (request: PasswordUpdateRequest) => Promise<void>;
|
|
14
|
+
refreshUser: () => Promise<void>;
|
|
15
|
+
clearError: () => void;
|
|
16
|
+
}
|
|
17
|
+
export type UseAuthReturn = UseAuthState & UseAuthActions;
|
|
18
|
+
/**
|
|
19
|
+
* Hook for authentication operations with state management.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* function LoginForm() {
|
|
24
|
+
* const { signIn, isLoading, error, user } = useAuth();
|
|
25
|
+
*
|
|
26
|
+
* const handleSubmit = async (e: FormEvent) => {
|
|
27
|
+
* e.preventDefault();
|
|
28
|
+
* try {
|
|
29
|
+
* await signIn({ email, password });
|
|
30
|
+
* navigate('/dashboard');
|
|
31
|
+
* } catch (err) {
|
|
32
|
+
* // Error is automatically captured in `error` state
|
|
33
|
+
* }
|
|
34
|
+
* };
|
|
35
|
+
*
|
|
36
|
+
* if (user) {
|
|
37
|
+
* return <p>Welcome, {user.email}!</p>;
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* return (
|
|
41
|
+
* <form onSubmit={handleSubmit}>
|
|
42
|
+
* {error && <p className="error">{error.message}</p>}
|
|
43
|
+
* <button disabled={isLoading}>
|
|
44
|
+
* {isLoading ? 'Signing in...' : 'Sign In'}
|
|
45
|
+
* </button>
|
|
46
|
+
* </form>
|
|
47
|
+
* );
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function useAuth(): UseAuthReturn;
|
|
52
|
+
//# sourceMappingURL=use-auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-auth.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/use-auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,gCAAgC,CAAC;AAOxC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC5D,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,oBAAoB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvE,cAAc,EAAE,CAAC,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,CAAC;AAM1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,OAAO,IAAI,aAAa,CAqHvC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { FavoriteEntity, AddFavoriteRequest } from '@23blocks/block-search';
|
|
2
|
+
export interface UseFavoritesState {
|
|
3
|
+
favorites: FavoriteEntity[];
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
}
|
|
7
|
+
export interface UseFavoritesActions {
|
|
8
|
+
listFavorites: () => Promise<FavoriteEntity[]>;
|
|
9
|
+
addFavorite: (request: AddFavoriteRequest) => Promise<FavoriteEntity>;
|
|
10
|
+
removeFavorite: (id: string) => Promise<void>;
|
|
11
|
+
isFavorite: (entityUniqueId: string) => Promise<boolean>;
|
|
12
|
+
clearError: () => void;
|
|
13
|
+
}
|
|
14
|
+
export type UseFavoritesReturn = UseFavoritesState & UseFavoritesActions;
|
|
15
|
+
/**
|
|
16
|
+
* Hook for managing favorites.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* function FavoritesList() {
|
|
21
|
+
* const { favorites, listFavorites, removeFavorite, isLoading } = useFavorites();
|
|
22
|
+
*
|
|
23
|
+
* useEffect(() => {
|
|
24
|
+
* listFavorites();
|
|
25
|
+
* }, [listFavorites]);
|
|
26
|
+
*
|
|
27
|
+
* return (
|
|
28
|
+
* <ul>
|
|
29
|
+
* {favorites.map(fav => (
|
|
30
|
+
* <li key={fav.id}>
|
|
31
|
+
* {fav.entityDescription}
|
|
32
|
+
* <button onClick={() => removeFavorite(fav.id)}>Remove</button>
|
|
33
|
+
* </li>
|
|
34
|
+
* ))}
|
|
35
|
+
* </ul>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useFavorites(): UseFavoritesReturn;
|
|
41
|
+
//# sourceMappingURL=use-favorites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-favorites.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/use-favorites.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,wBAAwB,CAAC;AAOhC,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,cAAc,EAAE,CAAC;IAC5B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,aAAa,EAAE,MAAM,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC/C,WAAW,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACtE,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAMzE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,IAAI,kBAAkB,CAgFjD"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { SearchResult, SearchRequest, SearchResponse, EntityType } from '@23blocks/block-search';
|
|
2
|
+
export interface UseSearchState {
|
|
3
|
+
results: SearchResult[];
|
|
4
|
+
totalRecords: number;
|
|
5
|
+
isLoading: boolean;
|
|
6
|
+
error: Error | null;
|
|
7
|
+
query: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UseSearchActions {
|
|
10
|
+
search: (request: SearchRequest) => Promise<SearchResponse>;
|
|
11
|
+
suggest: (query: string, limit?: number) => Promise<SearchResult[]>;
|
|
12
|
+
getEntityTypes: () => Promise<EntityType[]>;
|
|
13
|
+
clearResults: () => void;
|
|
14
|
+
clearError: () => void;
|
|
15
|
+
}
|
|
16
|
+
export type UseSearchReturn = UseSearchState & UseSearchActions;
|
|
17
|
+
/**
|
|
18
|
+
* Hook for search operations with state management.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* function SearchPage() {
|
|
23
|
+
* const { results, search, isLoading, query } = useSearch();
|
|
24
|
+
* const [inputValue, setInputValue] = useState('');
|
|
25
|
+
*
|
|
26
|
+
* const handleSearch = async (e: FormEvent) => {
|
|
27
|
+
* e.preventDefault();
|
|
28
|
+
* await search({ query: inputValue });
|
|
29
|
+
* };
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <div>
|
|
33
|
+
* <form onSubmit={handleSearch}>
|
|
34
|
+
* <input
|
|
35
|
+
* value={inputValue}
|
|
36
|
+
* onChange={(e) => setInputValue(e.target.value)}
|
|
37
|
+
* placeholder="Search..."
|
|
38
|
+
* />
|
|
39
|
+
* <button disabled={isLoading}>Search</button>
|
|
40
|
+
* </form>
|
|
41
|
+
*
|
|
42
|
+
* {query && <p>Results for: {query}</p>}
|
|
43
|
+
*
|
|
44
|
+
* <ul>
|
|
45
|
+
* {results.map(result => (
|
|
46
|
+
* <li key={result.id}>{result.entityDescription}</li>
|
|
47
|
+
* ))}
|
|
48
|
+
* </ul>
|
|
49
|
+
* </div>
|
|
50
|
+
* );
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function useSearch(): UseSearchReturn;
|
|
55
|
+
//# sourceMappingURL=use-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-search.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/use-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,cAAc,EACd,UAAU,EACX,MAAM,wBAAwB,CAAC;AAOhC,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAC5D,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;IACpE,cAAc,EAAE,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC5C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAMhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,SAAS,IAAI,eAAe,CAgF3C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { User, UpdateUserRequest } from '@23blocks/block-authentication';
|
|
2
|
+
export interface UseUsersState {
|
|
3
|
+
users: User[];
|
|
4
|
+
isLoading: boolean;
|
|
5
|
+
error: Error | null;
|
|
6
|
+
}
|
|
7
|
+
export interface UseUsersActions {
|
|
8
|
+
listUsers: (params?: {
|
|
9
|
+
page?: number;
|
|
10
|
+
perPage?: number;
|
|
11
|
+
}) => Promise<User[]>;
|
|
12
|
+
getUser: (id: string) => Promise<User>;
|
|
13
|
+
updateUser: (id: string, request: UpdateUserRequest) => Promise<User>;
|
|
14
|
+
deleteUser: (id: string) => Promise<void>;
|
|
15
|
+
clearError: () => void;
|
|
16
|
+
}
|
|
17
|
+
export type UseUsersReturn = UseUsersState & UseUsersActions;
|
|
18
|
+
/**
|
|
19
|
+
* Hook for user management operations.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* function UserList() {
|
|
24
|
+
* const { users, listUsers, isLoading, error } = useUsers();
|
|
25
|
+
*
|
|
26
|
+
* useEffect(() => {
|
|
27
|
+
* listUsers({ page: 1, perPage: 20 });
|
|
28
|
+
* }, [listUsers]);
|
|
29
|
+
*
|
|
30
|
+
* if (isLoading) return <Spinner />;
|
|
31
|
+
* if (error) return <Error message={error.message} />;
|
|
32
|
+
*
|
|
33
|
+
* return (
|
|
34
|
+
* <ul>
|
|
35
|
+
* {users.map(user => (
|
|
36
|
+
* <li key={user.id}>{user.email}</li>
|
|
37
|
+
* ))}
|
|
38
|
+
* </ul>
|
|
39
|
+
* );
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function useUsers(): UseUsersReturn;
|
|
44
|
+
//# sourceMappingURL=use-users.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-users.d.ts","sourceRoot":"","sources":["../../../../src/lib/hooks/use-users.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,iBAAiB,EAClB,MAAM,gCAAgC,CAAC;AAOxC,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7E,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,eAAe,CAAC;AAM7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,QAAQ,IAAI,cAAc,CAuFzC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { Provider, useClient, useAuth, type ProviderProps, type ClientContext, type ServiceUrls, type AuthMode, type StorageType, type TokenManager, SimpleBlocks23Provider, useSimpleBlocks23, useSimpleAuth, type SimpleBlocks23ProviderProps, type SimpleBlocks23Context, } from './simple-provider.js';
|
|
2
|
+
export { Blocks23Provider, use23Blocks, useAuthenticationBlock, useSearchBlock, useProductsBlock, useCrmBlock, useContentBlock, useGeolocationBlock, useConversationsBlock, useFilesBlock, useFormsBlock, useAssetsBlock, useCampaignsBlock, useCompanyBlock, useRewardsBlock, useSalesBlock, useWalletBlock, useJarvisBlock, useOnboardingBlock, useUniversityBlock, type Blocks23ProviderProps, type Blocks23Context, } from './context.js';
|
|
3
|
+
export { useAuth as useAuthState, useUsers, type UseAuthReturn, type UseAuthState, type UseAuthActions, type UseUsersReturn, type UseUsersState, type UseUsersActions, useSearch, useFavorites, type UseSearchReturn, type UseSearchState, type UseSearchActions, type UseFavoritesReturn, type UseFavoritesState, type UseFavoritesActions, } from './hooks/index.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,QAAQ,EACR,SAAS,EACT,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EAGjB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,sBAAsB,EACtB,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,OAAO,IAAI,YAAY,EACvB,QAAQ,EACR,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,eAAe,EAGpB,SAAS,EACT,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,GACzB,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type AuthenticationBlock, type SignInRequest, type SignInResponse, type SignUpRequest, type SignUpResponse } from '@23blocks/block-authentication';
|
|
3
|
+
import { type SearchBlock } from '@23blocks/block-search';
|
|
4
|
+
import { type ProductsBlock } from '@23blocks/block-products';
|
|
5
|
+
import { type CrmBlock } from '@23blocks/block-crm';
|
|
6
|
+
import { type ContentBlock } from '@23blocks/block-content';
|
|
7
|
+
import { type GeolocationBlock } from '@23blocks/block-geolocation';
|
|
8
|
+
import { type ConversationsBlock } from '@23blocks/block-conversations';
|
|
9
|
+
import { type FilesBlock } from '@23blocks/block-files';
|
|
10
|
+
import { type FormsBlock } from '@23blocks/block-forms';
|
|
11
|
+
import { type AssetsBlock } from '@23blocks/block-assets';
|
|
12
|
+
import { type CampaignsBlock } from '@23blocks/block-campaigns';
|
|
13
|
+
import { type CompanyBlock } from '@23blocks/block-company';
|
|
14
|
+
import { type RewardsBlock } from '@23blocks/block-rewards';
|
|
15
|
+
import { type SalesBlock } from '@23blocks/block-sales';
|
|
16
|
+
import { type WalletBlock } from '@23blocks/block-wallet';
|
|
17
|
+
import { type JarvisBlock } from '@23blocks/block-jarvis';
|
|
18
|
+
import { type OnboardingBlock } from '@23blocks/block-onboarding';
|
|
19
|
+
import { type UniversityBlock } from '@23blocks/block-university';
|
|
20
|
+
/**
|
|
21
|
+
* Authentication mode
|
|
22
|
+
*/
|
|
23
|
+
export type AuthMode = 'token' | 'cookie';
|
|
24
|
+
/**
|
|
25
|
+
* Storage type for token mode
|
|
26
|
+
*/
|
|
27
|
+
export type StorageType = 'localStorage' | 'sessionStorage' | 'memory';
|
|
28
|
+
/**
|
|
29
|
+
* Token manager interface
|
|
30
|
+
*/
|
|
31
|
+
export interface TokenManager {
|
|
32
|
+
getAccessToken(): string | null;
|
|
33
|
+
getRefreshToken(): string | null;
|
|
34
|
+
setTokens(accessToken: string, refreshToken?: string): void;
|
|
35
|
+
clearTokens(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Subscribe to storage changes from other tabs/windows.
|
|
38
|
+
* Returns an unsubscribe function.
|
|
39
|
+
*/
|
|
40
|
+
onStorageChange(callback: () => void): () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Service URL configuration - each microservice has its own URL.
|
|
44
|
+
* All URLs are optional - only configure the services you need.
|
|
45
|
+
*/
|
|
46
|
+
export interface ServiceUrls {
|
|
47
|
+
/** Authentication service URL */
|
|
48
|
+
authentication?: string;
|
|
49
|
+
/** Search service URL */
|
|
50
|
+
search?: string;
|
|
51
|
+
/** Products service URL */
|
|
52
|
+
products?: string;
|
|
53
|
+
/** CRM service URL */
|
|
54
|
+
crm?: string;
|
|
55
|
+
/** Content service URL */
|
|
56
|
+
content?: string;
|
|
57
|
+
/** Geolocation service URL */
|
|
58
|
+
geolocation?: string;
|
|
59
|
+
/** Conversations service URL */
|
|
60
|
+
conversations?: string;
|
|
61
|
+
/** Files service URL */
|
|
62
|
+
files?: string;
|
|
63
|
+
/** Forms service URL */
|
|
64
|
+
forms?: string;
|
|
65
|
+
/** Assets service URL */
|
|
66
|
+
assets?: string;
|
|
67
|
+
/** Campaigns service URL */
|
|
68
|
+
campaigns?: string;
|
|
69
|
+
/** Company service URL */
|
|
70
|
+
company?: string;
|
|
71
|
+
/** Rewards service URL */
|
|
72
|
+
rewards?: string;
|
|
73
|
+
/** Sales service URL */
|
|
74
|
+
sales?: string;
|
|
75
|
+
/** Wallet service URL */
|
|
76
|
+
wallet?: string;
|
|
77
|
+
/** Jarvis (AI) service URL */
|
|
78
|
+
jarvis?: string;
|
|
79
|
+
/** Onboarding service URL */
|
|
80
|
+
onboarding?: string;
|
|
81
|
+
/** University (LMS) service URL */
|
|
82
|
+
university?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Provider props
|
|
86
|
+
*/
|
|
87
|
+
export interface ProviderProps {
|
|
88
|
+
children: ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* Service URLs for each microservice.
|
|
91
|
+
* Only configure the services you need - accessing a service without
|
|
92
|
+
* a configured URL will throw an error.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* <Provider
|
|
97
|
+
* appId="your-app-id"
|
|
98
|
+
* urls={{
|
|
99
|
+
* authentication: 'https://gateway.23blocks.com',
|
|
100
|
+
* crm: 'https://crm.23blocks.com',
|
|
101
|
+
* products: 'https://products.23blocks.com',
|
|
102
|
+
* }}
|
|
103
|
+
* >
|
|
104
|
+
* <App />
|
|
105
|
+
* </Provider>
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
urls: ServiceUrls;
|
|
109
|
+
/**
|
|
110
|
+
* Application ID
|
|
111
|
+
*/
|
|
112
|
+
appId: string;
|
|
113
|
+
/**
|
|
114
|
+
* Tenant ID (optional, for multi-tenant setups)
|
|
115
|
+
*/
|
|
116
|
+
tenantId?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Authentication mode
|
|
119
|
+
* - 'token' (default): SDK stores tokens in localStorage/sessionStorage/memory
|
|
120
|
+
* - 'cookie': Backend manages auth via httpOnly cookies
|
|
121
|
+
*/
|
|
122
|
+
authMode?: AuthMode;
|
|
123
|
+
/**
|
|
124
|
+
* Storage type for token mode
|
|
125
|
+
* @default 'localStorage'
|
|
126
|
+
*/
|
|
127
|
+
storage?: StorageType;
|
|
128
|
+
/**
|
|
129
|
+
* Additional headers to include with every request
|
|
130
|
+
*/
|
|
131
|
+
headers?: Record<string, string>;
|
|
132
|
+
/**
|
|
133
|
+
* Request timeout in milliseconds
|
|
134
|
+
* @default 30000
|
|
135
|
+
*/
|
|
136
|
+
timeout?: number;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Context value providing access to all 23blocks services
|
|
140
|
+
*/
|
|
141
|
+
export interface ClientContext {
|
|
142
|
+
authentication: AuthenticationBlock;
|
|
143
|
+
search: SearchBlock;
|
|
144
|
+
products: ProductsBlock;
|
|
145
|
+
crm: CrmBlock;
|
|
146
|
+
content: ContentBlock;
|
|
147
|
+
geolocation: GeolocationBlock;
|
|
148
|
+
conversations: ConversationsBlock;
|
|
149
|
+
files: FilesBlock;
|
|
150
|
+
forms: FormsBlock;
|
|
151
|
+
assets: AssetsBlock;
|
|
152
|
+
campaigns: CampaignsBlock;
|
|
153
|
+
company: CompanyBlock;
|
|
154
|
+
rewards: RewardsBlock;
|
|
155
|
+
sales: SalesBlock;
|
|
156
|
+
wallet: WalletBlock;
|
|
157
|
+
jarvis: JarvisBlock;
|
|
158
|
+
onboarding: OnboardingBlock;
|
|
159
|
+
university: UniversityBlock;
|
|
160
|
+
signIn: (request: SignInRequest) => Promise<SignInResponse>;
|
|
161
|
+
signUp: (request: SignUpRequest) => Promise<SignUpResponse>;
|
|
162
|
+
signOut: () => Promise<void>;
|
|
163
|
+
getAccessToken: () => string | null;
|
|
164
|
+
getRefreshToken: () => string | null;
|
|
165
|
+
setTokens: (accessToken: string, refreshToken?: string) => void;
|
|
166
|
+
clearTokens: () => void;
|
|
167
|
+
isAuthenticated: () => boolean | null;
|
|
168
|
+
/**
|
|
169
|
+
* Subscribe to token changes from other tabs/windows.
|
|
170
|
+
* Returns an unsubscribe function.
|
|
171
|
+
*/
|
|
172
|
+
onStorageChange: (callback: () => void) => () => void;
|
|
173
|
+
authMode: AuthMode;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Provider component for 23blocks services.
|
|
177
|
+
*
|
|
178
|
+
* Wrap your app with this provider to access all 23blocks services
|
|
179
|
+
* with automatic token management.
|
|
180
|
+
*
|
|
181
|
+
* Services are only available if their URL is configured. Accessing
|
|
182
|
+
* a service without a configured URL will throw an error.
|
|
183
|
+
*
|
|
184
|
+
* @example Basic usage with multiple services
|
|
185
|
+
* ```tsx
|
|
186
|
+
* import { Provider } from '@23blocks/react';
|
|
187
|
+
*
|
|
188
|
+
* function App() {
|
|
189
|
+
* return (
|
|
190
|
+
* <Provider
|
|
191
|
+
* appId="your-app-id"
|
|
192
|
+
* urls={{
|
|
193
|
+
* authentication: 'https://gateway.23blocks.com',
|
|
194
|
+
* crm: 'https://crm.23blocks.com',
|
|
195
|
+
* products: 'https://products.23blocks.com',
|
|
196
|
+
* }}
|
|
197
|
+
* >
|
|
198
|
+
* <MyApp />
|
|
199
|
+
* </Provider>
|
|
200
|
+
* );
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*
|
|
204
|
+
* @example Cookie mode (recommended for security)
|
|
205
|
+
* ```tsx
|
|
206
|
+
* <Provider
|
|
207
|
+
* appId="your-app-id"
|
|
208
|
+
* authMode="cookie"
|
|
209
|
+
* urls={{
|
|
210
|
+
* authentication: 'https://gateway.23blocks.com',
|
|
211
|
+
* crm: 'https://crm.23blocks.com',
|
|
212
|
+
* }}
|
|
213
|
+
* >
|
|
214
|
+
* <MyApp />
|
|
215
|
+
* </Provider>
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
export declare function Provider({ children, urls, appId, tenantId, authMode, storage, headers: staticHeaders, timeout, }: ProviderProps): any;
|
|
219
|
+
/**
|
|
220
|
+
* Hook to access all 23blocks services.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```tsx
|
|
224
|
+
* function Dashboard() {
|
|
225
|
+
* const { products, crm, files } = useClient();
|
|
226
|
+
*
|
|
227
|
+
* // Access any service
|
|
228
|
+
* const loadProducts = async () => {
|
|
229
|
+
* const { data } = await products.products.list({ limit: 10 });
|
|
230
|
+
* };
|
|
231
|
+
* }
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export declare function useClient(): ClientContext;
|
|
235
|
+
/**
|
|
236
|
+
* Hook for authentication operations with automatic token management.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```tsx
|
|
240
|
+
* function LoginPage() {
|
|
241
|
+
* const { signIn, signOut, isAuthenticated } = useAuth();
|
|
242
|
+
*
|
|
243
|
+
* const handleLogin = async () => {
|
|
244
|
+
* await signIn({ email: 'user@example.com', password: 'password' });
|
|
245
|
+
* };
|
|
246
|
+
*
|
|
247
|
+
* return (
|
|
248
|
+
* <div>
|
|
249
|
+
* {isAuthenticated() ? (
|
|
250
|
+
* <button onClick={signOut}>Sign Out</button>
|
|
251
|
+
* ) : (
|
|
252
|
+
* <button onClick={handleLogin}>Sign In</button>
|
|
253
|
+
* )}
|
|
254
|
+
* </div>
|
|
255
|
+
* );
|
|
256
|
+
* }
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
export declare function useAuth(): {
|
|
260
|
+
signIn: (request: SignInRequest) => Promise<SignInResponse>;
|
|
261
|
+
signUp: (request: SignUpRequest) => Promise<SignUpResponse>;
|
|
262
|
+
signOut: () => Promise<void>;
|
|
263
|
+
getAccessToken: () => string | null;
|
|
264
|
+
getRefreshToken: () => string | null;
|
|
265
|
+
setTokens: (accessToken: string, refreshToken?: string) => void;
|
|
266
|
+
clearTokens: () => void;
|
|
267
|
+
isAuthenticated: () => boolean | null;
|
|
268
|
+
onStorageChange: (callback: () => void) => () => void;
|
|
269
|
+
authentication: AuthenticationBlock;
|
|
270
|
+
};
|
|
271
|
+
/** @deprecated Use `Provider` instead */
|
|
272
|
+
export declare const SimpleBlocks23Provider: typeof Provider;
|
|
273
|
+
/** @deprecated Use `ProviderProps` instead */
|
|
274
|
+
export type SimpleBlocks23ProviderProps = ProviderProps;
|
|
275
|
+
/** @deprecated Use `ClientContext` instead */
|
|
276
|
+
export type SimpleBlocks23Context = ClientContext;
|
|
277
|
+
/** @deprecated Use `useClient` instead */
|
|
278
|
+
export declare const useSimpleBlocks23: typeof useClient;
|
|
279
|
+
/** @deprecated Use `useAuth` instead */
|
|
280
|
+
export declare const useSimpleAuth: typeof useAuth;
|
|
281
|
+
//# sourceMappingURL=simple-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simple-provider.d.ts","sourceRoot":"","sources":["../../../src/lib/simple-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAGxF,OAAO,EAA6B,KAAK,mBAAmB,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACvL,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC5F,OAAO,EAA4B,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAClG,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM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