@archbase/data 3.0.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 +57 -0
- package/dist/archbase-data-3.0.0.tgz +0 -0
- package/dist/datasource/ArchbaseDataSource.d.ts +472 -0
- package/dist/datasource/ArchbaseLocalFilterDataSource.d.ts +27 -0
- package/dist/datasource/ArchbaseRemoteDataSource.d.ts +17 -0
- package/dist/datasource/ArchbaseRemoteFilterDataSource.d.ts +28 -0
- package/dist/datasource/ArchbaseV1V2CompatibilityPattern.d.ts +72 -0
- package/dist/datasource/IArchbaseDataSourceBase.d.ts +111 -0
- package/dist/datasource/index.d.ts +10 -0
- package/dist/datasource/v2/ArchbaseDataSourceV2.d.ts +128 -0
- package/dist/datasource/v2/ArchbaseQueryIntegration.d.ts +210 -0
- package/dist/datasource/v2/ArchbaseQueryProvider.d.ts +79 -0
- package/dist/datasource/v2/ArchbaseRemoteDataSourceV2.d.ts +182 -0
- package/dist/datasource/v2/ArchbaseTanStackQueryIntegration.d.ts +132 -0
- package/dist/datasource/v2/index.d.ts +11 -0
- package/dist/datasource/v2/useArchbaseDataSourceV2.d.ts +143 -0
- package/dist/datasource/v2/useArchbaseRemoteDataSourceV2.d.ts +210 -0
- package/dist/hooks/index.d.ts +14 -0
- package/dist/hooks/useArchbaseDataSource.d.ts +15 -0
- package/dist/hooks/useArchbaseDataSourceListener.d.ts +7 -0
- package/dist/hooks/useArchbaseDidMount.d.ts +5 -0
- package/dist/hooks/useArchbaseDidUpdate.d.ts +6 -0
- package/dist/hooks/useArchbaseEventListener.d.ts +1 -0
- package/dist/hooks/useArchbaseForceRerender.d.ts +5 -0
- package/dist/hooks/useArchbaseForceUpdate.d.ts +5 -0
- package/dist/hooks/useArchbaseLocalFilterDataSource.d.ts +13 -0
- package/dist/hooks/useArchbaseRemoteDataSource.d.ts +36 -0
- package/dist/hooks/useArchbaseRemoteFilterDataSource.d.ts +34 -0
- package/dist/hooks/useArchbaseRemoteServiceApi.d.ts +2 -0
- package/dist/hooks/useArchbaseStore.d.ts +3 -0
- package/dist/hooks/useArchbaseWillUnmount.d.ts +5 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +3360 -0
- package/dist/service/ArchbaseRemoteApiService.d.ts +103 -0
- package/dist/service/index.d.ts +2 -0
- package/dist/types/ArchbaseStateValues.d.ts +9 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { ArchbaseQueryFilter } from '@archbase/core';
|
|
3
|
+
import { DataSourceListener, IDataSourceValidator } from '../ArchbaseDataSource';
|
|
4
|
+
import { IArchbaseDataSourceBase } from '../IArchbaseDataSourceBase';
|
|
5
|
+
import { ArchbaseRemoteApiService } from '../../service/ArchbaseRemoteApiService';
|
|
6
|
+
/**
|
|
7
|
+
* Estados possíveis do DataSource
|
|
8
|
+
*/
|
|
9
|
+
type DataSourceState = 'browse' | 'edit' | 'insert';
|
|
10
|
+
/**
|
|
11
|
+
* Configuração para ArchbaseRemoteDataSourceV2
|
|
12
|
+
* Suporta configuração inicial com registros ou carregamento remoto
|
|
13
|
+
*/
|
|
14
|
+
export interface ArchbaseRemoteDataSourceV2Config<T> {
|
|
15
|
+
name: string;
|
|
16
|
+
label?: string;
|
|
17
|
+
service: ArchbaseRemoteApiService<T, any>;
|
|
18
|
+
records?: T[];
|
|
19
|
+
validator?: IDataSourceValidator;
|
|
20
|
+
defaultSortFields?: string[];
|
|
21
|
+
pageSize?: number;
|
|
22
|
+
onStateChange?: (prevRecords: T[], newRecords: T[]) => void;
|
|
23
|
+
onFieldError?: (fieldName: string, error: string) => void;
|
|
24
|
+
onError?: (error: string, originalError?: any) => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* ArchbaseRemoteDataSourceV2 - Versão V2 com Immer e suporte a TanStack Query
|
|
28
|
+
*
|
|
29
|
+
* Esta implementação:
|
|
30
|
+
* - Garante imutabilidade completa com Immer
|
|
31
|
+
* - Preparada para integração com TanStack Query
|
|
32
|
+
* - Suporte para operações CRUD remotas
|
|
33
|
+
* - Gestão de cache e sincronização otimizada
|
|
34
|
+
* - Interface simplificada focada em funcionalidade V2
|
|
35
|
+
*/
|
|
36
|
+
export declare class ArchbaseRemoteDataSourceV2<T> implements IArchbaseDataSourceBase<T> {
|
|
37
|
+
private name;
|
|
38
|
+
private label;
|
|
39
|
+
private service;
|
|
40
|
+
private records;
|
|
41
|
+
private filteredRecords;
|
|
42
|
+
private currentIndex;
|
|
43
|
+
private state;
|
|
44
|
+
private listeners;
|
|
45
|
+
private originalRecord;
|
|
46
|
+
private validator?;
|
|
47
|
+
private lastDataChangedAt;
|
|
48
|
+
private lastDataBrowsingOn;
|
|
49
|
+
private grandTotalRecords;
|
|
50
|
+
private defaultSortFields;
|
|
51
|
+
private pageSize;
|
|
52
|
+
private active;
|
|
53
|
+
private onStateChange?;
|
|
54
|
+
private onFieldError?;
|
|
55
|
+
private onError?;
|
|
56
|
+
constructor(config: ArchbaseRemoteDataSourceV2Config<T>);
|
|
57
|
+
getName(): string;
|
|
58
|
+
getLabel(): string;
|
|
59
|
+
isActive(): boolean;
|
|
60
|
+
close(): void;
|
|
61
|
+
getCurrentRecord(): T | undefined;
|
|
62
|
+
getCurrentIndex(): number;
|
|
63
|
+
getTotalRecords(): number;
|
|
64
|
+
isEmpty(): boolean;
|
|
65
|
+
first(): void;
|
|
66
|
+
last(): void;
|
|
67
|
+
next(): void;
|
|
68
|
+
prior(): void;
|
|
69
|
+
goToRecord(index: number): void;
|
|
70
|
+
isFirst(): boolean;
|
|
71
|
+
isLast(): boolean;
|
|
72
|
+
isBOF(): boolean;
|
|
73
|
+
isEOF(): boolean;
|
|
74
|
+
isBrowsing(): boolean;
|
|
75
|
+
isEditing(): boolean;
|
|
76
|
+
isInserting(): boolean;
|
|
77
|
+
edit(): void;
|
|
78
|
+
cancel(): void;
|
|
79
|
+
insert(record: T): void;
|
|
80
|
+
save(callback?: Function): Promise<T>;
|
|
81
|
+
remove(callback?: Function): Promise<T | undefined>;
|
|
82
|
+
setFieldValue(fieldName: string, value: any): void;
|
|
83
|
+
getFieldValue(fieldName: string): any;
|
|
84
|
+
appendToFieldArray<K extends keyof T>(fieldName: K, item: T[K] extends Array<infer U> ? U : never): void;
|
|
85
|
+
updateFieldArrayItem<K extends keyof T>(fieldName: K, index: number, updater: (draft: T[K] extends Array<infer U> ? Draft<U> : never) => void): void;
|
|
86
|
+
removeFromFieldArray<K extends keyof T>(fieldName: K, index: number): void;
|
|
87
|
+
insertIntoFieldArray<K extends keyof T>(fieldName: K, index: number, item: T[K] extends Array<infer U> ? U : never): void;
|
|
88
|
+
getFieldArray<K extends keyof T>(fieldName: K): T[K] extends Array<infer U> ? U[] : never;
|
|
89
|
+
isFieldArray<K extends keyof T>(fieldName: K): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Interface de opções para refreshData - compatibilidade com V1
|
|
92
|
+
*/
|
|
93
|
+
private currentPage;
|
|
94
|
+
private currentFilter?;
|
|
95
|
+
private currentSort?;
|
|
96
|
+
/**
|
|
97
|
+
* Atualiza os dados do DataSource com as opções fornecidas.
|
|
98
|
+
* Compatível com a interface do DataSource V1.
|
|
99
|
+
*
|
|
100
|
+
* @param options Opções de refresh incluindo página, filtro e ordenação
|
|
101
|
+
*/
|
|
102
|
+
refreshData(options?: {
|
|
103
|
+
currentPage?: number;
|
|
104
|
+
pageSize?: number;
|
|
105
|
+
filter?: string;
|
|
106
|
+
sort?: string[];
|
|
107
|
+
originFilter?: any;
|
|
108
|
+
originGlobalFilter?: string;
|
|
109
|
+
}): void;
|
|
110
|
+
/**
|
|
111
|
+
* Carrega dados com filtro RSQL
|
|
112
|
+
*/
|
|
113
|
+
private getDataWithRsqlFilter;
|
|
114
|
+
/**
|
|
115
|
+
* Retorna as opções atuais do DataSource - compatibilidade com V1
|
|
116
|
+
*/
|
|
117
|
+
getOptions(): {
|
|
118
|
+
currentPage: number;
|
|
119
|
+
pageSize: number;
|
|
120
|
+
filter?: string;
|
|
121
|
+
sort?: string[];
|
|
122
|
+
grandTotalRecords: number;
|
|
123
|
+
};
|
|
124
|
+
applyRemoteFilter(filter: ArchbaseQueryFilter, page: number, callback?: (() => void) | undefined): void;
|
|
125
|
+
addListener(listener: DataSourceListener<T>): void;
|
|
126
|
+
removeListener(listener: DataSourceListener<T>): void;
|
|
127
|
+
private emit;
|
|
128
|
+
getGrandTotalRecords(): number;
|
|
129
|
+
getPageSize(): number;
|
|
130
|
+
setPageSize(pageSize: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Retorna a página atual (0-indexed)
|
|
133
|
+
*/
|
|
134
|
+
getCurrentPage(): number;
|
|
135
|
+
/**
|
|
136
|
+
* Alias para getRecords - compatibilidade com V1
|
|
137
|
+
*/
|
|
138
|
+
browseRecords(): T[];
|
|
139
|
+
getRecords(): T[];
|
|
140
|
+
/**
|
|
141
|
+
* Localiza um registro por valores de campos e navega para ele
|
|
142
|
+
* @param values Objeto com campos/valores para busca
|
|
143
|
+
* @returns true se encontrou, false caso contrário
|
|
144
|
+
*/
|
|
145
|
+
locate(values: any): boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Vai para um registro pelo seu índice (alias para goToRecord)
|
|
148
|
+
* @param index Índice do registro
|
|
149
|
+
*/
|
|
150
|
+
gotoRecord(index: number): void;
|
|
151
|
+
/**
|
|
152
|
+
* Vai para um registro pelo seu dado
|
|
153
|
+
* @param record Dados do registro para navegar
|
|
154
|
+
* @returns true se encontrou, false caso contrário
|
|
155
|
+
*/
|
|
156
|
+
gotoRecordByData(record: T): boolean;
|
|
157
|
+
setRecords(records: T[], totalElements?: number): void;
|
|
158
|
+
getDebugSnapshot(): {
|
|
159
|
+
name: string;
|
|
160
|
+
label: string;
|
|
161
|
+
recordCount: number;
|
|
162
|
+
currentIndex: number;
|
|
163
|
+
currentRecord: T;
|
|
164
|
+
state: DataSourceState;
|
|
165
|
+
listeners: number;
|
|
166
|
+
totalRecords: number;
|
|
167
|
+
pageSize: number;
|
|
168
|
+
};
|
|
169
|
+
private validateDataSourceActive;
|
|
170
|
+
private publishEventError;
|
|
171
|
+
private publishEventErrors;
|
|
172
|
+
private handleSaveError;
|
|
173
|
+
private notifyStateChange;
|
|
174
|
+
private setNestedValue;
|
|
175
|
+
private getNestedValue;
|
|
176
|
+
private getDataWithFilter;
|
|
177
|
+
private getDataWithoutFilter;
|
|
178
|
+
private getDataWithQuickFilter;
|
|
179
|
+
private getSortFields;
|
|
180
|
+
private handleRemoteError;
|
|
181
|
+
}
|
|
182
|
+
export {};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TanStack Query Integration for ArchbaseRemoteDataSourceV2
|
|
3
|
+
*
|
|
4
|
+
* This module provides integration between ArchbaseRemoteDataSourceV2 and TanStack Query
|
|
5
|
+
* for advanced caching, synchronization, and offline capabilities.
|
|
6
|
+
*/
|
|
7
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
8
|
+
import { ArchbaseRemoteDataSourceV2 } from './ArchbaseRemoteDataSourceV2';
|
|
9
|
+
import { ArchbaseRemoteApiService } from '../../service/ArchbaseRemoteApiService';
|
|
10
|
+
import { ArchbaseQueryFilter } from '@archbase/core';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for TanStack Query integration
|
|
13
|
+
*/
|
|
14
|
+
export interface ArchbaseTanStackQueryConfig {
|
|
15
|
+
/** Cache time in milliseconds (default: 5 minutes) */
|
|
16
|
+
cacheTime?: number;
|
|
17
|
+
/** Stale time in milliseconds (default: 30 seconds) */
|
|
18
|
+
staleTime?: number;
|
|
19
|
+
/** Refetch on window focus (default: false) */
|
|
20
|
+
refetchOnWindowFocus?: boolean;
|
|
21
|
+
/** Refetch on reconnect (default: true) */
|
|
22
|
+
refetchOnReconnect?: boolean;
|
|
23
|
+
/** Retry count (default: 3) */
|
|
24
|
+
retry?: number;
|
|
25
|
+
/** Enable background updates (default: true) */
|
|
26
|
+
refetchInterval?: number | false;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Default TanStack Query configuration
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_TANSTACK_CONFIG: ArchbaseTanStackQueryConfig;
|
|
32
|
+
/**
|
|
33
|
+
* Query keys factory for consistent caching
|
|
34
|
+
*/
|
|
35
|
+
export declare class ArchbaseQueryKeys {
|
|
36
|
+
private static base;
|
|
37
|
+
static all: readonly ["archbase"];
|
|
38
|
+
static datasource: (name: string) => readonly ["archbase", "datasource", string];
|
|
39
|
+
static records: (name: string, filter?: ArchbaseQueryFilter, page?: number) => readonly ["archbase", "datasource", string, "records", {
|
|
40
|
+
readonly filter: ArchbaseQueryFilter;
|
|
41
|
+
readonly page: number;
|
|
42
|
+
}];
|
|
43
|
+
static record: (name: string, id: any) => readonly ["archbase", "datasource", string, "record", any];
|
|
44
|
+
static count: (name: string, filter?: ArchbaseQueryFilter) => readonly ["archbase", "datasource", string, "count", {
|
|
45
|
+
readonly filter: ArchbaseQueryFilter;
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Enhanced RemoteDataSource with TanStack Query integration
|
|
50
|
+
*/
|
|
51
|
+
export declare class ArchbaseRemoteDataSourceV2WithQuery<T> extends ArchbaseRemoteDataSourceV2<T> {
|
|
52
|
+
private queryClient;
|
|
53
|
+
private queryConfig;
|
|
54
|
+
constructor(config: {
|
|
55
|
+
name: string;
|
|
56
|
+
service: ArchbaseRemoteApiService<T, any>;
|
|
57
|
+
queryClient: QueryClient;
|
|
58
|
+
pageSize?: number;
|
|
59
|
+
queryConfig?: ArchbaseTanStackQueryConfig;
|
|
60
|
+
onStateChange?: (prevRecords: T[], newRecords: T[]) => void;
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Load data with TanStack Query caching
|
|
64
|
+
*/
|
|
65
|
+
loadWithQuery(filter?: ArchbaseQueryFilter, page?: number): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Save record with optimistic updates
|
|
68
|
+
*/
|
|
69
|
+
saveWithOptimisticUpdate(): Promise<T>;
|
|
70
|
+
/**
|
|
71
|
+
* Remove record with optimistic updates
|
|
72
|
+
*/
|
|
73
|
+
removeWithOptimisticUpdate(): Promise<T | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Prefetch next page for better UX
|
|
76
|
+
*/
|
|
77
|
+
prefetchNextPage(): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Invalidate all cache for this datasource
|
|
80
|
+
*/
|
|
81
|
+
invalidateCache(): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Get cached data without triggering a request
|
|
84
|
+
*/
|
|
85
|
+
getCachedData(filter?: ArchbaseQueryFilter, page?: number): T[] | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Check if data is stale and needs refresh
|
|
88
|
+
*/
|
|
89
|
+
isDataStale(filter?: ArchbaseQueryFilter, page?: number): boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Result type for useArchbaseRemoteDataSourceWithQuery hook
|
|
93
|
+
*/
|
|
94
|
+
export interface UseArchbaseRemoteDataSourceWithQueryResult<T> {
|
|
95
|
+
dataSource: ArchbaseRemoteDataSourceV2WithQuery<T>;
|
|
96
|
+
isLoading: boolean;
|
|
97
|
+
isError: boolean;
|
|
98
|
+
error: Error | null;
|
|
99
|
+
isRefetching: boolean;
|
|
100
|
+
records: T[];
|
|
101
|
+
currentRecord: T | undefined;
|
|
102
|
+
totalRecords: number;
|
|
103
|
+
currentPage: number;
|
|
104
|
+
totalPages: number;
|
|
105
|
+
refetch: () => Promise<any>;
|
|
106
|
+
save: () => Promise<T>;
|
|
107
|
+
remove: () => Promise<T | undefined>;
|
|
108
|
+
invalidateCache: () => Promise<void>;
|
|
109
|
+
prefetchNextPage: () => Promise<void>;
|
|
110
|
+
isSaving: boolean;
|
|
111
|
+
isRemoving: boolean;
|
|
112
|
+
saveError: Error | null;
|
|
113
|
+
removeError: Error | null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* React Hook for RemoteDataSource with TanStack Query
|
|
117
|
+
*/
|
|
118
|
+
export declare function useArchbaseRemoteDataSourceWithQuery<T>(config: {
|
|
119
|
+
name: string;
|
|
120
|
+
service: ArchbaseRemoteApiService<T, any>;
|
|
121
|
+
pageSize?: number;
|
|
122
|
+
queryConfig?: ArchbaseTanStackQueryConfig;
|
|
123
|
+
filter?: ArchbaseQueryFilter;
|
|
124
|
+
enabled?: boolean;
|
|
125
|
+
}): UseArchbaseRemoteDataSourceWithQueryResult<T>;
|
|
126
|
+
/**
|
|
127
|
+
* Hook for real-time data synchronization
|
|
128
|
+
*/
|
|
129
|
+
export declare function useArchbaseRealTimeSync<T>(dataSourceName: string, options?: {
|
|
130
|
+
interval?: number;
|
|
131
|
+
enabled?: boolean;
|
|
132
|
+
}): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ArchbaseDataSourceV2 } from './ArchbaseDataSourceV2';
|
|
2
|
+
export type { ArchbaseDataSourceV2Config } from './ArchbaseDataSourceV2';
|
|
3
|
+
export { ArchbaseRemoteDataSourceV2 } from './ArchbaseRemoteDataSourceV2';
|
|
4
|
+
export type { ArchbaseRemoteDataSourceV2Config } from './ArchbaseRemoteDataSourceV2';
|
|
5
|
+
export { useArchbaseDataSourceV2, useArchbaseDataSourceV2ReadOnly, useArchbaseDataSourceV2Editor } from './useArchbaseDataSourceV2';
|
|
6
|
+
export type { UseArchbaseDataSourceV2Return } from './useArchbaseDataSourceV2';
|
|
7
|
+
export { useArchbaseRemoteDataSourceV2, useArchbaseRemoteDataSourceV2ReadOnly, useArchbaseRemoteDataSourceV2Editor } from './useArchbaseRemoteDataSourceV2';
|
|
8
|
+
export type { UseArchbaseRemoteDataSourceV2Return } from './useArchbaseRemoteDataSourceV2';
|
|
9
|
+
export type { ArchbaseTanStackQueryConfig, ArchbaseQueryOperations, ArchbaseQueryState, ArchbaseQueryHookReturn } from './ArchbaseQueryIntegration';
|
|
10
|
+
export { ArchbaseQueryUtils, ARCHBASE_QUERY_DEFAULTS } from './ArchbaseQueryIntegration';
|
|
11
|
+
export type { DataSourceOptions, FilterFn, IDataSourceValidator, DataSourceEvent, DataSourceEventNames } from '../ArchbaseDataSource';
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ArchbaseDataSourceV2, ArchbaseDataSourceV2Config } from './ArchbaseDataSourceV2';
|
|
2
|
+
/**
|
|
3
|
+
* Hook para usar ArchbaseDataSourceV2 de forma reativa no React
|
|
4
|
+
*
|
|
5
|
+
* Este hook provê:
|
|
6
|
+
* - Gerenciamento automático do ciclo de vida do DataSource
|
|
7
|
+
* - Estado reativo baseado em eventos
|
|
8
|
+
* - Cleanup automático no unmount
|
|
9
|
+
* - Type safety completa
|
|
10
|
+
* - Performance otimizada com callbacks memoizados
|
|
11
|
+
*/
|
|
12
|
+
export declare function useArchbaseDataSourceV2<T, ID = any>(config: ArchbaseDataSourceV2Config<T>): {
|
|
13
|
+
dataSource: ArchbaseDataSourceV2<T>;
|
|
14
|
+
currentRecord: T;
|
|
15
|
+
currentIndex: number;
|
|
16
|
+
totalRecords: number;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
canNext: boolean;
|
|
19
|
+
canPrior: boolean;
|
|
20
|
+
isEmpty: boolean;
|
|
21
|
+
isFirst: boolean;
|
|
22
|
+
isLast: boolean;
|
|
23
|
+
isBrowsing: boolean;
|
|
24
|
+
isEditing: boolean;
|
|
25
|
+
isInserting: boolean;
|
|
26
|
+
setFieldValue: (fieldName: string, value: any) => void;
|
|
27
|
+
getFieldValue: (fieldName: string) => any;
|
|
28
|
+
edit: () => void;
|
|
29
|
+
save: () => Promise<T>;
|
|
30
|
+
cancel: () => void;
|
|
31
|
+
insert: (record: T) => void;
|
|
32
|
+
remove: (callback?: Function) => Promise<T>;
|
|
33
|
+
first: () => void;
|
|
34
|
+
last: () => void;
|
|
35
|
+
next: () => void;
|
|
36
|
+
prior: () => void;
|
|
37
|
+
goToRecord: (index: number) => void;
|
|
38
|
+
appendToFieldArray: <K extends keyof T>(fieldName: K, item: T[K] extends Array<infer U> ? U : never) => void;
|
|
39
|
+
updateFieldArrayItem: <K extends keyof T>(fieldName: K, index: number, updater: (draft: any) => void) => void;
|
|
40
|
+
removeFromFieldArray: <K extends keyof T>(fieldName: K, index: number) => void;
|
|
41
|
+
insertIntoFieldArray: <K extends keyof T>(fieldName: K, index: number, item: T[K] extends Array<infer U> ? U : never) => void;
|
|
42
|
+
getFieldArray: <K extends keyof T>(fieldName: K) => any[];
|
|
43
|
+
isFieldArray: <K extends keyof T>(fieldName: K) => boolean;
|
|
44
|
+
getDebugInfo: () => {
|
|
45
|
+
hookState: {
|
|
46
|
+
currentRecord: T;
|
|
47
|
+
currentIndex: number;
|
|
48
|
+
totalRecords: number;
|
|
49
|
+
isBrowsing: boolean;
|
|
50
|
+
isEditing: boolean;
|
|
51
|
+
isInserting: boolean;
|
|
52
|
+
isLoading: boolean;
|
|
53
|
+
};
|
|
54
|
+
name: string;
|
|
55
|
+
recordCount: number;
|
|
56
|
+
currentIndex: number;
|
|
57
|
+
currentRecord: T;
|
|
58
|
+
state: "insert" | "edit" | "browse";
|
|
59
|
+
listeners: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Tipo para o retorno do hook useArchbaseDataSourceV2
|
|
64
|
+
*/
|
|
65
|
+
export type UseArchbaseDataSourceV2Return<T> = ReturnType<typeof useArchbaseDataSourceV2<T, any>>;
|
|
66
|
+
/**
|
|
67
|
+
* Hook customizado para componentes que precisam apenas de leitura
|
|
68
|
+
* Otimizado para performance - não re-renderiza em mudanças de campo
|
|
69
|
+
*/
|
|
70
|
+
export declare function useArchbaseDataSourceV2ReadOnly<T, ID = any>(config: ArchbaseDataSourceV2Config<T>): {
|
|
71
|
+
dataSource: ArchbaseDataSourceV2<T>;
|
|
72
|
+
currentRecord: T;
|
|
73
|
+
currentIndex: number;
|
|
74
|
+
totalRecords: number;
|
|
75
|
+
canNext: boolean;
|
|
76
|
+
canPrior: boolean;
|
|
77
|
+
isEmpty: boolean;
|
|
78
|
+
isFirst: boolean;
|
|
79
|
+
isLast: boolean;
|
|
80
|
+
isBrowsing: boolean;
|
|
81
|
+
first: () => void;
|
|
82
|
+
last: () => void;
|
|
83
|
+
next: () => void;
|
|
84
|
+
prior: () => void;
|
|
85
|
+
goToRecord: (index: number) => void;
|
|
86
|
+
getFieldValue: (fieldName: string) => any;
|
|
87
|
+
getFieldArray: <K extends keyof T>(fieldName: K) => any[];
|
|
88
|
+
isFieldArray: <K extends keyof T>(fieldName: K) => boolean;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Hook customizado para componentes de edição
|
|
92
|
+
* Inclui todas as operações de modificação
|
|
93
|
+
*/
|
|
94
|
+
export declare function useArchbaseDataSourceV2Editor<T, ID = any>(config: ArchbaseDataSourceV2Config<T>): {
|
|
95
|
+
dataSource: ArchbaseDataSourceV2<T>;
|
|
96
|
+
currentRecord: T;
|
|
97
|
+
currentIndex: number;
|
|
98
|
+
totalRecords: number;
|
|
99
|
+
isLoading: boolean;
|
|
100
|
+
canNext: boolean;
|
|
101
|
+
canPrior: boolean;
|
|
102
|
+
isEmpty: boolean;
|
|
103
|
+
isFirst: boolean;
|
|
104
|
+
isLast: boolean;
|
|
105
|
+
isBrowsing: boolean;
|
|
106
|
+
isEditing: boolean;
|
|
107
|
+
isInserting: boolean;
|
|
108
|
+
setFieldValue: (fieldName: string, value: any) => void;
|
|
109
|
+
getFieldValue: (fieldName: string) => any;
|
|
110
|
+
edit: () => void;
|
|
111
|
+
save: () => Promise<T>;
|
|
112
|
+
cancel: () => void;
|
|
113
|
+
insert: (record: T) => void;
|
|
114
|
+
remove: (callback?: Function) => Promise<T>;
|
|
115
|
+
first: () => void;
|
|
116
|
+
last: () => void;
|
|
117
|
+
next: () => void;
|
|
118
|
+
prior: () => void;
|
|
119
|
+
goToRecord: (index: number) => void;
|
|
120
|
+
appendToFieldArray: <K extends keyof T>(fieldName: K, item: T[K] extends (infer U)[] ? U : never) => void;
|
|
121
|
+
updateFieldArrayItem: <K extends keyof T>(fieldName: K, index: number, updater: (draft: any) => void) => void;
|
|
122
|
+
removeFromFieldArray: <K extends keyof T>(fieldName: K, index: number) => void;
|
|
123
|
+
insertIntoFieldArray: <K extends keyof T>(fieldName: K, index: number, item: T[K] extends (infer U)[] ? U : never) => void;
|
|
124
|
+
getFieldArray: <K extends keyof T>(fieldName: K) => any[];
|
|
125
|
+
isFieldArray: <K extends keyof T>(fieldName: K) => boolean;
|
|
126
|
+
getDebugInfo: () => {
|
|
127
|
+
hookState: {
|
|
128
|
+
currentRecord: T;
|
|
129
|
+
currentIndex: number;
|
|
130
|
+
totalRecords: number;
|
|
131
|
+
isBrowsing: boolean;
|
|
132
|
+
isEditing: boolean;
|
|
133
|
+
isInserting: boolean;
|
|
134
|
+
isLoading: boolean;
|
|
135
|
+
};
|
|
136
|
+
name: string;
|
|
137
|
+
recordCount: number;
|
|
138
|
+
currentIndex: number;
|
|
139
|
+
currentRecord: T;
|
|
140
|
+
state: "insert" | "edit" | "browse";
|
|
141
|
+
listeners: number;
|
|
142
|
+
};
|
|
143
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { ArchbaseRemoteDataSourceV2, ArchbaseRemoteDataSourceV2Config } from './ArchbaseRemoteDataSourceV2';
|
|
2
|
+
import { ArchbaseQueryFilter } from '@archbase/core';
|
|
3
|
+
/**
|
|
4
|
+
* Hook para usar ArchbaseRemoteDataSourceV2 de forma reativa no React
|
|
5
|
+
*
|
|
6
|
+
* Este hook provê:
|
|
7
|
+
* - Gerenciamento automático do ciclo de vida do RemoteDataSource
|
|
8
|
+
* - Estado reativo baseado em eventos
|
|
9
|
+
* - Cleanup automático no unmount
|
|
10
|
+
* - Type safety completa
|
|
11
|
+
* - Performance otimizada com callbacks memoizados
|
|
12
|
+
* - Operações remotas (CRUD, filtragem, paginação)
|
|
13
|
+
*/
|
|
14
|
+
export declare function useArchbaseRemoteDataSourceV2<T, ID = any>(config: ArchbaseRemoteDataSourceV2Config<T>): {
|
|
15
|
+
dataSource: ArchbaseRemoteDataSourceV2<T>;
|
|
16
|
+
currentRecord: T;
|
|
17
|
+
currentIndex: number;
|
|
18
|
+
totalRecords: number;
|
|
19
|
+
grandTotalRecords: number;
|
|
20
|
+
isLoading: boolean;
|
|
21
|
+
error: string;
|
|
22
|
+
canNext: boolean;
|
|
23
|
+
canPrior: boolean;
|
|
24
|
+
isEmpty: boolean;
|
|
25
|
+
isFirst: boolean;
|
|
26
|
+
isLast: boolean;
|
|
27
|
+
isBrowsing: boolean;
|
|
28
|
+
isEditing: boolean;
|
|
29
|
+
isInserting: boolean;
|
|
30
|
+
setFieldValue: (fieldName: string, value: any) => void;
|
|
31
|
+
getFieldValue: (fieldName: string) => any;
|
|
32
|
+
edit: () => void;
|
|
33
|
+
save: () => Promise<T>;
|
|
34
|
+
cancel: () => void;
|
|
35
|
+
insert: (record: T) => void;
|
|
36
|
+
remove: (callback?: Function) => Promise<T>;
|
|
37
|
+
first: () => void;
|
|
38
|
+
last: () => void;
|
|
39
|
+
next: () => void;
|
|
40
|
+
prior: () => void;
|
|
41
|
+
goToRecord: (index: number) => void;
|
|
42
|
+
appendToFieldArray: <K extends keyof T>(fieldName: K, item: T[K] extends Array<infer U> ? U : never) => void;
|
|
43
|
+
updateFieldArrayItem: <K extends keyof T>(fieldName: K, index: number, updater: (draft: any) => void) => void;
|
|
44
|
+
removeFromFieldArray: <K extends keyof T>(fieldName: K, index: number) => void;
|
|
45
|
+
insertIntoFieldArray: <K extends keyof T>(fieldName: K, index: number, item: T[K] extends Array<infer U> ? U : never) => void;
|
|
46
|
+
getFieldArray: <K extends keyof T>(fieldName: K) => T[K] extends (infer U)[] ? U[] : never;
|
|
47
|
+
isFieldArray: <K extends keyof T>(fieldName: K) => boolean;
|
|
48
|
+
applyRemoteFilter: (filter: ArchbaseQueryFilter, page: number, callback?: (() => void) | undefined) => void;
|
|
49
|
+
refreshData: (options?: {
|
|
50
|
+
currentPage?: number;
|
|
51
|
+
pageSize?: number;
|
|
52
|
+
filter?: string;
|
|
53
|
+
sort?: string[];
|
|
54
|
+
}) => Promise<void>;
|
|
55
|
+
setPageSize: (pageSize: number) => void;
|
|
56
|
+
getPageSize: () => number;
|
|
57
|
+
getDebugInfo: () => {
|
|
58
|
+
hookState: {
|
|
59
|
+
currentRecord: T;
|
|
60
|
+
currentIndex: number;
|
|
61
|
+
totalRecords: number;
|
|
62
|
+
grandTotalRecords: number;
|
|
63
|
+
isBrowsing: boolean;
|
|
64
|
+
isEditing: boolean;
|
|
65
|
+
isInserting: boolean;
|
|
66
|
+
isLoading: boolean;
|
|
67
|
+
error: string;
|
|
68
|
+
};
|
|
69
|
+
name: string;
|
|
70
|
+
label: string;
|
|
71
|
+
recordCount: number;
|
|
72
|
+
currentIndex: number;
|
|
73
|
+
currentRecord: T;
|
|
74
|
+
state: "insert" | "edit" | "browse";
|
|
75
|
+
listeners: number;
|
|
76
|
+
totalRecords: number;
|
|
77
|
+
pageSize: number;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Tipo para o retorno do hook useArchbaseRemoteDataSourceV2
|
|
82
|
+
*/
|
|
83
|
+
export type UseArchbaseRemoteDataSourceV2Return<T> = ReturnType<typeof useArchbaseRemoteDataSourceV2<T, any>>;
|
|
84
|
+
/**
|
|
85
|
+
* Hook customizado para componentes que precisam apenas de leitura
|
|
86
|
+
* Otimizado para performance - não re-renderiza em mudanças de campo
|
|
87
|
+
*/
|
|
88
|
+
export declare function useArchbaseRemoteDataSourceV2ReadOnly<T, ID = any>(config: ArchbaseRemoteDataSourceV2Config<T>): {
|
|
89
|
+
dataSource: ArchbaseRemoteDataSourceV2<T>;
|
|
90
|
+
currentRecord: T;
|
|
91
|
+
currentIndex: number;
|
|
92
|
+
totalRecords: number;
|
|
93
|
+
grandTotalRecords: number;
|
|
94
|
+
isLoading: boolean;
|
|
95
|
+
error: string;
|
|
96
|
+
canNext: boolean;
|
|
97
|
+
canPrior: boolean;
|
|
98
|
+
isEmpty: boolean;
|
|
99
|
+
isFirst: boolean;
|
|
100
|
+
isLast: boolean;
|
|
101
|
+
isBrowsing: boolean;
|
|
102
|
+
first: () => void;
|
|
103
|
+
last: () => void;
|
|
104
|
+
next: () => void;
|
|
105
|
+
prior: () => void;
|
|
106
|
+
goToRecord: (index: number) => void;
|
|
107
|
+
getFieldValue: (fieldName: string) => any;
|
|
108
|
+
getFieldArray: <K extends keyof T>(fieldName: K) => T[K] extends (infer U)[] ? U[] : never;
|
|
109
|
+
isFieldArray: <K extends keyof T>(fieldName: K) => boolean;
|
|
110
|
+
applyRemoteFilter: (filter: ArchbaseQueryFilter, page: number, callback?: () => void) => void;
|
|
111
|
+
refreshData: (options?: {
|
|
112
|
+
currentPage?: number;
|
|
113
|
+
pageSize?: number;
|
|
114
|
+
filter?: string;
|
|
115
|
+
sort?: string[];
|
|
116
|
+
}) => Promise<void>;
|
|
117
|
+
getPageSize: () => number;
|
|
118
|
+
getDebugInfo: () => {
|
|
119
|
+
hookState: {
|
|
120
|
+
currentRecord: T;
|
|
121
|
+
currentIndex: number;
|
|
122
|
+
totalRecords: number;
|
|
123
|
+
grandTotalRecords: number;
|
|
124
|
+
isBrowsing: boolean;
|
|
125
|
+
isEditing: boolean;
|
|
126
|
+
isInserting: boolean;
|
|
127
|
+
isLoading: boolean;
|
|
128
|
+
error: string;
|
|
129
|
+
};
|
|
130
|
+
name: string;
|
|
131
|
+
label: string;
|
|
132
|
+
recordCount: number;
|
|
133
|
+
currentIndex: number;
|
|
134
|
+
currentRecord: T;
|
|
135
|
+
state: "insert" | "edit" | "browse";
|
|
136
|
+
listeners: number;
|
|
137
|
+
totalRecords: number;
|
|
138
|
+
pageSize: number;
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Hook customizado para componentes de edição
|
|
143
|
+
* Inclui todas as operações de modificação
|
|
144
|
+
*/
|
|
145
|
+
export declare function useArchbaseRemoteDataSourceV2Editor<T, ID = any>(config: ArchbaseRemoteDataSourceV2Config<T>): {
|
|
146
|
+
dataSource: ArchbaseRemoteDataSourceV2<T>;
|
|
147
|
+
currentRecord: T;
|
|
148
|
+
currentIndex: number;
|
|
149
|
+
totalRecords: number;
|
|
150
|
+
grandTotalRecords: number;
|
|
151
|
+
isLoading: boolean;
|
|
152
|
+
error: string;
|
|
153
|
+
canNext: boolean;
|
|
154
|
+
canPrior: boolean;
|
|
155
|
+
isEmpty: boolean;
|
|
156
|
+
isFirst: boolean;
|
|
157
|
+
isLast: boolean;
|
|
158
|
+
isBrowsing: boolean;
|
|
159
|
+
isEditing: boolean;
|
|
160
|
+
isInserting: boolean;
|
|
161
|
+
setFieldValue: (fieldName: string, value: any) => void;
|
|
162
|
+
getFieldValue: (fieldName: string) => any;
|
|
163
|
+
edit: () => void;
|
|
164
|
+
save: () => Promise<T>;
|
|
165
|
+
cancel: () => void;
|
|
166
|
+
insert: (record: T) => void;
|
|
167
|
+
remove: (callback?: Function) => Promise<T>;
|
|
168
|
+
first: () => void;
|
|
169
|
+
last: () => void;
|
|
170
|
+
next: () => void;
|
|
171
|
+
prior: () => void;
|
|
172
|
+
goToRecord: (index: number) => void;
|
|
173
|
+
appendToFieldArray: <K extends keyof T>(fieldName: K, item: T[K] extends (infer U)[] ? U : never) => void;
|
|
174
|
+
updateFieldArrayItem: <K extends keyof T>(fieldName: K, index: number, updater: (draft: any) => void) => void;
|
|
175
|
+
removeFromFieldArray: <K extends keyof T>(fieldName: K, index: number) => void;
|
|
176
|
+
insertIntoFieldArray: <K extends keyof T>(fieldName: K, index: number, item: T[K] extends (infer U)[] ? U : never) => void;
|
|
177
|
+
getFieldArray: <K extends keyof T>(fieldName: K) => T[K] extends (infer U)[] ? U[] : never;
|
|
178
|
+
isFieldArray: <K extends keyof T>(fieldName: K) => boolean;
|
|
179
|
+
applyRemoteFilter: (filter: ArchbaseQueryFilter, page: number, callback?: () => void) => void;
|
|
180
|
+
refreshData: (options?: {
|
|
181
|
+
currentPage?: number;
|
|
182
|
+
pageSize?: number;
|
|
183
|
+
filter?: string;
|
|
184
|
+
sort?: string[];
|
|
185
|
+
}) => Promise<void>;
|
|
186
|
+
setPageSize: (pageSize: number) => void;
|
|
187
|
+
getPageSize: () => number;
|
|
188
|
+
getDebugInfo: () => {
|
|
189
|
+
hookState: {
|
|
190
|
+
currentRecord: T;
|
|
191
|
+
currentIndex: number;
|
|
192
|
+
totalRecords: number;
|
|
193
|
+
grandTotalRecords: number;
|
|
194
|
+
isBrowsing: boolean;
|
|
195
|
+
isEditing: boolean;
|
|
196
|
+
isInserting: boolean;
|
|
197
|
+
isLoading: boolean;
|
|
198
|
+
error: string;
|
|
199
|
+
};
|
|
200
|
+
name: string;
|
|
201
|
+
label: string;
|
|
202
|
+
recordCount: number;
|
|
203
|
+
currentIndex: number;
|
|
204
|
+
currentRecord: T;
|
|
205
|
+
state: "insert" | "edit" | "browse";
|
|
206
|
+
listeners: number;
|
|
207
|
+
totalRecords: number;
|
|
208
|
+
pageSize: number;
|
|
209
|
+
};
|
|
210
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './useArchbaseDataSource';
|
|
2
|
+
export * from './useArchbaseDataSourceListener';
|
|
3
|
+
export * from './useArchbaseLocalFilterDataSource';
|
|
4
|
+
export * from './useArchbaseRemoteDataSource';
|
|
5
|
+
export * from './useArchbaseRemoteFilterDataSource';
|
|
6
|
+
export * from './useArchbaseRemoteServiceApi';
|
|
7
|
+
export * from './useArchbaseDidMount';
|
|
8
|
+
export * from './useArchbaseDidUpdate';
|
|
9
|
+
export * from './useArchbaseWillUnmount';
|
|
10
|
+
export * from './useArchbaseForceRerender';
|
|
11
|
+
export * from './useArchbaseForceUpdate';
|
|
12
|
+
export * from './useArchbaseStore';
|
|
13
|
+
export type { ArchbaseStore } from '@archbase/core';
|
|
14
|
+
export * from './useArchbaseEventListener';
|