@epam/uui-db 4.4.0 → 4.5.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/bundle-stats.json +1 -1
- package/index.d.ts +1 -1
- package/index.js +1196 -1174
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/readme.md +17 -17
- package/src/Db.d.ts +12 -12
- package/src/DbRef.d.ts +48 -48
- package/src/DbTable.d.ts +34 -34
- package/src/IxSet.d.ts +27 -27
- package/src/ListLoadingTracker.d.ts +18 -18
- package/src/Loader.d.ts +23 -23
- package/src/Scheduler.d.ts +18 -18
- package/src/SimpleLoadingTracker.d.ts +8 -8
- package/src/__benchmarks__/filter.d.ts +1 -1
- package/src/__benchmarks__/index.d.ts +2 -2
- package/src/__benchmarks__/pkLookup.d.ts +1 -1
- package/src/__benchmarks__/pkUpdate.d.ts +1 -1
- package/src/__benchmarks__/query.d.ts +1 -1
- package/src/__benchmarks__/sorting.d.ts +1 -1
- package/src/__benchmarks__/testData.d.ts +14 -14
- package/src/index.d.ts +8 -8
- package/src/patchHelpers.d.ts +17 -17
- package/src/reactHooks.d.ts +6 -6
- package/src/tempIds.d.ts +27 -27
- package/src/types.d.ts +116 -116
- package/src/utils.d.ts +9 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epam/uui-db",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.3",
|
|
4
4
|
"description": "UUI - client-side relational state cache",
|
|
5
5
|
"author": "EPAM",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"prepublish": "yarn build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@epam/uui": "4.
|
|
16
|
+
"@epam/uui": "4.5.3",
|
|
17
17
|
"@types/lodash.countby": "4.6.6",
|
|
18
18
|
"@types/lodash.filter": "4.6.6",
|
|
19
19
|
"@types/lodash.foreach": "4.5.6",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"react-dom": ">=16.0.0"
|
|
60
60
|
},
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@epam/uui-docs": "4.
|
|
62
|
+
"@epam/uui-docs": "4.5.3"
|
|
63
63
|
},
|
|
64
64
|
"repository": {
|
|
65
65
|
"type": "git",
|
|
66
66
|
"url": "https://github.com/epam/UUI"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "eecf226b7bc65fe15f03c4b34a636426d4bcf897",
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"directory": "build"
|
|
71
71
|
}
|
package/readme.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# UUI DB package
|
|
2
|
-
|
|
3
|
-
This package is a part of [EPAM UUI](https://github.com/epam/UUI) library.
|
|
4
|
-
|
|
5
|
-
@epam/uui-db is an experimental state-management solution. It maintains immutable relational database on client, provides means to load data from server, update it both from client, and save it to server asynchronously with UI operations.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- relation data model for state, providing a normalized storage for UI state
|
|
10
|
-
- data loading from server, with automatic GraphQL response normalization into tables
|
|
11
|
-
- synchronous and transactional updates of state from UI
|
|
12
|
-
- asynchronous bi-directional state synchronization between UI and server. UI changes in terms of 'patches' are batched and sent to server. Server can also push updates to UI state
|
|
13
|
-
- GIT-like branch-rebase approach to handle state concurrency
|
|
14
|
-
- tables can be indexed to speed-up queries
|
|
15
|
-
- Views to build arbitrary state projections
|
|
16
|
-
- subscriptions to subscribe parts of UI to changes in Views
|
|
17
|
-
|
|
1
|
+
# UUI DB package
|
|
2
|
+
|
|
3
|
+
This package is a part of [EPAM UUI](https://github.com/epam/UUI) library.
|
|
4
|
+
|
|
5
|
+
@epam/uui-db is an experimental state-management solution. It maintains immutable relational database on client, provides means to load data from server, update it both from client, and save it to server asynchronously with UI operations.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- relation data model for state, providing a normalized storage for UI state
|
|
10
|
+
- data loading from server, with automatic GraphQL response normalization into tables
|
|
11
|
+
- synchronous and transactional updates of state from UI
|
|
12
|
+
- asynchronous bi-directional state synchronization between UI and server. UI changes in terms of 'patches' are batched and sent to server. Server can also push updates to UI state
|
|
13
|
+
- GIT-like branch-rebase approach to handle state concurrency
|
|
14
|
+
- tables can be indexed to speed-up queries
|
|
15
|
+
- Views to build arbitrary state projections
|
|
16
|
+
- subscriptions to subscribe parts of UI to changes in Views
|
|
17
|
+
|
package/src/Db.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DbPatch, DbTablesSet, DbView, ViewCacheItem } from './types';
|
|
2
|
-
declare type ViewCache = Map<DbView<any, any, any, any>, Map<string, ViewCacheItem>>;
|
|
3
|
-
export declare abstract class Db<TTables extends DbTablesSet<TTables>> {
|
|
4
|
-
tables: TTables;
|
|
5
|
-
private viewCache;
|
|
6
|
-
constructor(tables: TTables, reusedCache?: ViewCache);
|
|
7
|
-
private update;
|
|
8
|
-
with(patch: DbPatch<TTables>): this;
|
|
9
|
-
valueAbsent: symbol;
|
|
10
|
-
runView<TResult, TParams = void, TDependencies = void>(view: DbView<this, TResult, TParams, TDependencies>, params?: TParams): TResult;
|
|
11
|
-
}
|
|
12
|
-
export {};
|
|
1
|
+
import { DbPatch, DbTablesSet, DbView, ViewCacheItem } from './types';
|
|
2
|
+
declare type ViewCache = Map<DbView<any, any, any, any>, Map<string, ViewCacheItem>>;
|
|
3
|
+
export declare abstract class Db<TTables extends DbTablesSet<TTables>> {
|
|
4
|
+
tables: TTables;
|
|
5
|
+
private viewCache;
|
|
6
|
+
constructor(tables: TTables, reusedCache?: ViewCache);
|
|
7
|
+
private update;
|
|
8
|
+
with(patch: DbPatch<TTables>): this;
|
|
9
|
+
valueAbsent: symbol;
|
|
10
|
+
runView<TResult, TParams = void, TDependencies = void>(view: DbView<this, TResult, TParams, TDependencies>, params?: TParams): TResult;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
13
13
|
//# sourceMappingURL=Db.d.ts.map
|
package/src/DbRef.d.ts
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { Db } from './Db';
|
|
2
|
-
import { DbPatch, DbTablesSet, ServerError, DbSaveResponse, DbView, DbSubscription } from './types';
|
|
3
|
-
import { IClientIdsMap } from './tempIds';
|
|
4
|
-
import { Loader, LoaderOptions } from './Loader';
|
|
5
|
-
import { DataQuery } from '@epam/uui';
|
|
6
|
-
import { ListLoadingTrackerOptions } from './ListLoadingTracker';
|
|
7
|
-
export declare class DbRef<TTables extends DbTablesSet<TTables>, TDb extends Db<TTables>> {
|
|
8
|
-
blank: TDb;
|
|
9
|
-
private base;
|
|
10
|
-
private log;
|
|
11
|
-
private autoSave;
|
|
12
|
-
private savedPoint;
|
|
13
|
-
private tempIdMap;
|
|
14
|
-
db: TDb;
|
|
15
|
-
errors: ServerError[];
|
|
16
|
-
protected throttleSaveMs: number;
|
|
17
|
-
readonly idMap: IClientIdsMap;
|
|
18
|
-
constructor(blank: TDb);
|
|
19
|
-
/** Saves all committed patches. Useful only if autoSave is off. */
|
|
20
|
-
save(): void;
|
|
21
|
-
getAutoSave(): boolean;
|
|
22
|
-
setAutoSave(val: boolean): void;
|
|
23
|
-
/** Concrete DbRef instances should override and implement their save logic in this method */
|
|
24
|
-
protected savePatch(patch: DbPatch<TTables>): Promise<DbSaveResponse<TTables>>;
|
|
25
|
-
commit(patch: DbPatch<TTables>): void;
|
|
26
|
-
private beforeUpdate;
|
|
27
|
-
commitFetch(patch: DbPatch<TTables>): void;
|
|
28
|
-
private rebase;
|
|
29
|
-
private makeCumulativePatch;
|
|
30
|
-
private applyResponse;
|
|
31
|
-
private lastSubscriptionId;
|
|
32
|
-
private subscriptions;
|
|
33
|
-
subscribe<TValue, TParams, TDependencies>(view: DbView<TDb, TValue, TParams, TDependencies>, params: TParams, onUpdate: (newValue: TValue) => any): DbSubscription<TValue, TParams>;
|
|
34
|
-
updateHandlers: (() => any)[];
|
|
35
|
-
onUpdate(handler: () => any): void;
|
|
36
|
-
private update;
|
|
37
|
-
saveErrorHandlers: ((request: DbPatch<TTables>, error: any) => void)[];
|
|
38
|
-
onSaveError(handler: (request: DbPatch<TTables>, error: any) => void): void;
|
|
39
|
-
private saveError;
|
|
40
|
-
private isSaveInProgress;
|
|
41
|
-
private isSaveThrottled;
|
|
42
|
-
private enqueueSave;
|
|
43
|
-
private handleBeforeUnload;
|
|
44
|
-
loaders: Loader<TTables, any, any>[];
|
|
45
|
-
protected makeLoader<TResponse, TRequest>(options: LoaderOptions<TTables, TResponse, TRequest>): Loader<TTables, TResponse, TRequest>;
|
|
46
|
-
protected makeListLoader<TItem, TResponse = DataQuery<TItem>, TRequest extends DataQuery<TItem> = DataQuery<TItem>>(options: (LoaderOptions<TTables, TResponse, TRequest> & ListLoadingTrackerOptions<TItem, TResponse>)): Loader<TTables, TResponse, TRequest>;
|
|
47
|
-
reload(): void;
|
|
48
|
-
}
|
|
1
|
+
import { Db } from './Db';
|
|
2
|
+
import { DbPatch, DbTablesSet, ServerError, DbSaveResponse, DbView, DbSubscription } from './types';
|
|
3
|
+
import { IClientIdsMap } from './tempIds';
|
|
4
|
+
import { Loader, LoaderOptions } from './Loader';
|
|
5
|
+
import { DataQuery } from '@epam/uui';
|
|
6
|
+
import { ListLoadingTrackerOptions } from './ListLoadingTracker';
|
|
7
|
+
export declare class DbRef<TTables extends DbTablesSet<TTables>, TDb extends Db<TTables>> {
|
|
8
|
+
blank: TDb;
|
|
9
|
+
private base;
|
|
10
|
+
private log;
|
|
11
|
+
private autoSave;
|
|
12
|
+
private savedPoint;
|
|
13
|
+
private tempIdMap;
|
|
14
|
+
db: TDb;
|
|
15
|
+
errors: ServerError[];
|
|
16
|
+
protected throttleSaveMs: number;
|
|
17
|
+
readonly idMap: IClientIdsMap;
|
|
18
|
+
constructor(blank: TDb);
|
|
19
|
+
/** Saves all committed patches. Useful only if autoSave is off. */
|
|
20
|
+
save(): void;
|
|
21
|
+
getAutoSave(): boolean;
|
|
22
|
+
setAutoSave(val: boolean): void;
|
|
23
|
+
/** Concrete DbRef instances should override and implement their save logic in this method */
|
|
24
|
+
protected savePatch(patch: DbPatch<TTables>): Promise<DbSaveResponse<TTables>>;
|
|
25
|
+
commit(patch: DbPatch<TTables>): void;
|
|
26
|
+
private beforeUpdate;
|
|
27
|
+
commitFetch(patch: DbPatch<TTables>): void;
|
|
28
|
+
private rebase;
|
|
29
|
+
private makeCumulativePatch;
|
|
30
|
+
private applyResponse;
|
|
31
|
+
private lastSubscriptionId;
|
|
32
|
+
private subscriptions;
|
|
33
|
+
subscribe<TValue, TParams, TDependencies>(view: DbView<TDb, TValue, TParams, TDependencies>, params: TParams, onUpdate: (newValue: TValue) => any): DbSubscription<TValue, TParams>;
|
|
34
|
+
updateHandlers: (() => any)[];
|
|
35
|
+
onUpdate(handler: () => any): void;
|
|
36
|
+
private update;
|
|
37
|
+
saveErrorHandlers: ((request: DbPatch<TTables>, error: any) => void)[];
|
|
38
|
+
onSaveError(handler: (request: DbPatch<TTables>, error: any) => void): void;
|
|
39
|
+
private saveError;
|
|
40
|
+
private isSaveInProgress;
|
|
41
|
+
private isSaveThrottled;
|
|
42
|
+
private enqueueSave;
|
|
43
|
+
private handleBeforeUnload;
|
|
44
|
+
loaders: Loader<TTables, any, any>[];
|
|
45
|
+
protected makeLoader<TResponse, TRequest>(options: LoaderOptions<TTables, TResponse, TRequest>): Loader<TTables, TResponse, TRequest>;
|
|
46
|
+
protected makeListLoader<TItem, TResponse = DataQuery<TItem>, TRequest extends DataQuery<TItem> = DataQuery<TItem>>(options: (LoaderOptions<TTables, TResponse, TRequest> & ListLoadingTrackerOptions<TItem, TResponse>)): Loader<TTables, TResponse, TRequest>;
|
|
47
|
+
reload(): void;
|
|
48
|
+
}
|
|
49
49
|
//# sourceMappingURL=DbRef.d.ts.map
|
package/src/DbTable.d.ts
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { DbTablePatch, DbQuery, DbEntitySchema, DbPkFieldType, DbTablesSet } from './types';
|
|
2
|
-
import * as I from 'immutable';
|
|
3
|
-
import { SortDirection, DataQueryFilter, SortingOption } from '@epam/uui';
|
|
4
|
-
interface DbIndex<TEntity, TId> {
|
|
5
|
-
field: (keyof TEntity);
|
|
6
|
-
map: I.Map<any, I.Set<any>>;
|
|
7
|
-
}
|
|
8
|
-
interface DbTableState<TEntity, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>> {
|
|
9
|
-
pk: I.Map<any, TEntity>;
|
|
10
|
-
indexes: DbIndex<TEntity, TId>[];
|
|
11
|
-
}
|
|
12
|
-
export declare class DbTable<TEntity, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>> {
|
|
13
|
-
readonly schema: DbEntitySchema<TEntity, TId, TTables>;
|
|
14
|
-
private state?;
|
|
15
|
-
private q?;
|
|
16
|
-
constructor(schema: DbEntitySchema<TEntity, TId, TTables>, state?: DbTableState<TEntity, TId, TTables>, q?: DbQuery<TEntity>);
|
|
17
|
-
protected keyToImmutable(id: TId): TId | I.List<any>;
|
|
18
|
-
byId(id: TId): TEntity;
|
|
19
|
-
getId(entity: Partial<TEntity>): TId;
|
|
20
|
-
private update;
|
|
21
|
-
with(patch: DbTablePatch<TEntity>): this;
|
|
22
|
-
find(filter: DataQueryFilter<TEntity>): DbTable<TEntity, TId, TTables>;
|
|
23
|
-
order(order: SortingOption[]): this;
|
|
24
|
-
orderBy(field: Extract<keyof TEntity, string>, direction?: SortDirection): this;
|
|
25
|
-
thenBy(field: Extract<keyof TEntity, string>, direction?: SortDirection): this;
|
|
26
|
-
search(text: string): this;
|
|
27
|
-
range(from: number, count: number): TEntity[];
|
|
28
|
-
count(): number;
|
|
29
|
-
one(): TEntity;
|
|
30
|
-
toArray(): TEntity[];
|
|
31
|
-
map<T>(fn: (item: TEntity, index?: number) => T): T[];
|
|
32
|
-
private runQuery;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
1
|
+
import { DbTablePatch, DbQuery, DbEntitySchema, DbPkFieldType, DbTablesSet } from './types';
|
|
2
|
+
import * as I from 'immutable';
|
|
3
|
+
import { SortDirection, DataQueryFilter, SortingOption } from '@epam/uui';
|
|
4
|
+
interface DbIndex<TEntity, TId> {
|
|
5
|
+
field: (keyof TEntity);
|
|
6
|
+
map: I.Map<any, I.Set<any>>;
|
|
7
|
+
}
|
|
8
|
+
interface DbTableState<TEntity, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>> {
|
|
9
|
+
pk: I.Map<any, TEntity>;
|
|
10
|
+
indexes: DbIndex<TEntity, TId>[];
|
|
11
|
+
}
|
|
12
|
+
export declare class DbTable<TEntity, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>> {
|
|
13
|
+
readonly schema: DbEntitySchema<TEntity, TId, TTables>;
|
|
14
|
+
private state?;
|
|
15
|
+
private q?;
|
|
16
|
+
constructor(schema: DbEntitySchema<TEntity, TId, TTables>, state?: DbTableState<TEntity, TId, TTables>, q?: DbQuery<TEntity>);
|
|
17
|
+
protected keyToImmutable(id: TId): TId | I.List<any>;
|
|
18
|
+
byId(id: TId): TEntity;
|
|
19
|
+
getId(entity: Partial<TEntity>): TId;
|
|
20
|
+
private update;
|
|
21
|
+
with(patch: DbTablePatch<TEntity>): this;
|
|
22
|
+
find(filter: DataQueryFilter<TEntity>): DbTable<TEntity, TId, TTables>;
|
|
23
|
+
order(order: SortingOption[]): this;
|
|
24
|
+
orderBy(field: Extract<keyof TEntity, string>, direction?: SortDirection): this;
|
|
25
|
+
thenBy(field: Extract<keyof TEntity, string>, direction?: SortDirection): this;
|
|
26
|
+
search(text: string): this;
|
|
27
|
+
range(from: number, count: number): TEntity[];
|
|
28
|
+
count(): number;
|
|
29
|
+
one(): TEntity;
|
|
30
|
+
toArray(): TEntity[];
|
|
31
|
+
map<T>(fn: (item: TEntity, index?: number) => T): T[];
|
|
32
|
+
private runQuery;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
35
|
//# sourceMappingURL=DbTable.d.ts.map
|
package/src/IxSet.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import BTree from 'sorted-btree';
|
|
2
|
-
import { DbQuery } from './types';
|
|
3
|
-
export interface IxSetIndexDefinition<TEntity> {
|
|
4
|
-
fields: (keyof TEntity)[];
|
|
5
|
-
}
|
|
6
|
-
declare const ID: unique symbol;
|
|
7
|
-
declare type IndexKey<TEntity> = TEntity & {
|
|
8
|
-
[ID]: any;
|
|
9
|
-
};
|
|
10
|
-
export interface IxSetIndex<TEntity> extends IxSetIndexDefinition<TEntity> {
|
|
11
|
-
tree: BTree<IndexKey<TEntity>, void>;
|
|
12
|
-
compare: (a: IndexKey<TEntity>, b: IndexKey<TEntity>) => number;
|
|
13
|
-
}
|
|
14
|
-
export declare class IxSet<TEntity, TId> {
|
|
15
|
-
private getId;
|
|
16
|
-
empty: BTree<TId, TEntity>;
|
|
17
|
-
/** Primary key - a b-tree with entity ID as a key, and entity itself as a value */
|
|
18
|
-
pk: BTree<TId, TEntity>;
|
|
19
|
-
indexes: IxSetIndex<TEntity>[];
|
|
20
|
-
constructor(getId: (e: Partial<TEntity>) => TId, indexesDefinition: IxSetIndexDefinition<TEntity>[]);
|
|
21
|
-
clone(): IxSet<TEntity, TId>;
|
|
22
|
-
byId(id: TId): TEntity;
|
|
23
|
-
with(items: Partial<TEntity>[]): IxSet<TEntity, TId>;
|
|
24
|
-
query(query: DbQuery<TEntity>): TEntity[];
|
|
25
|
-
queryOne(query: DbQuery<TEntity>): TEntity;
|
|
26
|
-
}
|
|
27
|
-
export {};
|
|
1
|
+
import BTree from 'sorted-btree';
|
|
2
|
+
import { DbQuery } from './types';
|
|
3
|
+
export interface IxSetIndexDefinition<TEntity> {
|
|
4
|
+
fields: (keyof TEntity)[];
|
|
5
|
+
}
|
|
6
|
+
declare const ID: unique symbol;
|
|
7
|
+
declare type IndexKey<TEntity> = TEntity & {
|
|
8
|
+
[ID]: any;
|
|
9
|
+
};
|
|
10
|
+
export interface IxSetIndex<TEntity> extends IxSetIndexDefinition<TEntity> {
|
|
11
|
+
tree: BTree<IndexKey<TEntity>, void>;
|
|
12
|
+
compare: (a: IndexKey<TEntity>, b: IndexKey<TEntity>) => number;
|
|
13
|
+
}
|
|
14
|
+
export declare class IxSet<TEntity, TId> {
|
|
15
|
+
private getId;
|
|
16
|
+
empty: BTree<TId, TEntity>;
|
|
17
|
+
/** Primary key - a b-tree with entity ID as a key, and entity itself as a value */
|
|
18
|
+
pk: BTree<TId, TEntity>;
|
|
19
|
+
indexes: IxSetIndex<TEntity>[];
|
|
20
|
+
constructor(getId: (e: Partial<TEntity>) => TId, indexesDefinition: IxSetIndexDefinition<TEntity>[]);
|
|
21
|
+
clone(): IxSet<TEntity, TId>;
|
|
22
|
+
byId(id: TId): TEntity;
|
|
23
|
+
with(items: Partial<TEntity>[]): IxSet<TEntity, TId>;
|
|
24
|
+
query(query: DbQuery<TEntity>): TEntity[];
|
|
25
|
+
queryOne(query: DbQuery<TEntity>): TEntity;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
28
28
|
//# sourceMappingURL=IxSet.d.ts.map
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { DataQuery, LazyDataSourceApiResponse } from '@epam/uui';
|
|
2
|
-
import { ILoadingTracker } from './types';
|
|
3
|
-
export interface ListLoadingTrackerOptions<TItem, TResponse> {
|
|
4
|
-
extractList?: (response: TResponse) => LazyDataSourceApiResponse<TItem>;
|
|
5
|
-
}
|
|
6
|
-
export declare class ListLoadingTracker<TItem, TRequest extends DataQuery<TItem> = DataQuery<TItem>, TResponse = LazyDataSourceApiResponse<TItem>> implements ILoadingTracker<TRequest, TResponse> {
|
|
7
|
-
private options?;
|
|
8
|
-
private cache;
|
|
9
|
-
private extractList;
|
|
10
|
-
constructor(options?: ListLoadingTrackerOptions<TItem, TResponse>);
|
|
11
|
-
private prepare;
|
|
12
|
-
diff(request: TRequest): TRequest;
|
|
13
|
-
count(request: TRequest): {
|
|
14
|
-
knownCount: number;
|
|
15
|
-
exactCount: number;
|
|
16
|
-
};
|
|
17
|
-
append(request: TRequest, response?: TResponse): void;
|
|
18
|
-
}
|
|
1
|
+
import { DataQuery, LazyDataSourceApiResponse } from '@epam/uui';
|
|
2
|
+
import { ILoadingTracker } from './types';
|
|
3
|
+
export interface ListLoadingTrackerOptions<TItem, TResponse> {
|
|
4
|
+
extractList?: (response: TResponse) => LazyDataSourceApiResponse<TItem>;
|
|
5
|
+
}
|
|
6
|
+
export declare class ListLoadingTracker<TItem, TRequest extends DataQuery<TItem> = DataQuery<TItem>, TResponse = LazyDataSourceApiResponse<TItem>> implements ILoadingTracker<TRequest, TResponse> {
|
|
7
|
+
private options?;
|
|
8
|
+
private cache;
|
|
9
|
+
private extractList;
|
|
10
|
+
constructor(options?: ListLoadingTrackerOptions<TItem, TResponse>);
|
|
11
|
+
private prepare;
|
|
12
|
+
diff(request: TRequest): TRequest;
|
|
13
|
+
count(request: TRequest): {
|
|
14
|
+
knownCount: number;
|
|
15
|
+
exactCount: number;
|
|
16
|
+
};
|
|
17
|
+
append(request: TRequest, response?: TResponse): void;
|
|
18
|
+
}
|
|
19
19
|
//# sourceMappingURL=ListLoadingTracker.d.ts.map
|
package/src/Loader.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { DbRef } from './DbRef';
|
|
2
|
-
import { DbPatch, DbTablesSet, LoadingState, ILoadingTracker } from './types';
|
|
3
|
-
export interface LoaderOptions<TTables extends DbTablesSet<TTables>, TResult, TRequest> {
|
|
4
|
-
api: (request: TRequest) => Promise<TResult>;
|
|
5
|
-
convertToPatch?: (result: TResult) => DbPatch<TTables>;
|
|
6
|
-
postProcess?: (patch: DbPatch<TTables>) => DbPatch<TTables>;
|
|
7
|
-
clientToServerRequest?: (request: TRequest) => TRequest;
|
|
8
|
-
}
|
|
9
|
-
export interface LoaderResult<TRequest> extends LoadingState<TRequest> {
|
|
10
|
-
promise: Promise<void>;
|
|
11
|
-
reload: () => void;
|
|
12
|
-
}
|
|
13
|
-
export declare class Loader<TTables extends DbTablesSet<TTables>, TResult, TRequest> {
|
|
14
|
-
private dbRef;
|
|
15
|
-
private getTracker;
|
|
16
|
-
private options;
|
|
17
|
-
private currentRequests;
|
|
18
|
-
loaded: ILoadingTracker<TRequest, TResult>;
|
|
19
|
-
private loadedAndLoading;
|
|
20
|
-
constructor(dbRef: DbRef<TTables, any>, getTracker: () => ILoadingTracker<TRequest, TResult>, options: LoaderOptions<TTables, TResult, TRequest>);
|
|
21
|
-
private loadImpl;
|
|
22
|
-
load: (inputRequest: TRequest) => LoaderResult<TRequest>;
|
|
23
|
-
}
|
|
1
|
+
import { DbRef } from './DbRef';
|
|
2
|
+
import { DbPatch, DbTablesSet, LoadingState, ILoadingTracker } from './types';
|
|
3
|
+
export interface LoaderOptions<TTables extends DbTablesSet<TTables>, TResult, TRequest> {
|
|
4
|
+
api: (request: TRequest) => Promise<TResult>;
|
|
5
|
+
convertToPatch?: (result: TResult) => DbPatch<TTables>;
|
|
6
|
+
postProcess?: (patch: DbPatch<TTables>) => DbPatch<TTables>;
|
|
7
|
+
clientToServerRequest?: (request: TRequest) => TRequest;
|
|
8
|
+
}
|
|
9
|
+
export interface LoaderResult<TRequest> extends LoadingState<TRequest> {
|
|
10
|
+
promise: Promise<void>;
|
|
11
|
+
reload: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class Loader<TTables extends DbTablesSet<TTables>, TResult, TRequest> {
|
|
14
|
+
private dbRef;
|
|
15
|
+
private getTracker;
|
|
16
|
+
private options;
|
|
17
|
+
private currentRequests;
|
|
18
|
+
loaded: ILoadingTracker<TRequest, TResult>;
|
|
19
|
+
private loadedAndLoading;
|
|
20
|
+
constructor(dbRef: DbRef<TTables, any>, getTracker: () => ILoadingTracker<TRequest, TResult>, options: LoaderOptions<TTables, TResult, TRequest>);
|
|
21
|
+
private loadImpl;
|
|
22
|
+
load: (inputRequest: TRequest) => LoaderResult<TRequest>;
|
|
23
|
+
}
|
|
24
24
|
//# sourceMappingURL=Loader.d.ts.map
|
package/src/Scheduler.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export interface SchedulerTask {
|
|
2
|
-
run: () => Promise<any>;
|
|
3
|
-
result?: any;
|
|
4
|
-
error?: any;
|
|
5
|
-
resolve?: (result: any) => void;
|
|
6
|
-
reject?: (result: any) => void;
|
|
7
|
-
isConcurrent: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare class Scheduler {
|
|
10
|
-
scheduled: SchedulerTask[];
|
|
11
|
-
running: SchedulerTask[];
|
|
12
|
-
complete: SchedulerTask[];
|
|
13
|
-
run(run: () => Promise<any>, isConcurrent?: boolean): Promise<unknown>;
|
|
14
|
-
isRunScheduled: boolean;
|
|
15
|
-
private scheduleRun;
|
|
16
|
-
tasksRunning: number;
|
|
17
|
-
private runQueues;
|
|
18
|
-
}
|
|
1
|
+
export interface SchedulerTask {
|
|
2
|
+
run: () => Promise<any>;
|
|
3
|
+
result?: any;
|
|
4
|
+
error?: any;
|
|
5
|
+
resolve?: (result: any) => void;
|
|
6
|
+
reject?: (result: any) => void;
|
|
7
|
+
isConcurrent: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare class Scheduler {
|
|
10
|
+
scheduled: SchedulerTask[];
|
|
11
|
+
running: SchedulerTask[];
|
|
12
|
+
complete: SchedulerTask[];
|
|
13
|
+
run(run: () => Promise<any>, isConcurrent?: boolean): Promise<unknown>;
|
|
14
|
+
isRunScheduled: boolean;
|
|
15
|
+
private scheduleRun;
|
|
16
|
+
tasksRunning: number;
|
|
17
|
+
private runQueues;
|
|
18
|
+
}
|
|
19
19
|
//# sourceMappingURL=Scheduler.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ILoadingTracker } from './types';
|
|
2
|
-
export declare class SimpleLoadingTracker<TRequest, TResult> implements ILoadingTracker<TRequest, TResult> {
|
|
3
|
-
private set;
|
|
4
|
-
constructor();
|
|
5
|
-
private getKey;
|
|
6
|
-
diff(request: TRequest): TRequest;
|
|
7
|
-
append(request: TRequest, result: TResult): void;
|
|
8
|
-
}
|
|
1
|
+
import { ILoadingTracker } from './types';
|
|
2
|
+
export declare class SimpleLoadingTracker<TRequest, TResult> implements ILoadingTracker<TRequest, TResult> {
|
|
3
|
+
private set;
|
|
4
|
+
constructor();
|
|
5
|
+
private getKey;
|
|
6
|
+
diff(request: TRequest): TRequest;
|
|
7
|
+
append(request: TRequest, result: TResult): void;
|
|
8
|
+
}
|
|
9
9
|
//# sourceMappingURL=SimpleLoadingTracker.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import './pkUpdate';
|
|
2
|
-
import './query';
|
|
1
|
+
import './pkUpdate';
|
|
2
|
+
import './query';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=pkLookup.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=pkUpdate.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=sorting.d.ts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { IxSet } from '../IxSet';
|
|
2
|
-
export interface Person {
|
|
3
|
-
id: number;
|
|
4
|
-
name: string;
|
|
5
|
-
departmentId: number;
|
|
6
|
-
location?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const test100KPersons: {
|
|
9
|
-
id: number;
|
|
10
|
-
name: string;
|
|
11
|
-
departmentId: number;
|
|
12
|
-
}[];
|
|
13
|
-
export declare const blankIxSet: IxSet<Person, number>;
|
|
14
|
-
export declare const blankIxSetNoIndex: IxSet<Person, number>;
|
|
1
|
+
import { IxSet } from '../IxSet';
|
|
2
|
+
export interface Person {
|
|
3
|
+
id: number;
|
|
4
|
+
name: string;
|
|
5
|
+
departmentId: number;
|
|
6
|
+
location?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const test100KPersons: {
|
|
9
|
+
id: number;
|
|
10
|
+
name: string;
|
|
11
|
+
departmentId: number;
|
|
12
|
+
}[];
|
|
13
|
+
export declare const blankIxSet: IxSet<Person, number>;
|
|
14
|
+
export declare const blankIxSetNoIndex: IxSet<Person, number>;
|
|
15
15
|
//# sourceMappingURL=testData.d.ts.map
|
package/src/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './types';
|
|
2
|
-
export * from './Db';
|
|
3
|
-
export * from './DbTable';
|
|
4
|
-
export * from './DbRef';
|
|
5
|
-
export * from './tempIds';
|
|
6
|
-
export * from './utils';
|
|
7
|
-
export * from './patchHelpers';
|
|
8
|
-
export * from './reactHooks';
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './Db';
|
|
3
|
+
export * from './DbTable';
|
|
4
|
+
export * from './DbRef';
|
|
5
|
+
export * from './tempIds';
|
|
6
|
+
export * from './utils';
|
|
7
|
+
export * from './patchHelpers';
|
|
8
|
+
export * from './reactHooks';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
package/src/patchHelpers.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { Db } from "./Db";
|
|
2
|
-
import { DbPatch, DbTablesSet, DbEntitySchema, DbPkFieldType } from "./types";
|
|
3
|
-
import { IClientIdsMap } from "./tempIds";
|
|
4
|
-
export declare function unionPatches<TTables extends DbTablesSet<TTables>>(patches: DbPatch<TTables>[]): DbPatch<TTables>;
|
|
5
|
-
export declare function mergeEntityPatches<TTables extends DbTablesSet<TTables>>(tables: TTables, patch: DbPatch<TTables>): DbPatch<TTables>;
|
|
6
|
-
export declare function flattenResponse<TTables extends DbTablesSet<any>>(response: any, tables: TTables): DbPatch<TTables>;
|
|
7
|
-
export declare function isPatchBlank<TTables extends DbTablesSet<TTables>>(patch: DbPatch<TTables>): boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Given several patches, creates a new single patch with all fields from all entities in all patches.
|
|
10
|
-
*/
|
|
11
|
-
export declare function makeCumulativePatch<TTables extends DbTablesSet<TTables>>(updatedDb: Db<TTables>, patches: DbPatch<TTables>[], clientIdsMap: IClientIdsMap): DbPatch<TTables>;
|
|
12
|
-
export declare function isClientOnly<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: T, schema: DbEntitySchema<T, TId, TTables>): boolean;
|
|
13
|
-
export declare function getId<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: Partial<T>, schema: DbEntitySchema<T, TId, TTables>): TId;
|
|
14
|
-
export declare function isNew<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: Partial<T>, schema: DbEntitySchema<T, TId, TTables>, clientIdsMap: IClientIdsMap): boolean;
|
|
15
|
-
export declare function hasServerFields<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: Partial<T>, schema: DbEntitySchema<T, TId, TTables>, clientIdsMap: IClientIdsMap, tables: TTables): boolean;
|
|
16
|
-
export declare function getParentEntities<TTables extends DbTablesSet<TTables>>(patch: DbPatch<TTables>, tables: TTables): DbPatch<TTables>;
|
|
17
|
-
export declare function getEntityParentDependencies<TEntity, TTables extends DbTablesSet<TTables>>(entity: Partial<TEntity>, entityName: keyof TTables, tables: TTables): DbPatch<TTables>;
|
|
1
|
+
import { Db } from "./Db";
|
|
2
|
+
import { DbPatch, DbTablesSet, DbEntitySchema, DbPkFieldType } from "./types";
|
|
3
|
+
import { IClientIdsMap } from "./tempIds";
|
|
4
|
+
export declare function unionPatches<TTables extends DbTablesSet<TTables>>(patches: DbPatch<TTables>[]): DbPatch<TTables>;
|
|
5
|
+
export declare function mergeEntityPatches<TTables extends DbTablesSet<TTables>>(tables: TTables, patch: DbPatch<TTables>): DbPatch<TTables>;
|
|
6
|
+
export declare function flattenResponse<TTables extends DbTablesSet<any>>(response: any, tables: TTables): DbPatch<TTables>;
|
|
7
|
+
export declare function isPatchBlank<TTables extends DbTablesSet<TTables>>(patch: DbPatch<TTables>): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Given several patches, creates a new single patch with all fields from all entities in all patches.
|
|
10
|
+
*/
|
|
11
|
+
export declare function makeCumulativePatch<TTables extends DbTablesSet<TTables>>(updatedDb: Db<TTables>, patches: DbPatch<TTables>[], clientIdsMap: IClientIdsMap): DbPatch<TTables>;
|
|
12
|
+
export declare function isClientOnly<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: T, schema: DbEntitySchema<T, TId, TTables>): boolean;
|
|
13
|
+
export declare function getId<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: Partial<T>, schema: DbEntitySchema<T, TId, TTables>): TId;
|
|
14
|
+
export declare function isNew<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: Partial<T>, schema: DbEntitySchema<T, TId, TTables>, clientIdsMap: IClientIdsMap): boolean;
|
|
15
|
+
export declare function hasServerFields<T, TId extends DbPkFieldType, TTables extends DbTablesSet<TTables>>(entity: Partial<T>, schema: DbEntitySchema<T, TId, TTables>, clientIdsMap: IClientIdsMap, tables: TTables): boolean;
|
|
16
|
+
export declare function getParentEntities<TTables extends DbTablesSet<TTables>>(patch: DbPatch<TTables>, tables: TTables): DbPatch<TTables>;
|
|
17
|
+
export declare function getEntityParentDependencies<TEntity, TTables extends DbTablesSet<TTables>>(entity: Partial<TEntity>, entityName: keyof TTables, tables: TTables): DbPatch<TTables>;
|
|
18
18
|
//# sourceMappingURL=patchHelpers.d.ts.map
|
package/src/reactHooks.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { DbRef } from './DbRef';
|
|
3
|
-
import { DbViewOptions } from '.';
|
|
4
|
-
export declare const DbContext: import("react").Context<any>;
|
|
5
|
-
export declare function useDbRef<TDbRef extends DbRef<any, any>>(): TDbRef;
|
|
6
|
-
export declare function useDbView<TDb, TResult, TParams = void, TDependencies = void>(fn: (db: TDb, params: TParams, dependencies: TDependencies) => TResult, params?: TParams, options?: DbViewOptions<TDb, TResult, TParams, TDependencies>): TResult;
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DbRef } from './DbRef';
|
|
3
|
+
import { DbViewOptions } from '.';
|
|
4
|
+
export declare const DbContext: import("react").Context<any>;
|
|
5
|
+
export declare function useDbRef<TDbRef extends DbRef<any, any>>(): TDbRef;
|
|
6
|
+
export declare function useDbView<TDb, TResult, TParams = void, TDependencies = void>(fn: (db: TDb, params: TParams, dependencies: TDependencies) => TResult, params?: TParams, options?: DbViewOptions<TDb, TResult, TParams, TDependencies>): TResult;
|
|
7
7
|
//# sourceMappingURL=reactHooks.d.ts.map
|