@pubflow/react 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/LICENSE +661 -0
- package/README.md +539 -0
- package/dist/index.d.ts +1908 -0
- package/dist/index.esm.js +9922 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +9954 -0
- package/dist/index.js.map +1 -0
- package/dist/types/components/AdvancedFilter.d.ts +113 -0
- package/dist/types/components/BridgeForm/index.d.ts +6 -0
- package/dist/types/components/BridgeForm/styles.d.ts +62 -0
- package/dist/types/components/BridgeForm/types.d.ts +128 -0
- package/dist/types/components/BridgeForm/utils.d.ts +60 -0
- package/dist/types/components/BridgeList.d.ts +157 -0
- package/dist/types/components/BridgeTable.d.ts +110 -0
- package/dist/types/components/BridgeView.d.ts +39 -0
- package/dist/types/components/OfflineIndicator.d.ts +58 -0
- package/dist/types/components/auth/AccountCreationForm.d.ts +60 -0
- package/dist/types/components/auth/LoginForm.d.ts +76 -0
- package/dist/types/components/auth/PasswordResetForm.d.ts +60 -0
- package/dist/types/components/auth/index.d.ts +8 -0
- package/dist/types/components/theme/ThemeProvider.d.ts +255 -0
- package/dist/types/components/theme/index.d.ts +6 -0
- package/dist/types/context/PubflowProvider.d.ts +100 -0
- package/dist/types/hooks/useAuth.d.ts +32 -0
- package/dist/types/hooks/useBridgeApi.d.ts +14 -0
- package/dist/types/hooks/useBridgeApiRaw.d.ts +91 -0
- package/dist/types/hooks/useBridgeCrud.d.ts +193 -0
- package/dist/types/hooks/useBridgeMutation.d.ts +69 -0
- package/dist/types/hooks/useBridgeQuery.d.ts +44 -0
- package/dist/types/hooks/useSearchQueryBuilder.d.ts +152 -0
- package/dist/types/hooks/useServerAuth.d.ts +45 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/storage/BrowserStorageAdapter.d.ts +112 -0
- package/dist/types/test/setup.d.ts +4 -0
- package/dist/types/utils/auth-utils.d.ts +37 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/persistent-cache.d.ts +57 -0
- package/package.json +70 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge API Raw Hook for React
|
|
3
|
+
*
|
|
4
|
+
* Provides raw API access for custom operations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Raw API request options
|
|
8
|
+
*/
|
|
9
|
+
export interface RawApiRequestOptions {
|
|
10
|
+
/**
|
|
11
|
+
* HTTP method
|
|
12
|
+
*/
|
|
13
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
14
|
+
/**
|
|
15
|
+
* Request headers
|
|
16
|
+
*/
|
|
17
|
+
headers?: Record<string, string>;
|
|
18
|
+
/**
|
|
19
|
+
* Request body
|
|
20
|
+
*/
|
|
21
|
+
body?: any;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to include session in request
|
|
24
|
+
*/
|
|
25
|
+
includeSession?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Request timeout in milliseconds
|
|
28
|
+
*/
|
|
29
|
+
timeout?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Raw API response
|
|
33
|
+
*/
|
|
34
|
+
export interface RawApiResponse<T = any> {
|
|
35
|
+
/**
|
|
36
|
+
* Response data
|
|
37
|
+
*/
|
|
38
|
+
data: T;
|
|
39
|
+
/**
|
|
40
|
+
* Response status
|
|
41
|
+
*/
|
|
42
|
+
status: number;
|
|
43
|
+
/**
|
|
44
|
+
* Response headers
|
|
45
|
+
*/
|
|
46
|
+
headers: Record<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the request was successful
|
|
49
|
+
*/
|
|
50
|
+
success: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Error message if any
|
|
53
|
+
*/
|
|
54
|
+
error?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Bridge API Raw hook result
|
|
58
|
+
*/
|
|
59
|
+
export interface UseBridgeApiRawResult {
|
|
60
|
+
/**
|
|
61
|
+
* Make a raw API request
|
|
62
|
+
*/
|
|
63
|
+
request: <T = any>(endpoint: string, options?: RawApiRequestOptions) => Promise<RawApiResponse<T>>;
|
|
64
|
+
/**
|
|
65
|
+
* GET request shorthand
|
|
66
|
+
*/
|
|
67
|
+
get: <T = any>(endpoint: string, options?: Omit<RawApiRequestOptions, 'method'>) => Promise<RawApiResponse<T>>;
|
|
68
|
+
/**
|
|
69
|
+
* POST request shorthand
|
|
70
|
+
*/
|
|
71
|
+
post: <T = any>(endpoint: string, body?: any, options?: Omit<RawApiRequestOptions, 'method' | 'body'>) => Promise<RawApiResponse<T>>;
|
|
72
|
+
/**
|
|
73
|
+
* PUT request shorthand
|
|
74
|
+
*/
|
|
75
|
+
put: <T = any>(endpoint: string, body?: any, options?: Omit<RawApiRequestOptions, 'method' | 'body'>) => Promise<RawApiResponse<T>>;
|
|
76
|
+
/**
|
|
77
|
+
* DELETE request shorthand
|
|
78
|
+
*/
|
|
79
|
+
delete: <T = any>(endpoint: string, options?: Omit<RawApiRequestOptions, 'method'>) => Promise<RawApiResponse<T>>;
|
|
80
|
+
/**
|
|
81
|
+
* PATCH request shorthand
|
|
82
|
+
*/
|
|
83
|
+
patch: <T = any>(endpoint: string, body?: any, options?: Omit<RawApiRequestOptions, 'method' | 'body'>) => Promise<RawApiResponse<T>>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Hook for raw Bridge API access
|
|
87
|
+
*
|
|
88
|
+
* @param instanceId Pubflow instance ID
|
|
89
|
+
* @returns Raw API hook result
|
|
90
|
+
*/
|
|
91
|
+
export declare function useBridgeApiRaw(instanceId?: string): UseBridgeApiRawResult;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge CRUD Hook for React
|
|
3
|
+
*
|
|
4
|
+
* Provides a hook for CRUD operations using Bridge API
|
|
5
|
+
*/
|
|
6
|
+
import { EntityConfig, EntityData, FilterOperator } from '@pubflow/core';
|
|
7
|
+
import { MutationOptions } from './useBridgeMutation';
|
|
8
|
+
/**
|
|
9
|
+
* Search configuration
|
|
10
|
+
*/
|
|
11
|
+
export interface SearchConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Initial search term
|
|
14
|
+
*/
|
|
15
|
+
initialSearchTerm?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Initial filters
|
|
18
|
+
*/
|
|
19
|
+
initialFilters?: Array<{
|
|
20
|
+
field: string;
|
|
21
|
+
operator: FilterOperator | string;
|
|
22
|
+
value: any;
|
|
23
|
+
}>;
|
|
24
|
+
/**
|
|
25
|
+
* Initial sort
|
|
26
|
+
*/
|
|
27
|
+
initialSort?: {
|
|
28
|
+
field: string;
|
|
29
|
+
direction: 'asc' | 'desc';
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Initial page
|
|
33
|
+
*/
|
|
34
|
+
initialPage?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Initial limit
|
|
37
|
+
*/
|
|
38
|
+
initialLimit?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Fields to search
|
|
41
|
+
*/
|
|
42
|
+
searchFields?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* Debounce time in milliseconds
|
|
45
|
+
*/
|
|
46
|
+
debounceMs?: number;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to search automatically
|
|
49
|
+
*/
|
|
50
|
+
autoSearch?: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Entity schemas
|
|
54
|
+
*/
|
|
55
|
+
export interface EntitySchemas<T, U, V> {
|
|
56
|
+
/**
|
|
57
|
+
* Schema for the complete entity
|
|
58
|
+
*/
|
|
59
|
+
entity?: any;
|
|
60
|
+
/**
|
|
61
|
+
* Schema for creating an entity
|
|
62
|
+
*/
|
|
63
|
+
create?: any;
|
|
64
|
+
/**
|
|
65
|
+
* Schema for updating an entity
|
|
66
|
+
*/
|
|
67
|
+
update?: any;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Success messages
|
|
71
|
+
*/
|
|
72
|
+
export interface SuccessMessages {
|
|
73
|
+
/**
|
|
74
|
+
* Success message for create operation
|
|
75
|
+
*/
|
|
76
|
+
create?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Success message for update operation
|
|
79
|
+
*/
|
|
80
|
+
update?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Success message for delete operation
|
|
83
|
+
*/
|
|
84
|
+
delete?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Error messages
|
|
88
|
+
*/
|
|
89
|
+
export interface ErrorMessages {
|
|
90
|
+
/**
|
|
91
|
+
* Error message for create operation
|
|
92
|
+
*/
|
|
93
|
+
create?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Error message for update operation
|
|
96
|
+
*/
|
|
97
|
+
update?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Error message for delete operation
|
|
100
|
+
*/
|
|
101
|
+
delete?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Error message for fetch operation
|
|
104
|
+
*/
|
|
105
|
+
fetch?: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Bridge CRUD hook options
|
|
109
|
+
*/
|
|
110
|
+
export interface UseBridgeCrudOptions<T extends EntityData, U = Partial<T>, V = Partial<T>> {
|
|
111
|
+
/**
|
|
112
|
+
* Entity configuration
|
|
113
|
+
*/
|
|
114
|
+
entityConfig: EntityConfig;
|
|
115
|
+
/**
|
|
116
|
+
* Pubflow instance ID
|
|
117
|
+
*/
|
|
118
|
+
instanceId?: string;
|
|
119
|
+
/**
|
|
120
|
+
* Entity schemas
|
|
121
|
+
*/
|
|
122
|
+
schemas?: EntitySchemas<T, U, V>;
|
|
123
|
+
/**
|
|
124
|
+
* Search configuration
|
|
125
|
+
*/
|
|
126
|
+
searchConfig?: SearchConfig;
|
|
127
|
+
/**
|
|
128
|
+
* Success messages
|
|
129
|
+
*/
|
|
130
|
+
successMessages?: SuccessMessages;
|
|
131
|
+
/**
|
|
132
|
+
* Error messages
|
|
133
|
+
*/
|
|
134
|
+
errorMessages?: ErrorMessages;
|
|
135
|
+
/**
|
|
136
|
+
* Notification configuration
|
|
137
|
+
*/
|
|
138
|
+
notificationConfig?: {
|
|
139
|
+
/**
|
|
140
|
+
* Whether to show notifications automatically
|
|
141
|
+
*/
|
|
142
|
+
autoNotify?: boolean;
|
|
143
|
+
/**
|
|
144
|
+
* Function to show notifications
|
|
145
|
+
*/
|
|
146
|
+
showNotification?: (message: string, type: 'success' | 'error') => void;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Bridge CRUD hook result
|
|
151
|
+
*/
|
|
152
|
+
export interface UseBridgeCrudResult<T extends EntityData> {
|
|
153
|
+
items: T[];
|
|
154
|
+
selectedItem: T | null;
|
|
155
|
+
totalItems: number;
|
|
156
|
+
loading: boolean;
|
|
157
|
+
creating: boolean;
|
|
158
|
+
updating: boolean;
|
|
159
|
+
deleting: boolean;
|
|
160
|
+
error: Error | null;
|
|
161
|
+
validationErrors: Record<string, string[]> | null;
|
|
162
|
+
page: number;
|
|
163
|
+
limit: number;
|
|
164
|
+
hasMore: boolean;
|
|
165
|
+
setPage: (page: number) => void;
|
|
166
|
+
setLimit: (limit: number) => void;
|
|
167
|
+
orderBy: string | undefined;
|
|
168
|
+
orderDir: 'asc' | 'desc' | undefined;
|
|
169
|
+
setSort: (field: string, direction?: 'asc' | 'desc') => void;
|
|
170
|
+
searchTerm: string;
|
|
171
|
+
setSearchTerm: (term: string) => void;
|
|
172
|
+
filters: Array<{
|
|
173
|
+
field: string;
|
|
174
|
+
operator: FilterOperator | string;
|
|
175
|
+
value: any;
|
|
176
|
+
}>;
|
|
177
|
+
addFilter: (field: string, operator: FilterOperator | string, value: any) => void;
|
|
178
|
+
removeFilter: (field: string) => void;
|
|
179
|
+
resetFilters: () => void;
|
|
180
|
+
getItem: (id: string) => Promise<T>;
|
|
181
|
+
createItem: (data: Partial<T>, options?: MutationOptions) => Promise<T>;
|
|
182
|
+
updateItem: (id: string, data: Partial<T>, options?: MutationOptions) => Promise<T>;
|
|
183
|
+
deleteItem: (id: string, options?: MutationOptions) => Promise<void>;
|
|
184
|
+
refresh: () => Promise<void>;
|
|
185
|
+
selectItem: (item: T | null) => void;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Hook for CRUD operations using Bridge API
|
|
189
|
+
*
|
|
190
|
+
* @param options Hook options
|
|
191
|
+
* @returns CRUD hook result
|
|
192
|
+
*/
|
|
193
|
+
export declare function useBridgeCrud<T extends EntityData, U = Partial<T>, V = Partial<T>>(options: UseBridgeCrudOptions<T, U, V>): UseBridgeCrudResult<T>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Mutation Hook for React
|
|
3
|
+
*
|
|
4
|
+
* Provides a hook for mutating data using Bridge API
|
|
5
|
+
*/
|
|
6
|
+
import { BridgeApiService, EntityData } from '@pubflow/core';
|
|
7
|
+
/**
|
|
8
|
+
* Mutation types
|
|
9
|
+
*/
|
|
10
|
+
type MutationType = 'create' | 'update' | 'delete';
|
|
11
|
+
/**
|
|
12
|
+
* Mutation parameters
|
|
13
|
+
*/
|
|
14
|
+
type MutationParams<T, M> = M extends 'create' ? Partial<T> : M extends 'update' ? {
|
|
15
|
+
id: string;
|
|
16
|
+
data: Partial<T>;
|
|
17
|
+
} : M extends 'delete' ? string : never;
|
|
18
|
+
/**
|
|
19
|
+
* Mutation result
|
|
20
|
+
*/
|
|
21
|
+
type MutationResult<T, M> = M extends 'create' ? T : M extends 'update' ? T : M extends 'delete' ? void : never;
|
|
22
|
+
/**
|
|
23
|
+
* Mutation options
|
|
24
|
+
*/
|
|
25
|
+
export interface MutationOptions {
|
|
26
|
+
/**
|
|
27
|
+
* Whether to invalidate queries after mutation
|
|
28
|
+
*/
|
|
29
|
+
invalidateQueries?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Success message
|
|
32
|
+
*/
|
|
33
|
+
successMessage?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Error message
|
|
36
|
+
*/
|
|
37
|
+
errorMessage?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Success callback
|
|
40
|
+
*/
|
|
41
|
+
onSuccess?: (data: any) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Error callback
|
|
44
|
+
*/
|
|
45
|
+
onError?: (error: Error) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Whether to show alerts for success/error
|
|
48
|
+
*/
|
|
49
|
+
showAlerts?: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Bridge mutation hook result
|
|
53
|
+
*/
|
|
54
|
+
export interface UseBridgeMutationResult<T, M extends MutationType> {
|
|
55
|
+
mutate: (params: MutationParams<T, M>, options?: MutationOptions) => Promise<MutationResult<T, M>>;
|
|
56
|
+
isLoading: boolean;
|
|
57
|
+
error: Error | null;
|
|
58
|
+
reset: () => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Hook for mutating data using Bridge API
|
|
62
|
+
*
|
|
63
|
+
* @param service Bridge API service
|
|
64
|
+
* @param type Mutation type
|
|
65
|
+
* @param defaultOptions Default mutation options
|
|
66
|
+
* @returns Mutation result
|
|
67
|
+
*/
|
|
68
|
+
export declare function useBridgeMutation<T extends EntityData, M extends MutationType>(service: BridgeApiService<T>, type: M, defaultOptions?: MutationOptions): UseBridgeMutationResult<T, M>;
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Query Hook for React
|
|
3
|
+
*
|
|
4
|
+
* Provides a hook for querying data using Bridge API with SWR
|
|
5
|
+
*/
|
|
6
|
+
import { SWRConfiguration } from 'swr';
|
|
7
|
+
import { BridgeApiService, EntityData, SearchParams, QueryParams as CoreQueryParams } from '@pubflow/core';
|
|
8
|
+
/**
|
|
9
|
+
* Bridge query types
|
|
10
|
+
*/
|
|
11
|
+
type QueryType = 'list' | 'get' | 'search';
|
|
12
|
+
/**
|
|
13
|
+
* Bridge query parameters
|
|
14
|
+
*/
|
|
15
|
+
type BridgeQueryParams<T> = T extends 'list' ? CoreQueryParams : T extends 'get' ? {
|
|
16
|
+
id: string;
|
|
17
|
+
params?: CoreQueryParams;
|
|
18
|
+
} : T extends 'search' ? SearchParams : never;
|
|
19
|
+
/**
|
|
20
|
+
* Bridge query hook result
|
|
21
|
+
*/
|
|
22
|
+
export interface UseBridgeQueryResult<T extends EntityData, Q extends QueryType> {
|
|
23
|
+
data: Q extends 'list' | 'search' ? T[] : T | null;
|
|
24
|
+
meta: Q extends 'list' | 'search' ? {
|
|
25
|
+
page: number;
|
|
26
|
+
limit: number;
|
|
27
|
+
total: number;
|
|
28
|
+
hasMore: boolean;
|
|
29
|
+
} : null;
|
|
30
|
+
isLoading: boolean;
|
|
31
|
+
error: Error | null;
|
|
32
|
+
refetch: () => Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Hook for querying data using Bridge API with SWR
|
|
36
|
+
*
|
|
37
|
+
* @param service Bridge API service
|
|
38
|
+
* @param type Query type
|
|
39
|
+
* @param params Query parameters
|
|
40
|
+
* @param config SWR configuration
|
|
41
|
+
* @returns Query result
|
|
42
|
+
*/
|
|
43
|
+
export declare function useBridgeQuery<T extends EntityData, Q extends QueryType>(service: BridgeApiService<T>, type: Q, params: BridgeQueryParams<Q>, config?: SWRConfiguration): UseBridgeQueryResult<T, Q>;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search Query Builder Hook for React
|
|
3
|
+
*
|
|
4
|
+
* Provides utilities for building complex search queries
|
|
5
|
+
*/
|
|
6
|
+
import { FilterDefinition, FilterOperator } from '@pubflow/core';
|
|
7
|
+
/**
|
|
8
|
+
* Search field definition
|
|
9
|
+
*/
|
|
10
|
+
export interface SearchField {
|
|
11
|
+
/**
|
|
12
|
+
* Field name
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Display label
|
|
17
|
+
*/
|
|
18
|
+
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* Field type
|
|
21
|
+
*/
|
|
22
|
+
type: 'text' | 'number' | 'date' | 'boolean' | 'select';
|
|
23
|
+
/**
|
|
24
|
+
* Whether the field is searchable
|
|
25
|
+
*/
|
|
26
|
+
searchable?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the field is filterable
|
|
29
|
+
*/
|
|
30
|
+
filterable?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the field is sortable
|
|
33
|
+
*/
|
|
34
|
+
sortable?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Options for select type
|
|
37
|
+
*/
|
|
38
|
+
options?: {
|
|
39
|
+
label: string;
|
|
40
|
+
value: any;
|
|
41
|
+
}[];
|
|
42
|
+
/**
|
|
43
|
+
* Default operator for this field
|
|
44
|
+
*/
|
|
45
|
+
defaultOperator?: FilterOperator;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Search query state
|
|
49
|
+
*/
|
|
50
|
+
export interface SearchQueryState {
|
|
51
|
+
/**
|
|
52
|
+
* Search term
|
|
53
|
+
*/
|
|
54
|
+
searchTerm: string;
|
|
55
|
+
/**
|
|
56
|
+
* Active filters
|
|
57
|
+
*/
|
|
58
|
+
filters: FilterDefinition[];
|
|
59
|
+
/**
|
|
60
|
+
* Sort field
|
|
61
|
+
*/
|
|
62
|
+
sortField?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Sort direction
|
|
65
|
+
*/
|
|
66
|
+
sortDirection?: 'asc' | 'desc';
|
|
67
|
+
/**
|
|
68
|
+
* Current page
|
|
69
|
+
*/
|
|
70
|
+
page: number;
|
|
71
|
+
/**
|
|
72
|
+
* Items per page
|
|
73
|
+
*/
|
|
74
|
+
limit: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Search query builder hook result
|
|
78
|
+
*/
|
|
79
|
+
export interface UseSearchQueryBuilderResult {
|
|
80
|
+
/**
|
|
81
|
+
* Current query state
|
|
82
|
+
*/
|
|
83
|
+
queryState: SearchQueryState;
|
|
84
|
+
/**
|
|
85
|
+
* Set search term
|
|
86
|
+
*/
|
|
87
|
+
setSearchTerm: (term: string) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Add a filter
|
|
90
|
+
*/
|
|
91
|
+
addFilter: (filter: FilterDefinition) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Remove a filter by index
|
|
94
|
+
*/
|
|
95
|
+
removeFilter: (index: number) => void;
|
|
96
|
+
/**
|
|
97
|
+
* Update a filter
|
|
98
|
+
*/
|
|
99
|
+
updateFilter: (index: number, filter: FilterDefinition) => void;
|
|
100
|
+
/**
|
|
101
|
+
* Clear all filters
|
|
102
|
+
*/
|
|
103
|
+
clearFilters: () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Set sort
|
|
106
|
+
*/
|
|
107
|
+
setSort: (field: string, direction: 'asc' | 'desc') => void;
|
|
108
|
+
/**
|
|
109
|
+
* Clear sort
|
|
110
|
+
*/
|
|
111
|
+
clearSort: () => void;
|
|
112
|
+
/**
|
|
113
|
+
* Set page
|
|
114
|
+
*/
|
|
115
|
+
setPage: (page: number) => void;
|
|
116
|
+
/**
|
|
117
|
+
* Set limit
|
|
118
|
+
*/
|
|
119
|
+
setLimit: (limit: number) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Reset query to initial state
|
|
122
|
+
*/
|
|
123
|
+
resetQuery: () => void;
|
|
124
|
+
/**
|
|
125
|
+
* Build query string for API
|
|
126
|
+
*/
|
|
127
|
+
buildQueryString: () => string;
|
|
128
|
+
/**
|
|
129
|
+
* Build query object for API
|
|
130
|
+
*/
|
|
131
|
+
buildQueryObject: () => Record<string, any>;
|
|
132
|
+
/**
|
|
133
|
+
* Get searchable fields
|
|
134
|
+
*/
|
|
135
|
+
getSearchableFields: () => SearchField[];
|
|
136
|
+
/**
|
|
137
|
+
* Get filterable fields
|
|
138
|
+
*/
|
|
139
|
+
getFilterableFields: () => SearchField[];
|
|
140
|
+
/**
|
|
141
|
+
* Get sortable fields
|
|
142
|
+
*/
|
|
143
|
+
getSortableFields: () => SearchField[];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Hook for building search queries
|
|
147
|
+
*
|
|
148
|
+
* @param fields Available search fields
|
|
149
|
+
* @param initialState Initial query state
|
|
150
|
+
* @returns Search query builder result
|
|
151
|
+
*/
|
|
152
|
+
export declare function useSearchQueryBuilder(fields: SearchField[], initialState?: Partial<SearchQueryState>): UseSearchQueryBuilderResult;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server Authentication Hook for React
|
|
3
|
+
*
|
|
4
|
+
* Provides a hook for handling authentication with automatic redirects
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Server authentication hook options
|
|
8
|
+
*/
|
|
9
|
+
export interface UseServerAuthOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Path to redirect to when not authenticated
|
|
12
|
+
*/
|
|
13
|
+
loginRedirectPath?: string;
|
|
14
|
+
/**
|
|
15
|
+
* User types allowed to access the page
|
|
16
|
+
*/
|
|
17
|
+
allowedTypes?: string[];
|
|
18
|
+
/**
|
|
19
|
+
* Whether to validate the session on mount
|
|
20
|
+
*/
|
|
21
|
+
validateOnMount?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Pubflow instance ID
|
|
24
|
+
*/
|
|
25
|
+
instanceId?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Custom redirect function
|
|
28
|
+
*/
|
|
29
|
+
onRedirect?: (path: string) => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Hook for handling authentication with automatic redirects
|
|
33
|
+
*
|
|
34
|
+
* @param options Hook options
|
|
35
|
+
* @returns Authentication hook result
|
|
36
|
+
*/
|
|
37
|
+
export declare function useServerAuth({ loginRedirectPath, allowedTypes, validateOnMount, instanceId, onRedirect }?: UseServerAuthOptions): {
|
|
38
|
+
user: import("@pubflow/core").User | null;
|
|
39
|
+
isAuthenticated: boolean;
|
|
40
|
+
isLoading: boolean;
|
|
41
|
+
validateSession: () => Promise<{
|
|
42
|
+
isValid: boolean;
|
|
43
|
+
expiresAt?: string;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pubflow React Adapter
|
|
3
|
+
*
|
|
4
|
+
* Main entry point for the Pubflow React adapter
|
|
5
|
+
*/
|
|
6
|
+
export * from '@pubflow/core';
|
|
7
|
+
export * from './components/BridgeView';
|
|
8
|
+
export * from './components/BridgeTable';
|
|
9
|
+
export * from './components/BridgeForm';
|
|
10
|
+
export * from './components/BridgeList';
|
|
11
|
+
export * from './components/OfflineIndicator';
|
|
12
|
+
export * from './components/AdvancedFilter';
|
|
13
|
+
export * from './components/auth';
|
|
14
|
+
export * from './components/theme';
|
|
15
|
+
export * from './context/PubflowProvider';
|
|
16
|
+
export * from './hooks/useAuth';
|
|
17
|
+
export * from './hooks/useBridgeApi';
|
|
18
|
+
export * from './hooks/useBridgeApiRaw';
|
|
19
|
+
export * from './hooks/useBridgeQuery';
|
|
20
|
+
export * from './hooks/useBridgeMutation';
|
|
21
|
+
export * from './hooks/useServerAuth';
|
|
22
|
+
export * from './hooks/useSearchQueryBuilder';
|
|
23
|
+
import { useBridgeCrud } from './hooks/useBridgeCrud';
|
|
24
|
+
export { useBridgeCrud };
|
|
25
|
+
export * from './storage/BrowserStorageAdapter';
|
|
26
|
+
export * from './utils/auth-utils';
|