@deephaven/storage 0.43.0 → 0.44.1-beta.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/dist/Storage.js +6 -0
- package/dist/Storage.js.map +1 -0
- package/dist/StorageTableViewportUpdater.js +63 -0
- package/dist/StorageTableViewportUpdater.js.map +1 -0
- package/dist/StorageUtils.js +39 -0
- package/dist/StorageUtils.js.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/package.json +4 -4
package/dist/Storage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Storage.js","names":["SortDirection"],"sources":["../src/Storage.ts"],"sourcesContent":["export type FilterValue = number | string | string[];\n\nexport type FilterConfigItem = {\n columnName: string;\n type: string;\n value: FilterValue;\n};\n\nexport type FilterConfig = {\n filterItems: FilterConfigItem[];\n filterOperators: string[];\n};\n\nexport enum SortDirection {\n ASC = 'asc',\n DESC = 'desc',\n}\n\nexport type SortConfig = {\n column: string;\n direction: SortDirection;\n};\n\nexport type IndexRange = number[];\n\nexport interface Storage<T extends StorageItem> {\n getTable(): Promise<StorageTable<T>>;\n close(): void;\n}\n\nexport interface StorageTable<T extends StorageItem> {\n getViewportData(): Promise<ViewportData<T>>;\n getSnapshot(sortedRanges: IndexRange[]): Promise<StorageSnapshot<T>>;\n setViewport(viewport: StorageTableViewport): void;\n setFilters(config: FilterConfig[] | null): void;\n setSorts(config: SortConfig[] | null): void;\n setReversed(isReversed: boolean): void;\n close(): void;\n onUpdate(callback: ViewportUpdateCallback<T>): StorageListenerRemover;\n size: number;\n}\n\nexport interface StorageItem {\n id: string;\n}\n\nexport interface UnsavedStorageItem {\n id: undefined;\n}\n\nexport type StorageTableViewport = {\n top: number;\n bottom: number;\n columns?: string[];\n};\n\nexport type StorageSnapshot<T extends StorageItem> = Map<number, T>;\n\nexport type ViewportData<T extends StorageItem> = {\n items: T[];\n offset: number;\n};\n\nexport type ViewportUpdateCallback<T extends StorageItem> = (\n viewportUpdate: ViewportData<T>\n) => void;\n\nexport type StorageListenerRemover = () => void;\n\nexport type StorageItemListener<T extends StorageItem> = (update: T) => void;\n\nexport type StorageErrorListener = (error: string) => void;\n"],"mappings":"AAaA,WAAYA,aAAa;AAGxB,WAHWA,aAAa;EAAbA,aAAa;EAAbA,aAAa;AAAA,GAAbA,aAAa,KAAbA,aAAa"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react';
|
|
2
|
+
import Log from '@deephaven/log';
|
|
3
|
+
import throttle from 'lodash.throttle';
|
|
4
|
+
var UPDATE_DELAY = 150;
|
|
5
|
+
var ROW_BUFFER_PAGES = 3;
|
|
6
|
+
var log = Log.module('StorageTableViewportUpdater');
|
|
7
|
+
export function StorageTableViewportUpdater(_ref) {
|
|
8
|
+
var {
|
|
9
|
+
table,
|
|
10
|
+
columns,
|
|
11
|
+
top = 0,
|
|
12
|
+
bottom = 0,
|
|
13
|
+
filters,
|
|
14
|
+
sorts,
|
|
15
|
+
isReversed = false,
|
|
16
|
+
onUpdate
|
|
17
|
+
} = _ref;
|
|
18
|
+
var throttledUpdateViewport = useMemo(() => throttle(viewport => {
|
|
19
|
+
var viewHeight = viewport.bottom - viewport.top;
|
|
20
|
+
var bufferedTop = Math.max(0, viewport.top - viewHeight * ROW_BUFFER_PAGES);
|
|
21
|
+
var bufferedBottom = viewport.bottom + viewHeight * ROW_BUFFER_PAGES;
|
|
22
|
+
table.setViewport({
|
|
23
|
+
top: bufferedTop,
|
|
24
|
+
bottom: bufferedBottom,
|
|
25
|
+
columns: viewport.columns
|
|
26
|
+
});
|
|
27
|
+
}, UPDATE_DELAY), [table]);
|
|
28
|
+
useEffect(function updateViewportAndReturnCleanup() {
|
|
29
|
+
var cleanup = table.onUpdate(viewportData => {
|
|
30
|
+
var _viewportData$items, _viewportData$offset;
|
|
31
|
+
onUpdate({
|
|
32
|
+
items: (_viewportData$items = viewportData.items) !== null && _viewportData$items !== void 0 ? _viewportData$items : [],
|
|
33
|
+
offset: (_viewportData$offset = viewportData.offset) !== null && _viewportData$offset !== void 0 ? _viewportData$offset : 0
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
return () => {
|
|
37
|
+
log.debug('onUpdate cleanup');
|
|
38
|
+
cleanup();
|
|
39
|
+
};
|
|
40
|
+
}, [table, onUpdate]);
|
|
41
|
+
useEffect(function updateFilters() {
|
|
42
|
+
table.setFilters(filters !== null && filters !== void 0 ? filters : null);
|
|
43
|
+
}, [table, filters]);
|
|
44
|
+
useEffect(function updateSorts() {
|
|
45
|
+
table.setSorts(sorts !== null && sorts !== void 0 ? sorts : null);
|
|
46
|
+
}, [table, sorts]);
|
|
47
|
+
useEffect(function updateViewport() {
|
|
48
|
+
throttledUpdateViewport({
|
|
49
|
+
top,
|
|
50
|
+
bottom,
|
|
51
|
+
columns
|
|
52
|
+
});
|
|
53
|
+
}, [throttledUpdateViewport, top, bottom, columns, filters, sorts, isReversed]);
|
|
54
|
+
useEffect(function cleanupUpdateViewport() {
|
|
55
|
+
return () => {
|
|
56
|
+
log.debug2('Cancel throttledUpdateViewport');
|
|
57
|
+
throttledUpdateViewport.cancel();
|
|
58
|
+
};
|
|
59
|
+
}, [throttledUpdateViewport]);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
export default StorageTableViewportUpdater;
|
|
63
|
+
//# sourceMappingURL=StorageTableViewportUpdater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageTableViewportUpdater.js","names":["useEffect","useMemo","Log","throttle","UPDATE_DELAY","ROW_BUFFER_PAGES","log","module","StorageTableViewportUpdater","table","columns","top","bottom","filters","sorts","isReversed","onUpdate","throttledUpdateViewport","viewport","viewHeight","bufferedTop","Math","max","bufferedBottom","setViewport","updateViewportAndReturnCleanup","cleanup","viewportData","items","offset","debug","updateFilters","setFilters","updateSorts","setSorts","updateViewport","cleanupUpdateViewport","debug2","cancel"],"sources":["../src/StorageTableViewportUpdater.ts"],"sourcesContent":["import { useEffect, useMemo } from 'react';\nimport Log from '@deephaven/log';\nimport throttle from 'lodash.throttle';\nimport {\n FilterConfig,\n SortConfig,\n StorageItem,\n StorageTable,\n StorageTableViewport,\n ViewportData,\n ViewportUpdateCallback,\n} from './Storage';\n\nexport type StorageTableViewportUpdaterProps<T extends StorageItem> = {\n table: StorageTable<T>;\n columns?: string[];\n top?: number;\n bottom?: number;\n filters?: FilterConfig[];\n sorts?: SortConfig[];\n isReversed?: boolean;\n onUpdate: ViewportUpdateCallback<T>;\n};\n\nconst UPDATE_DELAY = 150;\n\nconst ROW_BUFFER_PAGES = 3;\n\nconst log = Log.module('StorageTableViewportUpdater');\n\nexport function StorageTableViewportUpdater<\n T extends StorageItem = StorageItem\n>({\n table,\n columns,\n top = 0,\n bottom = 0,\n filters,\n sorts,\n isReversed = false,\n onUpdate,\n}: StorageTableViewportUpdaterProps<T>): null {\n const throttledUpdateViewport = useMemo(\n () =>\n throttle((viewport: StorageTableViewport) => {\n const viewHeight = viewport.bottom - viewport.top;\n const bufferedTop = Math.max(\n 0,\n viewport.top - viewHeight * ROW_BUFFER_PAGES\n );\n const bufferedBottom = viewport.bottom + viewHeight * ROW_BUFFER_PAGES;\n\n table.setViewport({\n top: bufferedTop,\n bottom: bufferedBottom,\n columns: viewport.columns,\n });\n }, UPDATE_DELAY),\n [table]\n );\n\n useEffect(\n function updateViewportAndReturnCleanup() {\n const cleanup = table.onUpdate((viewportData: ViewportData<T>) => {\n onUpdate({\n items: viewportData.items ?? [],\n offset: viewportData.offset ?? 0,\n });\n });\n\n return () => {\n log.debug('onUpdate cleanup');\n cleanup();\n };\n },\n [table, onUpdate]\n );\n\n useEffect(\n function updateFilters() {\n table.setFilters(filters ?? null);\n },\n [table, filters]\n );\n\n useEffect(\n function updateSorts() {\n table.setSorts(sorts ?? null);\n },\n [table, sorts]\n );\n\n useEffect(\n function updateViewport() {\n throttledUpdateViewport({\n top,\n bottom,\n columns,\n });\n },\n [throttledUpdateViewport, top, bottom, columns, filters, sorts, isReversed]\n );\n\n useEffect(\n function cleanupUpdateViewport() {\n return () => {\n log.debug2('Cancel throttledUpdateViewport');\n throttledUpdateViewport.cancel();\n };\n },\n [throttledUpdateViewport]\n );\n\n return null;\n}\n\nexport default StorageTableViewportUpdater;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAC1C,OAAOC,GAAG,MAAM,gBAAgB;AAChC,OAAOC,QAAQ,MAAM,iBAAiB;AAsBtC,IAAMC,YAAY,GAAG,GAAG;AAExB,IAAMC,gBAAgB,GAAG,CAAC;AAE1B,IAAMC,GAAG,GAAGJ,GAAG,CAACK,MAAM,CAAC,6BAA6B,CAAC;AAErD,OAAO,SAASC,2BAA2B,OAWG;EAAA,IAT5C;IACAC,KAAK;IACLC,OAAO;IACPC,GAAG,GAAG,CAAC;IACPC,MAAM,GAAG,CAAC;IACVC,OAAO;IACPC,KAAK;IACLC,UAAU,GAAG,KAAK;IAClBC;EACmC,CAAC;EACpC,IAAMC,uBAAuB,GAAGhB,OAAO,CACrC,MACEE,QAAQ,CAAEe,QAA8B,IAAK;IAC3C,IAAMC,UAAU,GAAGD,QAAQ,CAACN,MAAM,GAAGM,QAAQ,CAACP,GAAG;IACjD,IAAMS,WAAW,GAAGC,IAAI,CAACC,GAAG,CAC1B,CAAC,EACDJ,QAAQ,CAACP,GAAG,GAAGQ,UAAU,GAAGd,gBAAgB,CAC7C;IACD,IAAMkB,cAAc,GAAGL,QAAQ,CAACN,MAAM,GAAGO,UAAU,GAAGd,gBAAgB;IAEtEI,KAAK,CAACe,WAAW,CAAC;MAChBb,GAAG,EAAES,WAAW;MAChBR,MAAM,EAAEW,cAAc;MACtBb,OAAO,EAAEQ,QAAQ,CAACR;IACpB,CAAC,CAAC;EACJ,CAAC,EAAEN,YAAY,CAAC,EAClB,CAACK,KAAK,CAAC,CACR;EAEDT,SAAS,CACP,SAASyB,8BAA8B,G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,0 +1,39 @@
|
|
|
1
|
+
import { Operator as FilterOperator } from '@deephaven/filters';
|
|
2
|
+
export class StorageUtils {
|
|
3
|
+
static makeSortConfig(columnName, direction) {
|
|
4
|
+
return {
|
|
5
|
+
column: columnName,
|
|
6
|
+
direction
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
static makeFilterConfig(filters) {
|
|
10
|
+
var filterItems = [];
|
|
11
|
+
var filterOperators = [];
|
|
12
|
+
filters.forEach((filterItem, i) => {
|
|
13
|
+
filterItems.push(filterItem);
|
|
14
|
+
if (i > 0) {
|
|
15
|
+
filterOperators.push(FilterOperator.and);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
filterItems,
|
|
20
|
+
filterOperators
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
static combineFilterConfigs(config1, config2) {
|
|
24
|
+
var operator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : FilterOperator.and;
|
|
25
|
+
return {
|
|
26
|
+
filterItems: [...config1.filterItems, ...config2.filterItems],
|
|
27
|
+
filterOperators: [...config1.filterOperators, operator, ...config2.filterOperators]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
static makeFilterItem(columnName, type, value) {
|
|
31
|
+
return {
|
|
32
|
+
columnName,
|
|
33
|
+
type,
|
|
34
|
+
value
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export default StorageUtils;
|
|
39
|
+
//# sourceMappingURL=StorageUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageUtils.js","names":["Operator","FilterOperator","StorageUtils","makeSortConfig","columnName","direction","column","makeFilterConfig","filters","filterItems","filterOperators","forEach","filterItem","i","push","and","combineFilterConfigs","config1","config2","operator","makeFilterItem","type","value"],"sources":["../src/StorageUtils.ts"],"sourcesContent":["import { Operator as FilterOperator } from '@deephaven/filters';\nimport {\n FilterConfig,\n FilterConfigItem,\n FilterValue,\n SortConfig,\n SortDirection,\n} from './Storage';\n\nexport class StorageUtils {\n static makeSortConfig(\n columnName: string,\n direction: SortDirection\n ): SortConfig {\n return { column: columnName, direction };\n }\n\n static makeFilterConfig(filters: FilterConfigItem[]): FilterConfig {\n const filterItems: FilterConfigItem[] = [];\n const filterOperators: string[] = [];\n filters.forEach((filterItem, i) => {\n filterItems.push(filterItem);\n if (i > 0) {\n filterOperators.push(FilterOperator.and);\n }\n });\n return {\n filterItems,\n filterOperators,\n };\n }\n\n static combineFilterConfigs(\n config1: FilterConfig,\n config2: FilterConfig,\n operator = FilterOperator.and\n ): FilterConfig {\n return {\n filterItems: [...config1.filterItems, ...config2.filterItems],\n filterOperators: [\n ...config1.filterOperators,\n operator,\n ...config2.filterOperators,\n ],\n };\n }\n\n static makeFilterItem(\n columnName: string,\n type: string,\n value: FilterValue\n ): FilterConfigItem {\n return { columnName, type, value };\n }\n}\n\nexport default StorageUtils;\n"],"mappings":"AAAA,SAASA,QAAQ,IAAIC,cAAc,QAAQ,oBAAoB;AAS/D,OAAO,MAAMC,YAAY,CAAC;EACxB,OAAOC,cAAc,CACnBC,UAAkB,EAClBC,SAAwB,EACZ;IACZ,OAAO;MAAEC,MAAM,EAAEF,UAAU;MAAEC;IAAU,CAAC;EAC1C;EAEA,OAAOE,gBAAgB,CAACC,OAA2B,EAAgB;IACjE,IAAMC,WAA+B,GAAG,EAAE;IAC1C,IAAMC,eAAyB,GAAG,EAAE;IACpCF,OAAO,CAACG,OAAO,CAAC,CAACC,UAAU,EAAEC,CAAC,KAAK;MACjCJ,WAAW,CAACK,IAAI,CAACF,UAAU,CAAC;MAC5B,IAAIC,CAAC,GAAG,CAAC,EAAE;QACTH,eAAe,CAACI,IAAI,CAACb,cAAc,CAACc,GAAG,CAAC;MAC1C;IACF,CAAC,CAAC;IACF,OAAO;MACLN,WAAW;MACXC;IACF,CAAC;EACH;EAEA,OAAOM,oBAAoB,CACzBC,OAAqB,EACrBC,OAAqB,EAEP;IAAA,IADdC,QAAQ,uEAAGlB,cAAc,CAACc,GAAG;IAE7B,OAAO;MACLN,WAAW,EAAE,CAAC,GAAGQ,OAAO,CAACR,WAAW,EAAE,GAAGS,OAAO,CAACT,WAAW,CAAC;MAC7DC,eAAe,EAAE,CACf,GAAGO,OAAO,CAACP,eAAe,EAC1BS,QAAQ,EACR,GAAGD,OAAO,CAACR,eAAe;IAE9B,CAAC;EACH;EAEA,OAAOU,cAAc,CACnBhB,UAAkB,EAClBiB,IAAY,EACZC,KAAkB,EACA;IAClB,OAAO;MAAElB,UAAU;MAAEiB,IAAI;MAAEC;IAAM,CAAC;EACpC;AACF;AAEA,eAAepB,YAAY"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './Storage';\nexport * from './StorageTableViewportUpdater';\nexport * from './StorageUtils';\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/storage",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.1-beta.0+ba13c913",
|
|
4
4
|
"description": "Deephaven Storage abstract classes for storing app data",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"build:babel": "babel ./src --out-dir ./dist --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@deephaven/filters": "^0.
|
|
25
|
-
"@deephaven/log": "^0.
|
|
24
|
+
"@deephaven/filters": "^0.44.1-beta.0+ba13c913",
|
|
25
|
+
"@deephaven/log": "^0.44.1-beta.0+ba13c913",
|
|
26
26
|
"lodash.throttle": "^4.1.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "ba13c9139b3b7a5f5d64d79069f1de9d4727eeb6"
|
|
39
39
|
}
|