@deephaven/pouch-storage 0.20.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/LICENSE +176 -0
- package/README.md +9 -0
- package/dist/PouchCommandHistoryStorage.d.ts +13 -0
- package/dist/PouchCommandHistoryStorage.d.ts.map +1 -0
- package/dist/PouchCommandHistoryStorage.js +70 -0
- package/dist/PouchCommandHistoryStorage.js.map +1 -0
- package/dist/PouchCommandHistoryTable.d.ts +8 -0
- package/dist/PouchCommandHistoryTable.d.ts.map +1 -0
- package/dist/PouchCommandHistoryTable.js +15 -0
- package/dist/PouchCommandHistoryTable.js.map +1 -0
- package/dist/PouchStorageTable.d.ts +39 -0
- package/dist/PouchStorageTable.d.ts.map +1 -0
- package/dist/PouchStorageTable.js +438 -0
- package/dist/PouchStorageTable.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandHistoryStorage, CommandHistoryStorageData, CommandHistoryStorageItem } from '@deephaven/console';
|
|
2
|
+
import { StorageItemListener, StorageListenerRemover } from '@deephaven/storage';
|
|
3
|
+
import PouchCommandHistoryTable from './PouchCommandHistoryTable';
|
|
4
|
+
export declare class PouchCommandHistoryStorage implements CommandHistoryStorage {
|
|
5
|
+
private updateTableMap;
|
|
6
|
+
private getUpdateTable;
|
|
7
|
+
getTable(language: string): Promise<PouchCommandHistoryTable>;
|
|
8
|
+
addItem(language: string, scope: string, command: string, data: CommandHistoryStorageData): Promise<CommandHistoryStorageItem>;
|
|
9
|
+
updateItem(language: string, item: CommandHistoryStorageItem): Promise<CommandHistoryStorageItem>;
|
|
10
|
+
listenItem(language: string, id: string, listener: StorageItemListener<CommandHistoryStorageItem>): StorageListenerRemover;
|
|
11
|
+
}
|
|
12
|
+
export default PouchCommandHistoryStorage;
|
|
13
|
+
//# sourceMappingURL=PouchCommandHistoryStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchCommandHistoryStorage.d.ts","sourceRoot":"","sources":["../src/PouchCommandHistoryStorage.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAIlE,qBAAa,0BAA2B,YAAW,qBAAqB;IACtE,OAAO,CAAC,cAAc,CAA+C;IAErE,OAAO,CAAC,cAAc;IAQhB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAI7D,OAAO,CACX,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IAQ/B,UAAU,CACd,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,yBAAyB,GAC9B,OAAO,CAAC,yBAAyB,CAAC;IAgBrC,UAAU,CACR,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,mBAAmB,CAAC,yBAAyB,CAAC,GACvD,sBAAsB;CAK1B;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8
|
+
|
|
9
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
|
|
11
|
+
/* eslint-disable class-methods-use-this */
|
|
12
|
+
import Log from '@deephaven/log';
|
|
13
|
+
import PouchCommandHistoryTable from "./PouchCommandHistoryTable.js";
|
|
14
|
+
var log = Log.module('PouchCommandHistoryStorage');
|
|
15
|
+
export class PouchCommandHistoryStorage {
|
|
16
|
+
constructor() {
|
|
17
|
+
_defineProperty(this, "updateTableMap", new Map());
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getUpdateTable(language) {
|
|
21
|
+
if (!this.updateTableMap.has(language)) {
|
|
22
|
+
this.updateTableMap.set(language, new PouchCommandHistoryTable(language));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return this.updateTableMap.get(language);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getTable(language) {
|
|
29
|
+
return _asyncToGenerator(function* () {
|
|
30
|
+
return new PouchCommandHistoryTable(language);
|
|
31
|
+
})();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
addItem(language, scope, command, data) {
|
|
35
|
+
var _this = this;
|
|
36
|
+
|
|
37
|
+
return _asyncToGenerator(function* () {
|
|
38
|
+
return _this.updateItem(language, {
|
|
39
|
+
id: "".concat(new Date().getTime()),
|
|
40
|
+
name: command,
|
|
41
|
+
data
|
|
42
|
+
});
|
|
43
|
+
})();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
updateItem(language, item) {
|
|
47
|
+
var _this2 = this;
|
|
48
|
+
|
|
49
|
+
return _asyncToGenerator(function* () {
|
|
50
|
+
var updateTable = _this2.getUpdateTable(language);
|
|
51
|
+
|
|
52
|
+
var dbItem = yield updateTable.refreshItem(item.id);
|
|
53
|
+
|
|
54
|
+
var updatedItem = _objectSpread(_objectSpread({}, dbItem !== null && dbItem !== void 0 ? dbItem : {}), item);
|
|
55
|
+
|
|
56
|
+
log.debug('Updating item', updatedItem);
|
|
57
|
+
yield updateTable.put(updatedItem);
|
|
58
|
+
log.debug('Update saved');
|
|
59
|
+
return item;
|
|
60
|
+
})();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
listenItem(language, id, listener) {
|
|
64
|
+
var updateTable = this.getUpdateTable(language);
|
|
65
|
+
return updateTable.onItemUpdate(id, listener);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}
|
|
69
|
+
export default PouchCommandHistoryStorage;
|
|
70
|
+
//# sourceMappingURL=PouchCommandHistoryStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchCommandHistoryStorage.js","names":["Log","PouchCommandHistoryTable","log","module","PouchCommandHistoryStorage","Map","getUpdateTable","language","updateTableMap","has","set","get","getTable","addItem","scope","command","data","updateItem","id","Date","getTime","name","item","updateTable","dbItem","refreshItem","updatedItem","debug","put","listenItem","listener","onItemUpdate"],"sources":["../src/PouchCommandHistoryStorage.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport Log from '@deephaven/log';\nimport {\n CommandHistoryStorage,\n CommandHistoryStorageData,\n CommandHistoryStorageItem,\n} from '@deephaven/console';\nimport {\n StorageItemListener,\n StorageListenerRemover,\n} from '@deephaven/storage';\nimport PouchCommandHistoryTable from './PouchCommandHistoryTable';\n\nconst log = Log.module('PouchCommandHistoryStorage');\n\nexport class PouchCommandHistoryStorage implements CommandHistoryStorage {\n private updateTableMap = new Map<string, PouchCommandHistoryTable>();\n\n private getUpdateTable(language: string): PouchCommandHistoryTable {\n if (!this.updateTableMap.has(language)) {\n this.updateTableMap.set(language, new PouchCommandHistoryTable(language));\n }\n\n return this.updateTableMap.get(language) as PouchCommandHistoryTable;\n }\n\n async getTable(language: string): Promise<PouchCommandHistoryTable> {\n return new PouchCommandHistoryTable(language);\n }\n\n async addItem(\n language: string,\n scope: string,\n command: string,\n data: CommandHistoryStorageData\n ): Promise<CommandHistoryStorageItem> {\n return this.updateItem(language, {\n id: `${new Date().getTime()}`,\n name: command,\n data,\n } as CommandHistoryStorageItem);\n }\n\n async updateItem(\n language: string,\n item: CommandHistoryStorageItem\n ): Promise<CommandHistoryStorageItem> {\n const updateTable = this.getUpdateTable(language);\n\n const dbItem = await updateTable.refreshItem(item.id);\n\n const updatedItem = { ...(dbItem ?? {}), ...item };\n\n log.debug('Updating item', updatedItem);\n\n await updateTable.put(updatedItem);\n\n log.debug('Update saved');\n\n return item;\n }\n\n listenItem(\n language: string,\n id: string,\n listener: StorageItemListener<CommandHistoryStorageItem>\n ): StorageListenerRemover {\n const updateTable = this.getUpdateTable(language);\n\n return updateTable.onItemUpdate(id, listener);\n }\n}\n\nexport default PouchCommandHistoryStorage;\n"],"mappings":";;;;;;;;;;AAAA;AACA,OAAOA,GAAP,MAAgB,gBAAhB;OAUOC,wB;AAEP,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,4BAAX,CAAZ;AAEA,OAAO,MAAMC,0BAAN,CAAkE;EAAA;IAAA,wCAC9C,IAAIC,GAAJ,EAD8C;EAAA;;EAG/DC,cAAc,CAACC,QAAD,EAA6C;IACjE,IAAI,CAAC,KAAKC,cAAL,CAAoBC,GAApB,CAAwBF,QAAxB,CAAL,EAAwC;MACtC,KAAKC,cAAL,CAAoBE,GAApB,CAAwBH,QAAxB,EAAkC,IAAIN,wBAAJ,CAA6BM,QAA7B,CAAlC;IACD;;IAED,OAAO,KAAKC,cAAL,CAAoBG,GAApB,CAAwBJ,QAAxB,CAAP;EACD;;EAEKK,QAAQ,CAACL,QAAD,EAAsD;IAAA;MAClE,OAAO,IAAIN,wBAAJ,CAA6BM,QAA7B,CAAP;IADkE;EAEnE;;EAEKM,OAAO,CACXN,QADW,EAEXO,KAFW,EAGXC,OAHW,EAIXC,IAJW,EAKyB;IAAA;;IAAA;MACpC,OAAO,KAAI,CAACC,UAAL,CAAgBV,QAAhB,EAA0B;QAC/BW,EAAE,YAAK,IAAIC,IAAJ,GAAWC,OAAX,EAAL,CAD6B;QAE/BC,IAAI,EAAEN,OAFyB;QAG/BC;MAH+B,CAA1B,CAAP;IADoC;EAMrC;;EAEKC,UAAU,CACdV,QADc,EAEde,IAFc,EAGsB;IAAA;;IAAA;MACpC,IAAMC,WAAW,GAAG,MAAI,CAACjB,cAAL,CAAoBC,QAApB,CAApB;;MAEA,IAAMiB,MAAM,SAASD,WAAW,CAACE,WAAZ,CAAwBH,IAAI,CAACJ,EAA7B,CAArB;;MAEA,IAAMQ,WAAW,mCAASF,MAAT,aAASA,MAAT,cAASA,MAAT,GAAmB,EAAnB,GAA2BF,IAA3B,CAAjB;;MAEApB,GAAG,CAACyB,KAAJ,CAAU,eAAV,EAA2BD,WAA3B;MAEA,MAAMH,WAAW,CAACK,GAAZ,CAAgBF,WAAhB,CAAN;MAEAxB,GAAG,CAACyB,KAAJ,CAAU,cAAV;MAEA,OAAOL,IAAP;IAboC;EAcrC;;EAEDO,UAAU,CACRtB,QADQ,EAERW,EAFQ,EAGRY,QAHQ,EAIgB;IACxB,IAAMP,WAAW,GAAG,KAAKjB,cAAL,CAAoBC,QAApB,CAApB;IAEA,OAAOgB,WAAW,CAACQ,YAAZ,CAAyBb,EAAzB,EAA6BY,QAA7B,CAAP;EACD;;AAvDsE;AA0DzE,eAAe1B,0BAAf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CommandHistoryStorageItem, CommandHistoryTable } from '@deephaven/console';
|
|
2
|
+
import PouchStorageTable from './PouchStorageTable';
|
|
3
|
+
export declare class PouchCommandHistoryTable extends PouchStorageTable<CommandHistoryStorageItem> implements CommandHistoryTable {
|
|
4
|
+
constructor(language: string);
|
|
5
|
+
setSearch(search: string): void;
|
|
6
|
+
}
|
|
7
|
+
export default PouchCommandHistoryTable;
|
|
8
|
+
//# sourceMappingURL=PouchCommandHistoryTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchCommandHistoryTable.d.ts","sourceRoot":"","sources":["../src/PouchCommandHistoryTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACpB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,qBAAa,wBACX,SAAQ,iBAAiB,CAAC,yBAAyB,CACnD,YAAW,mBAAmB;gBAClB,QAAQ,EAAE,MAAM;IAI5B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAWhC;AAED,eAAe,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Type as FilterType } from '@deephaven/filters';
|
|
2
|
+
import { StorageUtils } from '@deephaven/storage';
|
|
3
|
+
import PouchStorageTable from "./PouchStorageTable.js";
|
|
4
|
+
export class PouchCommandHistoryTable extends PouchStorageTable<CommandHistoryStorageItem> {
|
|
5
|
+
constructor(language) {
|
|
6
|
+
super("CommandHistoryStorage.".concat(language));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
setSearch(search) {
|
|
10
|
+
this.setFilters(search ? [StorageUtils.makeFilterConfig([StorageUtils.makeFilterItem('name', FilterType.contains, search)])] : []);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
export default PouchCommandHistoryTable;
|
|
15
|
+
//# sourceMappingURL=PouchCommandHistoryTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchCommandHistoryTable.js","names":["Type","FilterType","StorageUtils","PouchStorageTable","PouchCommandHistoryTable","CommandHistoryStorageItem","constructor","language","setSearch","search","setFilters","makeFilterConfig","makeFilterItem","contains"],"sources":["../src/PouchCommandHistoryTable.ts"],"sourcesContent":["import {\n CommandHistoryStorageItem,\n CommandHistoryTable,\n} from '@deephaven/console';\nimport { Type as FilterType } from '@deephaven/filters';\nimport { StorageUtils } from '@deephaven/storage';\nimport PouchStorageTable from './PouchStorageTable';\n\nexport class PouchCommandHistoryTable\n extends PouchStorageTable<CommandHistoryStorageItem>\n implements CommandHistoryTable {\n constructor(language: string) {\n super(`CommandHistoryStorage.${language}`);\n }\n\n setSearch(search: string): void {\n this.setFilters(\n search\n ? [\n StorageUtils.makeFilterConfig([\n StorageUtils.makeFilterItem('name', FilterType.contains, search),\n ]),\n ]\n : []\n );\n }\n}\n\nexport default PouchCommandHistoryTable;\n"],"mappings":"AAIA,SAASA,IAAI,IAAIC,UAAjB,QAAmC,oBAAnC;AACA,SAASC,YAAT,QAA6B,oBAA7B;OACOC,iB;AAEP,OAAO,MAAMC,wBAAN,SACGD,iBAAiB,CAACE,yBAAD,CADpB,CAE0B;EAC/BC,WAAW,CAACC,QAAD,EAAmB;IAC5B,sCAA+BA,QAA/B;EACD;;EAEDC,SAAS,CAACC,MAAD,EAAuB;IAC9B,KAAKC,UAAL,CACED,MAAM,GACF,CACEP,YAAY,CAACS,gBAAb,CAA8B,CAC5BT,YAAY,CAACU,cAAb,CAA4B,MAA5B,EAAoCX,UAAU,CAACY,QAA/C,EAAyDJ,MAAzD,CAD4B,CAA9B,CADF,CADE,GAMF,EAPN;EASD;;AAf8B;AAkBjC,eAAeL,wBAAf"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { FilterConfig, SortConfig, StorageItem, StorageTable, StorageListenerRemover, StorageTableViewport, StorageItemListener, StorageSnapshot, ViewportData, ViewportUpdateCallback } from '@deephaven/storage';
|
|
2
|
+
export declare type PouchDBSort = Array<string | {
|
|
3
|
+
[propName: string]: 'asc' | 'desc';
|
|
4
|
+
}>;
|
|
5
|
+
export declare class PouchStorageTable<T extends StorageItem = StorageItem> implements StorageTable<T> {
|
|
6
|
+
private db;
|
|
7
|
+
private listeners;
|
|
8
|
+
private itemListeners;
|
|
9
|
+
private currentSize;
|
|
10
|
+
private currentViewport?;
|
|
11
|
+
private currentReverse;
|
|
12
|
+
private currentFilter;
|
|
13
|
+
private currentSort;
|
|
14
|
+
private infoUpdatePromise?;
|
|
15
|
+
private viewportUpdatePromise?;
|
|
16
|
+
private currentViewportData?;
|
|
17
|
+
constructor(databaseName: string);
|
|
18
|
+
onUpdate(callback: ViewportUpdateCallback<T>): StorageListenerRemover;
|
|
19
|
+
onItemUpdate(id: string, listener: StorageItemListener<T>): StorageListenerRemover;
|
|
20
|
+
close(): void;
|
|
21
|
+
get size(): number;
|
|
22
|
+
get viewport(): StorageTableViewport | undefined;
|
|
23
|
+
setReversed(reversed: boolean): void;
|
|
24
|
+
setViewport(viewport: StorageTableViewport | undefined): void;
|
|
25
|
+
setSorts(config: SortConfig[] | null): void;
|
|
26
|
+
setFilters(config: FilterConfig[] | null): void;
|
|
27
|
+
get data(): ViewportData<T> | undefined;
|
|
28
|
+
getViewportData(): Promise<ViewportData<T>>;
|
|
29
|
+
put(item: T): Promise<T>;
|
|
30
|
+
private sendUpdate;
|
|
31
|
+
private sendItemUpdate;
|
|
32
|
+
private dbUpdate;
|
|
33
|
+
private refreshInfo;
|
|
34
|
+
private refreshData;
|
|
35
|
+
refreshItem(id: string): Promise<T | undefined>;
|
|
36
|
+
getSnapshot(sortedRanges: [number, number][]): Promise<StorageSnapshot<T>>;
|
|
37
|
+
}
|
|
38
|
+
export default PouchStorageTable;
|
|
39
|
+
//# sourceMappingURL=PouchStorageTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchStorageTable.d.ts","sourceRoot":"","sources":["../src/PouchStorageTable.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,YAAY,EAEZ,UAAU,EACV,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,YAAY,EACZ,sBAAsB,EACvB,MAAM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CAAC,GAAG,SAAS,CAEtC;IAEK,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAS3C,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAa9B,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,QAAQ;YAYF,WAAW;YAwBX,WAAW;IA0CnB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAe/C,WAAW,CACf,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,GAC/B,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;CA2B/B;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
|
|
7
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8
|
+
|
|
9
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
|
|
11
|
+
import PouchDB from 'pouchdb-browser';
|
|
12
|
+
import PouchDBFind from 'pouchdb-find';
|
|
13
|
+
import { Operator as FilterOperator, Type as FilterType } from '@deephaven/filters';
|
|
14
|
+
import Log from '@deephaven/log';
|
|
15
|
+
import { PromiseUtils } from '@deephaven/utils';
|
|
16
|
+
var log = Log.module('PouchStorageTable');
|
|
17
|
+
var DB_PREFIX = 'Deephaven.';
|
|
18
|
+
PouchDB.plugin(PouchDBFind);
|
|
19
|
+
|
|
20
|
+
function makePouchFilter(type, value) {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case FilterType.in:
|
|
23
|
+
case FilterType.contains:
|
|
24
|
+
return {
|
|
25
|
+
$regex: new RegExp("".concat(value))
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
case FilterType.inIgnoreCase:
|
|
29
|
+
return {
|
|
30
|
+
$regex: new RegExp("".concat(value), 'i')
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
case FilterType.eq:
|
|
34
|
+
return {
|
|
35
|
+
$eq: value
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
case FilterType.notEq:
|
|
39
|
+
return {
|
|
40
|
+
$neq: value
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
case FilterType.greaterThan:
|
|
44
|
+
return {
|
|
45
|
+
$gt: value
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
case FilterType.greaterThanOrEqualTo:
|
|
49
|
+
return {
|
|
50
|
+
$gte: value
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
case FilterType.lessThan:
|
|
54
|
+
return {
|
|
55
|
+
$lt: value
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
case FilterType.lessThanOrEqualTo:
|
|
59
|
+
return {
|
|
60
|
+
$lte: value
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
case FilterType.startsWith:
|
|
64
|
+
return {
|
|
65
|
+
$regex: new RegExp("^(?".concat(value, ").*"))
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
default:
|
|
69
|
+
throw new Error("Unsupported type: ".concat(type));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function makePouchSelectorFromConfig(config) {
|
|
74
|
+
var {
|
|
75
|
+
filterItems,
|
|
76
|
+
filterOperators
|
|
77
|
+
} = config;
|
|
78
|
+
var filter = null;
|
|
79
|
+
|
|
80
|
+
for (var i = 0; i < filterItems.length; i += 1) {
|
|
81
|
+
var filterItem = filterItems[i];
|
|
82
|
+
var {
|
|
83
|
+
columnName,
|
|
84
|
+
type,
|
|
85
|
+
value
|
|
86
|
+
} = filterItem;
|
|
87
|
+
var newFilter = {
|
|
88
|
+
[columnName]: makePouchFilter(type, value)
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
if (i === 0) {
|
|
92
|
+
filter = newFilter;
|
|
93
|
+
} else if (filter !== null && i - 1 < filterOperators.length) {
|
|
94
|
+
var filterOperator = filterOperators[i - 1];
|
|
95
|
+
|
|
96
|
+
if (filterOperator === FilterOperator.and) {
|
|
97
|
+
filter = {
|
|
98
|
+
$and: [filter, newFilter]
|
|
99
|
+
};
|
|
100
|
+
} else if (filterOperator === FilterOperator.or) {
|
|
101
|
+
filter = {
|
|
102
|
+
$or: [filter, newFilter]
|
|
103
|
+
};
|
|
104
|
+
} else {
|
|
105
|
+
throw new Error("Unexpected filter operator ".concat(filterOperator, ", ").concat(newFilter));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (filter == null) {
|
|
111
|
+
throw new Error("Invalid filter config ".concat(config));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return filter;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function selectorWithFilters() {
|
|
118
|
+
var filters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
119
|
+
return {
|
|
120
|
+
$and: [...filters.map(filter => makePouchSelectorFromConfig(filter)), {
|
|
121
|
+
name: {
|
|
122
|
+
$gt: null
|
|
123
|
+
}
|
|
124
|
+
}, {
|
|
125
|
+
id: {
|
|
126
|
+
$gt: null
|
|
127
|
+
}
|
|
128
|
+
}]
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function sortWithConfigs(sorts) {
|
|
133
|
+
var _sorts$map;
|
|
134
|
+
|
|
135
|
+
var reverse = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
136
|
+
return [{
|
|
137
|
+
id: reverse ? 'desc' : 'asc'
|
|
138
|
+
}, ...((_sorts$map = sorts === null || sorts === void 0 ? void 0 : sorts.map(sort => ({
|
|
139
|
+
[sort.column]: sort.direction
|
|
140
|
+
}))) !== null && _sorts$map !== void 0 ? _sorts$map : [])];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export class PouchStorageTable {
|
|
144
|
+
constructor(databaseName) {
|
|
145
|
+
_defineProperty(this, "db", void 0);
|
|
146
|
+
|
|
147
|
+
_defineProperty(this, "listeners", []);
|
|
148
|
+
|
|
149
|
+
_defineProperty(this, "itemListeners", new Map());
|
|
150
|
+
|
|
151
|
+
_defineProperty(this, "currentSize", 0);
|
|
152
|
+
|
|
153
|
+
_defineProperty(this, "currentViewport", void 0);
|
|
154
|
+
|
|
155
|
+
_defineProperty(this, "currentReverse", false);
|
|
156
|
+
|
|
157
|
+
_defineProperty(this, "currentFilter", null);
|
|
158
|
+
|
|
159
|
+
_defineProperty(this, "currentSort", null);
|
|
160
|
+
|
|
161
|
+
_defineProperty(this, "infoUpdatePromise", void 0);
|
|
162
|
+
|
|
163
|
+
_defineProperty(this, "viewportUpdatePromise", void 0);
|
|
164
|
+
|
|
165
|
+
_defineProperty(this, "currentViewportData", void 0);
|
|
166
|
+
|
|
167
|
+
this.db = new PouchDB("".concat(DB_PREFIX).concat(databaseName)); // Need to set `_remote` to false to remove deprecation warnings: https://github.com/pouchdb/pouchdb/issues/6106
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, no-underscore-dangle
|
|
169
|
+
|
|
170
|
+
this.db._remote = false;
|
|
171
|
+
this.db.changes({
|
|
172
|
+
live: true,
|
|
173
|
+
since: 'now',
|
|
174
|
+
include_docs: true
|
|
175
|
+
}).on('change', this.dbUpdate.bind(this));
|
|
176
|
+
this.db.createIndex({
|
|
177
|
+
index: {
|
|
178
|
+
fields: ['id', 'name']
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
this.refreshInfo();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
onUpdate(callback) {
|
|
185
|
+
this.listeners = [...this.listeners, callback];
|
|
186
|
+
return () => {
|
|
187
|
+
this.listeners = this.listeners.filter(other => other !== callback);
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
onItemUpdate(id, listener) {
|
|
192
|
+
if (!this.itemListeners.has(id)) {
|
|
193
|
+
this.itemListeners.set(id, []);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.itemListeners.set(id, [...this.itemListeners.get(id), listener]);
|
|
197
|
+
this.refreshItem(id);
|
|
198
|
+
return () => {
|
|
199
|
+
this.itemListeners.set(id, this.itemListeners.get(id).filter(other => other !== listener));
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
close() {
|
|
204
|
+
this.listeners = [];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
get size() {
|
|
208
|
+
return this.currentSize;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
get viewport() {
|
|
212
|
+
return this.currentViewport;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
setReversed(reversed) {
|
|
216
|
+
this.currentReverse = reversed;
|
|
217
|
+
this.currentViewportData = undefined;
|
|
218
|
+
this.refreshData();
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
setViewport(viewport) {
|
|
222
|
+
this.currentViewport = viewport;
|
|
223
|
+
this.refreshInfo();
|
|
224
|
+
this.refreshData();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
setSorts(config) {
|
|
228
|
+
this.currentSort = config;
|
|
229
|
+
this.currentViewportData = undefined;
|
|
230
|
+
this.refreshData();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
setFilters(config) {
|
|
234
|
+
this.currentFilter = config;
|
|
235
|
+
this.currentViewportData = undefined;
|
|
236
|
+
this.refreshInfo();
|
|
237
|
+
this.refreshData();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
get data() {
|
|
241
|
+
return this.currentViewportData;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
getViewportData() {
|
|
245
|
+
var _this = this;
|
|
246
|
+
|
|
247
|
+
return _asyncToGenerator(function* () {
|
|
248
|
+
var _this$viewportUpdateP;
|
|
249
|
+
|
|
250
|
+
if (!_this.viewportUpdatePromise) {
|
|
251
|
+
_this.refreshData();
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return (_this$viewportUpdateP = _this.viewportUpdatePromise) !== null && _this$viewportUpdateP !== void 0 ? _this$viewportUpdateP : Promise.resolve({
|
|
255
|
+
items: [],
|
|
256
|
+
offset: 0
|
|
257
|
+
});
|
|
258
|
+
})();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
put(item) {
|
|
262
|
+
var _this2 = this;
|
|
263
|
+
|
|
264
|
+
return _asyncToGenerator(function* () {
|
|
265
|
+
// Put the item ID in both the _id and the id slot
|
|
266
|
+
// PouchDB uses _id everywhere, StorageTable just uses `id` though
|
|
267
|
+
var newItem = _objectSpread(_objectSpread({}, item), {}, {
|
|
268
|
+
_id: item.id
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
yield _this2.db.put(newItem);
|
|
272
|
+
return newItem;
|
|
273
|
+
})();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
sendUpdate() {
|
|
277
|
+
var _this$currentViewport;
|
|
278
|
+
|
|
279
|
+
// Retain a reference to it in case a listener gets removed while sending an update
|
|
280
|
+
var {
|
|
281
|
+
listeners
|
|
282
|
+
} = this;
|
|
283
|
+
var data = (_this$currentViewport = this.currentViewportData) !== null && _this$currentViewport !== void 0 ? _this$currentViewport : {
|
|
284
|
+
items: [],
|
|
285
|
+
offset: 0
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
for (var i = 0; i < listeners.length; i += 1) {
|
|
289
|
+
listeners[i](data);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
sendItemUpdate(item) {
|
|
294
|
+
var listeners = this.itemListeners.get(item.id);
|
|
295
|
+
|
|
296
|
+
if (listeners !== undefined) {
|
|
297
|
+
for (var i = 0; i < listeners.length; i += 1) {
|
|
298
|
+
listeners[i](item);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
dbUpdate(event) {
|
|
304
|
+
log.debug('Update received', event);
|
|
305
|
+
this.refreshInfo();
|
|
306
|
+
|
|
307
|
+
if (event.doc !== undefined) {
|
|
308
|
+
this.sendItemUpdate(event.doc);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
this.refreshData();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
refreshInfo() {
|
|
315
|
+
var _this3 = this;
|
|
316
|
+
|
|
317
|
+
return _asyncToGenerator(function* () {
|
|
318
|
+
try {
|
|
319
|
+
var _this3$infoUpdateProm, _this3$currentFilter;
|
|
320
|
+
|
|
321
|
+
(_this3$infoUpdateProm = _this3.infoUpdatePromise) === null || _this3$infoUpdateProm === void 0 ? void 0 : _this3$infoUpdateProm.cancel();
|
|
322
|
+
_this3.infoUpdatePromise = PromiseUtils.makeCancelable(_this3.db.find({
|
|
323
|
+
selector: selectorWithFilters((_this3$currentFilter = _this3.currentFilter) !== null && _this3$currentFilter !== void 0 ? _this3$currentFilter : []),
|
|
324
|
+
fields: []
|
|
325
|
+
}));
|
|
326
|
+
var findResult = yield _this3.infoUpdatePromise;
|
|
327
|
+
_this3.currentSize = findResult.docs.length;
|
|
328
|
+
|
|
329
|
+
_this3.sendUpdate();
|
|
330
|
+
} catch (e) {
|
|
331
|
+
if (!PromiseUtils.isCanceled(e)) {
|
|
332
|
+
log.error('Unable to refreshInfo', e);
|
|
333
|
+
throw e;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
})();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
refreshData() {
|
|
340
|
+
var _this4 = this;
|
|
341
|
+
|
|
342
|
+
return _asyncToGenerator(function* () {
|
|
343
|
+
if (!_this4.currentViewport) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
try {
|
|
348
|
+
var _this4$viewportUpdate, _this4$currentFilter;
|
|
349
|
+
|
|
350
|
+
var {
|
|
351
|
+
currentViewport: viewport
|
|
352
|
+
} = _this4;
|
|
353
|
+
var sort = sortWithConfigs(_this4.currentSort, _this4.currentReverse);
|
|
354
|
+
(_this4$viewportUpdate = _this4.viewportUpdatePromise) === null || _this4$viewportUpdate === void 0 ? void 0 : _this4$viewportUpdate.cancel();
|
|
355
|
+
_this4.viewportUpdatePromise = PromiseUtils.makeCancelable(_this4.db.find({
|
|
356
|
+
selector: selectorWithFilters((_this4$currentFilter = _this4.currentFilter) !== null && _this4$currentFilter !== void 0 ? _this4$currentFilter : []),
|
|
357
|
+
skip: viewport.top,
|
|
358
|
+
limit: viewport.bottom - viewport.top + 1,
|
|
359
|
+
sort,
|
|
360
|
+
fields: ['id', 'name']
|
|
361
|
+
}).then(findResult => ({
|
|
362
|
+
items: findResult.docs,
|
|
363
|
+
offset: viewport.top
|
|
364
|
+
})));
|
|
365
|
+
var viewportData = yield _this4.viewportUpdatePromise;
|
|
366
|
+
_this4.currentViewportData = viewportData;
|
|
367
|
+
|
|
368
|
+
_this4.sendUpdate();
|
|
369
|
+
|
|
370
|
+
return viewportData;
|
|
371
|
+
} catch (e) {
|
|
372
|
+
if (!PromiseUtils.isCanceled(e)) {
|
|
373
|
+
log.error('Unable to refreshData', e);
|
|
374
|
+
throw e;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
})();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
refreshItem(id) {
|
|
381
|
+
var _this5 = this;
|
|
382
|
+
|
|
383
|
+
return _asyncToGenerator(function* () {
|
|
384
|
+
var findResult = yield _this5.db.find({
|
|
385
|
+
selector: {
|
|
386
|
+
id
|
|
387
|
+
},
|
|
388
|
+
limit: 1
|
|
389
|
+
});
|
|
390
|
+
var item = findResult.docs[0];
|
|
391
|
+
|
|
392
|
+
if (item !== undefined) {
|
|
393
|
+
_this5.sendItemUpdate(item);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return item;
|
|
397
|
+
})();
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
getSnapshot(sortedRanges) {
|
|
401
|
+
var _this6 = this;
|
|
402
|
+
|
|
403
|
+
return _asyncToGenerator(function* () {
|
|
404
|
+
var itemMap = new Map();
|
|
405
|
+
var sort = [{
|
|
406
|
+
id: _this6.currentReverse ? 'desc' : 'asc'
|
|
407
|
+
}];
|
|
408
|
+
yield Promise.all(sortedRanges.map( /*#__PURE__*/function () {
|
|
409
|
+
var _ref2 = _asyncToGenerator(function* (_ref) {
|
|
410
|
+
var _this6$currentFilter;
|
|
411
|
+
|
|
412
|
+
var [from, to] = _ref;
|
|
413
|
+
var limit = to - from + 1;
|
|
414
|
+
return _this6.db.find({
|
|
415
|
+
selector: selectorWithFilters((_this6$currentFilter = _this6.currentFilter) !== null && _this6$currentFilter !== void 0 ? _this6$currentFilter : []),
|
|
416
|
+
skip: from,
|
|
417
|
+
limit,
|
|
418
|
+
sort,
|
|
419
|
+
fields: ['id', 'name']
|
|
420
|
+
}).then(findSnapshotResult => {
|
|
421
|
+
for (var i = 0; i < limit; i += 1) {
|
|
422
|
+
var index = from + i;
|
|
423
|
+
itemMap.set(index, findSnapshotResult.docs[i]);
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
return function (_x) {
|
|
429
|
+
return _ref2.apply(this, arguments);
|
|
430
|
+
};
|
|
431
|
+
}()));
|
|
432
|
+
return itemMap;
|
|
433
|
+
})();
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
}
|
|
437
|
+
export default PouchStorageTable;
|
|
438
|
+
//# sourceMappingURL=PouchStorageTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PouchStorageTable.js","names":["PouchDB","PouchDBFind","Operator","FilterOperator","Type","FilterType","Log","PromiseUtils","log","module","DB_PREFIX","plugin","makePouchFilter","type","value","in","contains","$regex","RegExp","inIgnoreCase","eq","$eq","notEq","$neq","greaterThan","$gt","greaterThanOrEqualTo","$gte","lessThan","$lt","lessThanOrEqualTo","$lte","startsWith","Error","makePouchSelectorFromConfig","config","filterItems","filterOperators","filter","i","length","filterItem","columnName","newFilter","filterOperator","and","$and","or","$or","selectorWithFilters","filters","map","name","id","sortWithConfigs","sorts","reverse","sort","column","direction","PouchStorageTable","constructor","databaseName","Map","db","_remote","changes","live","since","include_docs","on","dbUpdate","bind","createIndex","index","fields","refreshInfo","onUpdate","callback","listeners","other","onItemUpdate","listener","itemListeners","has","set","get","refreshItem","close","size","currentSize","viewport","currentViewport","setReversed","reversed","currentReverse","currentViewportData","undefined","refreshData","setViewport","setSorts","currentSort","setFilters","currentFilter","data","getViewportData","viewportUpdatePromise","Promise","resolve","items","offset","put","item","newItem","_id","sendUpdate","sendItemUpdate","event","debug","doc","infoUpdatePromise","cancel","makeCancelable","find","selector","findResult","docs","e","isCanceled","error","skip","top","limit","bottom","then","viewportData","getSnapshot","sortedRanges","itemMap","all","from","to","findSnapshotResult"],"sources":["../src/PouchStorageTable.ts"],"sourcesContent":["import PouchDB from 'pouchdb-browser';\nimport PouchDBFind from 'pouchdb-find';\nimport {\n Operator as FilterOperator,\n Type as FilterType,\n} from '@deephaven/filters';\nimport Log from '@deephaven/log';\nimport {\n FilterConfig,\n FilterValue,\n SortConfig,\n StorageItem,\n StorageTable,\n StorageListenerRemover,\n StorageTableViewport,\n StorageItemListener,\n StorageSnapshot,\n ViewportData,\n ViewportUpdateCallback,\n} from '@deephaven/storage';\nimport { CancelablePromise, PromiseUtils } from '@deephaven/utils';\n\nconst log = Log.module('PouchStorageTable');\n\nconst DB_PREFIX = 'Deephaven.';\n\nPouchDB.plugin(PouchDBFind);\n\ninterface PouchStorageItem {\n _id?: string;\n}\n\nexport type PouchDBSort = Array<\n string | { [propName: string]: 'asc' | 'desc' }\n>;\n\nfunction makePouchFilter(type: string, value: FilterValue | FilterValue[]) {\n switch (type) {\n case FilterType.in:\n case FilterType.contains:\n return { $regex: new RegExp(`${value}`) };\n case FilterType.inIgnoreCase:\n return { $regex: new RegExp(`${value}`, 'i') };\n case FilterType.eq:\n return { $eq: value };\n case FilterType.notEq:\n return { $neq: value };\n case FilterType.greaterThan:\n return { $gt: value };\n case FilterType.greaterThanOrEqualTo:\n return { $gte: value };\n case FilterType.lessThan:\n return { $lt: value };\n case FilterType.lessThanOrEqualTo:\n return { $lte: value };\n case FilterType.startsWith:\n return { $regex: new RegExp(`^(?${value}).*`) };\n default:\n throw new Error(`Unsupported type: ${type}`);\n }\n}\n\nfunction makePouchSelectorFromConfig(\n config: FilterConfig\n): PouchDB.Find.Selector {\n const { filterItems, filterOperators } = config;\n let filter = null;\n for (let i = 0; i < filterItems.length; i += 1) {\n const filterItem = filterItems[i];\n const { columnName, type, value } = filterItem;\n const newFilter = { [columnName]: makePouchFilter(type, value) };\n if (i === 0) {\n filter = newFilter;\n } else if (filter !== null && i - 1 < filterOperators.length) {\n const filterOperator = filterOperators[i - 1];\n if (filterOperator === FilterOperator.and) {\n filter = { $and: [filter, newFilter] };\n } else if (filterOperator === FilterOperator.or) {\n filter = { $or: [filter, newFilter] };\n } else {\n throw new Error(\n `Unexpected filter operator ${filterOperator}, ${newFilter}`\n );\n }\n }\n }\n if (filter == null) {\n throw new Error(`Invalid filter config ${config}`);\n }\n return filter;\n}\n\nfunction selectorWithFilters(\n filters: FilterConfig[] = []\n): PouchDB.Find.Selector {\n return {\n $and: [\n ...filters.map(filter => makePouchSelectorFromConfig(filter)),\n { name: { $gt: null } },\n { id: { $gt: null } },\n ],\n };\n}\n\nfunction sortWithConfigs(\n sorts: SortConfig[] | null,\n reverse = false\n): PouchDBSort {\n return [\n { id: reverse ? 'desc' : 'asc' },\n ...(sorts?.map(sort => ({ [sort.column]: sort.direction })) ?? []),\n ];\n}\n\nexport class PouchStorageTable<T extends StorageItem = StorageItem>\n implements StorageTable<T> {\n private db: PouchDB.Database<T & PouchStorageItem>;\n\n private listeners: ViewportUpdateCallback<T>[] = [];\n\n private itemListeners: Map<string, StorageItemListener<T>[]> = new Map();\n\n private currentSize = 0;\n\n private currentViewport?: StorageTableViewport;\n\n private currentReverse = false;\n\n private currentFilter: FilterConfig[] | null = null;\n\n private currentSort: SortConfig[] | null = null;\n\n private infoUpdatePromise?: CancelablePromise<\n PouchDB.Find.FindResponse<T & PouchStorageItem>\n >;\n\n private viewportUpdatePromise?: CancelablePromise<ViewportData<T>>;\n\n private currentViewportData?: ViewportData<T>;\n\n constructor(databaseName: string) {\n this.db = new PouchDB<T & PouchStorageItem>(`${DB_PREFIX}${databaseName}`);\n\n // Need to set `_remote` to false to remove deprecation warnings: https://github.com/pouchdb/pouchdb/issues/6106\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, no-underscore-dangle\n (this.db as any)._remote = false;\n\n this.db\n .changes({ live: true, since: 'now', include_docs: true })\n .on('change', this.dbUpdate.bind(this));\n\n this.db.createIndex({ index: { fields: ['id', 'name'] } });\n\n this.refreshInfo();\n }\n\n onUpdate(callback: ViewportUpdateCallback<T>): StorageListenerRemover {\n this.listeners = [...this.listeners, callback];\n return () => {\n this.listeners = this.listeners.filter(other => other !== callback);\n };\n }\n\n onItemUpdate(\n id: string,\n listener: StorageItemListener<T>\n ): StorageListenerRemover {\n if (!this.itemListeners.has(id)) {\n this.itemListeners.set(id, []);\n }\n\n this.itemListeners.set(id, [\n ...(this.itemListeners.get(id) as StorageItemListener<T>[]),\n listener,\n ]);\n\n this.refreshItem(id);\n\n return () => {\n this.itemListeners.set(\n id,\n (this.itemListeners.get(id) as StorageItemListener<T>[]).filter(\n other => other !== listener\n )\n );\n };\n }\n\n close(): void {\n this.listeners = [];\n }\n\n get size(): number {\n return this.currentSize;\n }\n\n get viewport(): StorageTableViewport | undefined {\n return this.currentViewport;\n }\n\n setReversed(reversed: boolean): void {\n this.currentReverse = reversed;\n\n this.currentViewportData = undefined;\n\n this.refreshData();\n }\n\n setViewport(viewport: StorageTableViewport | undefined): void {\n this.currentViewport = viewport;\n\n this.refreshInfo();\n\n this.refreshData();\n }\n\n setSorts(config: SortConfig[] | null): void {\n this.currentSort = config;\n\n this.currentViewportData = undefined;\n\n this.refreshData();\n }\n\n setFilters(config: FilterConfig[] | null): void {\n this.currentFilter = config;\n\n this.currentViewportData = undefined;\n\n this.refreshInfo();\n\n this.refreshData();\n }\n\n get data(): ViewportData<T> | undefined {\n return this.currentViewportData;\n }\n\n async getViewportData(): Promise<ViewportData<T>> {\n if (!this.viewportUpdatePromise) {\n this.refreshData();\n }\n return (\n this.viewportUpdatePromise ?? Promise.resolve({ items: [], offset: 0 })\n );\n }\n\n async put(item: T): Promise<T> {\n // Put the item ID in both the _id and the id slot\n // PouchDB uses _id everywhere, StorageTable just uses `id` though\n const newItem = {\n ...item,\n _id: item.id,\n } as T;\n\n await this.db.put(newItem);\n\n return newItem;\n }\n\n private sendUpdate() {\n // Retain a reference to it in case a listener gets removed while sending an update\n const { listeners } = this;\n const data = this.currentViewportData ?? { items: [], offset: 0 };\n for (let i = 0; i < listeners.length; i += 1) {\n listeners[i](data);\n }\n }\n\n private sendItemUpdate(item: T) {\n const listeners = this.itemListeners.get(item.id);\n if (listeners !== undefined) {\n for (let i = 0; i < listeners.length; i += 1) {\n listeners[i](item);\n }\n }\n }\n\n private dbUpdate(event: PouchDB.Core.ChangesResponseChange<T>): void {\n log.debug('Update received', event);\n\n this.refreshInfo();\n\n if (event.doc !== undefined) {\n this.sendItemUpdate(event.doc);\n }\n\n this.refreshData();\n }\n\n private async refreshInfo() {\n try {\n this.infoUpdatePromise?.cancel();\n\n this.infoUpdatePromise = PromiseUtils.makeCancelable(\n this.db.find({\n selector: selectorWithFilters(this.currentFilter ?? []),\n fields: [],\n })\n );\n\n const findResult = await this.infoUpdatePromise;\n\n this.currentSize = findResult.docs.length;\n\n this.sendUpdate();\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to refreshInfo', e);\n throw e;\n }\n }\n }\n\n private async refreshData(): Promise<ViewportData<T> | undefined> {\n if (!this.currentViewport) {\n return;\n }\n\n try {\n const { currentViewport: viewport } = this;\n\n const sort = sortWithConfigs(this.currentSort, this.currentReverse);\n\n this.viewportUpdatePromise?.cancel();\n\n this.viewportUpdatePromise = PromiseUtils.makeCancelable(\n this.db\n .find({\n selector: selectorWithFilters(this.currentFilter ?? []),\n skip: viewport.top,\n limit: viewport.bottom - viewport.top + 1,\n sort,\n fields: ['id', 'name'],\n })\n .then(findResult => ({\n items: findResult.docs,\n offset: viewport.top,\n }))\n );\n\n const viewportData = await this.viewportUpdatePromise;\n\n this.currentViewportData = viewportData;\n\n this.sendUpdate();\n\n return viewportData;\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to refreshData', e);\n throw e;\n }\n }\n }\n\n async refreshItem(id: string): Promise<T | undefined> {\n const findResult = await this.db.find({\n selector: { id },\n limit: 1,\n });\n\n const item = findResult.docs[0];\n\n if (item !== undefined) {\n this.sendItemUpdate(item);\n }\n\n return item;\n }\n\n async getSnapshot(\n sortedRanges: [number, number][]\n ): Promise<StorageSnapshot<T>> {\n const itemMap = new Map();\n\n const sort: PouchDBSort = [{ id: this.currentReverse ? 'desc' : 'asc' }];\n\n await Promise.all(\n sortedRanges.map(async ([from, to]) => {\n const limit = to - from + 1;\n return this.db\n .find({\n selector: selectorWithFilters(this.currentFilter ?? []),\n skip: from,\n limit,\n sort,\n fields: ['id', 'name'],\n })\n .then(findSnapshotResult => {\n for (let i = 0; i < limit; i += 1) {\n const index = from + i;\n itemMap.set(index, findSnapshotResult.docs[i]);\n }\n });\n })\n );\n\n return itemMap;\n }\n}\n\nexport default PouchStorageTable;\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,OAAP,MAAoB,iBAApB;AACA,OAAOC,WAAP,MAAwB,cAAxB;AACA,SACEC,QAAQ,IAAIC,cADd,EAEEC,IAAI,IAAIC,UAFV,QAGO,oBAHP;AAIA,OAAOC,GAAP,MAAgB,gBAAhB;AAcA,SAA4BC,YAA5B,QAAgD,kBAAhD;AAEA,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,mBAAX,CAAZ;AAEA,IAAMC,SAAS,GAAG,YAAlB;AAEAV,OAAO,CAACW,MAAR,CAAeV,WAAf;;AAUA,SAASW,eAAT,CAAyBC,IAAzB,EAAuCC,KAAvC,EAA2E;EACzE,QAAQD,IAAR;IACE,KAAKR,UAAU,CAACU,EAAhB;IACA,KAAKV,UAAU,CAACW,QAAhB;MACE,OAAO;QAAEC,MAAM,EAAE,IAAIC,MAAJ,WAAcJ,KAAd;MAAV,CAAP;;IACF,KAAKT,UAAU,CAACc,YAAhB;MACE,OAAO;QAAEF,MAAM,EAAE,IAAIC,MAAJ,WAAcJ,KAAd,GAAuB,GAAvB;MAAV,CAAP;;IACF,KAAKT,UAAU,CAACe,EAAhB;MACE,OAAO;QAAEC,GAAG,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,GAA+B;MAArC,CAAD,CAA1B;MAEA,MAAMY,OAAO,CAACgC,GAAR,CACJF,YAAY,CAACtF,GAAb;QAAA,8BAAiB,iBAAsB;UAAA;;UAAA,IAAf,CAACyF,IAAD,EAAOC,EAAP,CAAe;UACrC,IAAMT,KAAK,GAAGS,EAAE,GAAGD,IAAL,GAAY,CAA1B;UACA,OAAO,MAAI,CAAC5E,EAAL,CACJ2D,IADI,CACC;YACJC,QAAQ,EAAE3E,mBAAmB,yBAAC,MAAI,CAACsD,aAAN,uEAAuB,EAAvB,CADzB;YAEJ2B,IAAI,EAAEU,IAFF;YAGJR,KAHI;YAIJ3E,IAJI;YAKJkB,MAAM,EAAE,CAAC,IAAD,EAAO,MAAP;UALJ,CADD,EAQJ2D,IARI,CAQCQ,kBAAkB,IAAI;YAC1B,KAAK,IAAIvG,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG6F,KAApB,EAA2B7F,CAAC,IAAI,CAAhC,EAAmC;cACjC,IAAMmC,KAAK,GAAGkE,IAAI,GAAGrG,CAArB;cACAmG,OAAO,CAACrD,GAAR,CAAYX,KAAZ,EAAmBoE,kBAAkB,CAAChB,IAAnB,CAAwBvF,CAAxB,CAAnB;YACD;UACF,CAbI,CAAP;QAcD,CAhBD;;QAAA;UAAA;QAAA;MAAA,IADI,CAAN;MAoBA,OAAOmG,OAAP;IAzB6B;EA0B9B;;AA5R0B;AA+R7B,eAAe9E,iBAAf"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './PouchCommandHistoryStorage';\n"],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deephaven/pouch-storage",
|
|
3
|
+
"version": "0.20.1-beta.0+d483569",
|
|
4
|
+
"description": "Deephaven Storage based on PouchDB",
|
|
5
|
+
"author": "Deephaven Data Labs LLC",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/deephaven/web-client-ui.git",
|
|
11
|
+
"directory": "packages/pouch-storage"
|
|
12
|
+
},
|
|
13
|
+
"source": "src/index.js",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"types": "dist/index.d.ts",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=16"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "cross-env NODE_ENV=production run-p build:*",
|
|
21
|
+
"build-dev": "cross-env NODE_ENV=development run-p build:*",
|
|
22
|
+
"babel": "babel ./src --out-dir ./dist --extensions \".ts,.tsx,.js,.jsx\" --source-maps --root-mode upward",
|
|
23
|
+
"build:babel": "npm run babel",
|
|
24
|
+
"watch": "run-p watch:*",
|
|
25
|
+
"watch:babel": "npm run babel -- -w --skip-initial-build",
|
|
26
|
+
"prestart": "npm run build-dev",
|
|
27
|
+
"start": "cross-env NODE_ENV=development npm run watch"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@deephaven/console": "^0.20.1-beta.0+d483569",
|
|
31
|
+
"@deephaven/filters": "^0.20.1-beta.0+d483569",
|
|
32
|
+
"@deephaven/log": "^0.20.1-beta.0+d483569",
|
|
33
|
+
"@deephaven/storage": "^0.20.1-beta.0+d483569",
|
|
34
|
+
"@deephaven/utils": "^0.20.1-beta.0+d483569",
|
|
35
|
+
"lodash.throttle": "^4.1.1",
|
|
36
|
+
"pouchdb-browser": "^7.3.0",
|
|
37
|
+
"pouchdb-find": "^7.3.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"react": "^17.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@deephaven/tsconfig": "^0.20.1-beta.0+d483569"
|
|
44
|
+
},
|
|
45
|
+
"files": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"gitHead": "d483569ffe9aadc229d8869aee1e4f38ca6b3c4a"
|
|
52
|
+
}
|