@requestnetwork/data-access 0.27.1-next.1862 → 0.27.1-next.1864
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/block.d.ts +4 -4
- package/dist/block.d.ts.map +1 -1
- package/dist/combined-data-access.js +2 -2
- package/dist/data-access.js +15 -15
- package/dist/ignored-location.js +5 -5
- package/dist/interval-timer.js +2 -2
- package/dist/transaction-index/index.js +2 -2
- package/dist/transaction-index/index.js.map +1 -1
- package/dist/transaction-index/location-by-topic.js +5 -5
- package/dist/transaction-index/timestamp-by-location.js +7 -7
- package/dist/transaction-index/transaction-index.js +10 -10
- package/dist/transaction-index/transaction-index.js.map +1 -1
- package/package.json +9 -9
package/dist/block.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { DataAccessTypes } from '@requestnetwork/types';
|
|
2
|
+
/**
|
|
3
|
+
* Module to manage a block in the data access-layer
|
|
4
|
+
* a block is a sorted list of transactions with topics
|
|
5
|
+
*/
|
|
2
6
|
declare const _default: {
|
|
3
7
|
createEmptyBlock: typeof createEmptyBlock;
|
|
4
8
|
getAllChannelIds: typeof getAllChannelIds;
|
|
@@ -11,10 +15,6 @@ declare const _default: {
|
|
|
11
15
|
parseBlock: typeof parseBlock;
|
|
12
16
|
pushTransaction: typeof pushTransaction;
|
|
13
17
|
};
|
|
14
|
-
/**
|
|
15
|
-
* Module to manage a block in the data access-layer
|
|
16
|
-
* a block is a sorted list of transactions with topics
|
|
17
|
-
*/
|
|
18
18
|
export default _default;
|
|
19
19
|
/**
|
|
20
20
|
* Function to create an empty block
|
package/dist/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"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gBAAgB,CAAC,KAAK,EAAE,eAAe,CAAC,MAAM,GAAG,eAAe,CAAC,WAAW,CAEpF"}
|
|
@@ -12,13 +12,13 @@ class CombinedDataAccess {
|
|
|
12
12
|
this.persistTransaction = this.writer.persistTransaction.bind(this.writer);
|
|
13
13
|
}
|
|
14
14
|
initialize() {
|
|
15
|
-
return
|
|
15
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
yield this.reader.initialize();
|
|
17
17
|
yield this.writer.initialize();
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
close() {
|
|
21
|
-
return
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
22
|
yield this.writer.close();
|
|
23
23
|
yield this.reader.close();
|
|
24
24
|
});
|
package/dist/data-access.js
CHANGED
|
@@ -51,7 +51,7 @@ class DataAccess {
|
|
|
51
51
|
* Function to initialize the dataId topic with the previous block
|
|
52
52
|
*/
|
|
53
53
|
initialize() {
|
|
54
|
-
return
|
|
54
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
if (this.isInitialized) {
|
|
56
56
|
throw new Error('already initialized');
|
|
57
57
|
}
|
|
@@ -80,7 +80,7 @@ class DataAccess {
|
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
close() {
|
|
83
|
-
return
|
|
83
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
84
84
|
yield this.stopAutoSynchronization();
|
|
85
85
|
});
|
|
86
86
|
}
|
|
@@ -95,7 +95,7 @@ class DataAccess {
|
|
|
95
95
|
* @returns string dataId where the transaction is stored
|
|
96
96
|
*/
|
|
97
97
|
persistTransaction(transaction, channelId, topics = []) {
|
|
98
|
-
return
|
|
98
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
99
99
|
this.checkInitialized();
|
|
100
100
|
// get all the topics not well formatted
|
|
101
101
|
const notFormattedTopics = topics.filter((topic) => !multi_format_1.default.hashFormat.isDeserializableString(topic));
|
|
@@ -116,7 +116,7 @@ class DataAccess {
|
|
|
116
116
|
});
|
|
117
117
|
// Store the data to the real storage
|
|
118
118
|
resultAppend
|
|
119
|
-
.on('confirmed', (resultAppendConfirmed) =>
|
|
119
|
+
.on('confirmed', (resultAppendConfirmed) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
120
120
|
// update the timestamp with the confirmed one
|
|
121
121
|
yield this.transactionIndex.updateTimestamp(resultAppendConfirmed.id, resultAppendConfirmed.meta.timestamp);
|
|
122
122
|
const resultAfterConfirmation = {
|
|
@@ -129,7 +129,7 @@ class DataAccess {
|
|
|
129
129
|
};
|
|
130
130
|
result.emit('confirmed', resultAfterConfirmation);
|
|
131
131
|
}))
|
|
132
|
-
.on('error', (error) =>
|
|
132
|
+
.on('error', (error) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
133
133
|
result.emit('error', error);
|
|
134
134
|
}));
|
|
135
135
|
// adds this transaction to the index, to enable retrieving it later.
|
|
@@ -149,7 +149,7 @@ class DataAccess {
|
|
|
149
149
|
* @returns list of transactions in the channel
|
|
150
150
|
*/
|
|
151
151
|
getTransactionsByChannelId(channelId, timestampBoundaries) {
|
|
152
|
-
return
|
|
152
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
153
153
|
this.checkInitialized();
|
|
154
154
|
// Gets the list of locationStorage indexed by the channel id that are within the boundaries
|
|
155
155
|
const storageLocationList = yield this.transactionIndex.getStorageLocationList(channelId, timestampBoundaries);
|
|
@@ -190,7 +190,7 @@ class DataAccess {
|
|
|
190
190
|
* @returns list of channels indexed by topic
|
|
191
191
|
*/
|
|
192
192
|
getChannelsByTopic(topic, updatedBetween) {
|
|
193
|
-
return
|
|
193
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
194
194
|
this.checkInitialized();
|
|
195
195
|
// check if the topic is well formatted
|
|
196
196
|
if (!multi_format_1.default.hashFormat.isDeserializableString(topic)) {
|
|
@@ -228,7 +228,7 @@ class DataAccess {
|
|
|
228
228
|
* @returns list of channels indexed by topics
|
|
229
229
|
*/
|
|
230
230
|
getChannelsByMultipleTopics(topics, updatedBetween) {
|
|
231
|
-
return
|
|
231
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
232
232
|
this.checkInitialized();
|
|
233
233
|
if (topics.some((topic) => !multi_format_1.default.hashFormat.isDeserializableString(topic))) {
|
|
234
234
|
throw new Error(`The topics are not well formatted`);
|
|
@@ -260,7 +260,7 @@ class DataAccess {
|
|
|
260
260
|
* Function to synchronize with the new dataIds on the storage
|
|
261
261
|
*/
|
|
262
262
|
synchronizeNewDataIds() {
|
|
263
|
-
return
|
|
263
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
264
264
|
this.checkInitialized();
|
|
265
265
|
const synchronizationTo = (0, utils_1.getCurrentTimestampInSecond)();
|
|
266
266
|
// We increment lastSyncStorageTimestamp because the data located at lastSyncStorageTimestamp
|
|
@@ -295,7 +295,7 @@ class DataAccess {
|
|
|
295
295
|
* Stop to synchronize with the storage automatically
|
|
296
296
|
*/
|
|
297
297
|
stopAutoSynchronization() {
|
|
298
|
-
return
|
|
298
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
299
299
|
if (this.synchronizationTimer.isStarted) {
|
|
300
300
|
yield this.synchronizationTimer.stop();
|
|
301
301
|
}
|
|
@@ -307,7 +307,7 @@ class DataAccess {
|
|
|
307
307
|
* @param detailed if true get the list of the files hashes
|
|
308
308
|
*/
|
|
309
309
|
_getStatus(detailed = false) {
|
|
310
|
-
return
|
|
310
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
311
311
|
this.checkInitialized();
|
|
312
312
|
// last transaction timestamp retrieved
|
|
313
313
|
const lastLocationTimestamp = yield this.transactionIndex.getLastTransactionTimestamp();
|
|
@@ -338,13 +338,13 @@ class DataAccess {
|
|
|
338
338
|
* @param locationByTopic LocationByTopic object to push location
|
|
339
339
|
*/
|
|
340
340
|
pushLocationsWithTopics(entries) {
|
|
341
|
-
return
|
|
341
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
342
342
|
if (!entries) {
|
|
343
343
|
throw Error(`data from storage do not follow the standard`);
|
|
344
344
|
}
|
|
345
345
|
let parsingErrorCount = 0;
|
|
346
346
|
let proceedCount = 0;
|
|
347
|
-
yield Bluebird.each(entries, (entry) =>
|
|
347
|
+
yield Bluebird.each(entries, (entry) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
348
348
|
if (!entry.content || !entry.id) {
|
|
349
349
|
throw Error(`data from storage do not follow the standard`);
|
|
350
350
|
}
|
|
@@ -375,9 +375,9 @@ class DataAccess {
|
|
|
375
375
|
* @returns the blocks and their metadata
|
|
376
376
|
*/
|
|
377
377
|
getBlockAndMetaFromStorageLocation(storageLocationList) {
|
|
378
|
-
return
|
|
378
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
379
379
|
// Gets blocks indexed by topic
|
|
380
|
-
return Promise.all(storageLocationList.map((location) =>
|
|
380
|
+
return Promise.all(storageLocationList.map((location) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
381
381
|
const resultRead = yield this.storage.read(location);
|
|
382
382
|
return {
|
|
383
383
|
block: block_1.default.parseBlock(resultRead.content),
|
package/dist/ignored-location.js
CHANGED
|
@@ -27,7 +27,7 @@ class ReasonsByIgnoredLocationIndex {
|
|
|
27
27
|
* @param reason reason to be ignored
|
|
28
28
|
*/
|
|
29
29
|
pushReasonByLocation(dataId, reason) {
|
|
30
|
-
return
|
|
30
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
if (!(yield this.reasonsByIgnoredLocation.get(dataId))) {
|
|
32
32
|
yield this.reasonsByIgnoredLocation.set(dataId, reason);
|
|
33
33
|
yield this.updateDataId(dataId);
|
|
@@ -41,7 +41,7 @@ class ReasonsByIgnoredLocationIndex {
|
|
|
41
41
|
* @param reason reason to be ignored
|
|
42
42
|
*/
|
|
43
43
|
removeReasonByLocation(dataId) {
|
|
44
|
-
return
|
|
44
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
45
45
|
yield this.reasonsByIgnoredLocation.delete(dataId);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -52,7 +52,7 @@ class ReasonsByIgnoredLocationIndex {
|
|
|
52
52
|
* @returns reason of the location, null if not found
|
|
53
53
|
*/
|
|
54
54
|
getReasonFromLocation(dataId) {
|
|
55
|
-
return
|
|
55
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
56
56
|
const reason = yield this.reasonsByIgnoredLocation.get(dataId);
|
|
57
57
|
return reason ? reason : null;
|
|
58
58
|
});
|
|
@@ -63,7 +63,7 @@ class ReasonsByIgnoredLocationIndex {
|
|
|
63
63
|
* @returns the list of data ids stored
|
|
64
64
|
*/
|
|
65
65
|
getIgnoredLocations() {
|
|
66
|
-
return
|
|
66
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
67
67
|
const listDataId = yield this.listIgnoredLocation.get('list');
|
|
68
68
|
if (!listDataId) {
|
|
69
69
|
return {};
|
|
@@ -82,7 +82,7 @@ class ReasonsByIgnoredLocationIndex {
|
|
|
82
82
|
* @returns
|
|
83
83
|
*/
|
|
84
84
|
updateDataId(dataId) {
|
|
85
|
-
return
|
|
85
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
86
86
|
let listDataIds = yield this.listIgnoredLocation.get('list');
|
|
87
87
|
if (!listDataIds) {
|
|
88
88
|
listDataIds = [];
|
package/dist/interval-timer.js
CHANGED
|
@@ -35,7 +35,7 @@ class IntervalTimer {
|
|
|
35
35
|
// Function to be called periodically
|
|
36
36
|
// This function calls and waits for the intervalFunction and sets a timeout
|
|
37
37
|
// to call itself recursively
|
|
38
|
-
const recursiveTimeoutFunction = () =>
|
|
38
|
+
const recursiveTimeoutFunction = () => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
39
39
|
try {
|
|
40
40
|
// We wait for the internal function to reset the timeout
|
|
41
41
|
yield this.intervalFunction();
|
|
@@ -66,7 +66,7 @@ class IntervalTimer {
|
|
|
66
66
|
* Stop the interval timer
|
|
67
67
|
*/
|
|
68
68
|
stop() {
|
|
69
|
-
return
|
|
69
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
70
70
|
if (!this.timeoutObject) {
|
|
71
71
|
return Promise.reject("Can't stop IntervalTimer if it has not been started");
|
|
72
72
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const transaction_index_1 = require("./transaction-index");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
tslib_1.__exportStar(require("./location-by-topic"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./timestamp-by-location"), exports);
|
|
7
7
|
exports.default = transaction_index_1.default;
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transaction-index/index.ts"],"names":[],"mappings":";;;AAAA,2DAAmD;AAEnD,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transaction-index/index.ts"],"names":[],"mappings":";;;AAAA,2DAAmD;AAEnD,8DAAoC;AACpC,kEAAwC;AAExC,kBAAe,2BAAgB,CAAC"}
|
|
@@ -45,7 +45,7 @@ class LocationByTopicTransactionIndex {
|
|
|
45
45
|
* @param blockHeader header of the block
|
|
46
46
|
*/
|
|
47
47
|
pushStorageLocationIndexedWithBlockTopics(storageLocation, blockHeader) {
|
|
48
|
-
return
|
|
48
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
// index the new block with the channel ids
|
|
50
50
|
for (const id of Object.keys(blockHeader.channelIds)) {
|
|
51
51
|
const existingLocationIds = (yield this.storageLocationByChannelId.get(id)) || new Set([]);
|
|
@@ -67,7 +67,7 @@ class LocationByTopicTransactionIndex {
|
|
|
67
67
|
* @returns list of the channel ids connected to the topic
|
|
68
68
|
*/
|
|
69
69
|
getChannelIdsFromTopic(topic) {
|
|
70
|
-
return
|
|
70
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
71
71
|
return Array.from((yield this.channelIdByTopics.get(topic)) || []);
|
|
72
72
|
});
|
|
73
73
|
}
|
|
@@ -78,8 +78,8 @@ class LocationByTopicTransactionIndex {
|
|
|
78
78
|
* @returns list of the channel ids linked to the topics
|
|
79
79
|
*/
|
|
80
80
|
getChannelIdsFromMultipleTopics(topics) {
|
|
81
|
-
return
|
|
82
|
-
const channelIdsPromises = topics.map((topic) =>
|
|
81
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const channelIdsPromises = topics.map((topic) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
83
83
|
return Array.from((yield this.channelIdByTopics.get(topic)) || []);
|
|
84
84
|
}));
|
|
85
85
|
const channelIds = yield Promise.all(channelIdsPromises);
|
|
@@ -94,7 +94,7 @@ class LocationByTopicTransactionIndex {
|
|
|
94
94
|
* @returns list of the location connected to the channel id
|
|
95
95
|
*/
|
|
96
96
|
getStorageLocationsFromChannelId(channelId) {
|
|
97
|
-
return
|
|
97
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
98
98
|
return Array.from((yield this.storageLocationByChannelId.get(channelId)) || []);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
@@ -23,7 +23,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
23
23
|
* @param timestamp timestamp of the block
|
|
24
24
|
*/
|
|
25
25
|
pushTimestampByLocation(dataId, timestamp) {
|
|
26
|
-
return
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
if (!(yield this.timestampByLocation.get(dataId))) {
|
|
28
28
|
yield this.timestampByLocation.set(dataId, timestamp);
|
|
29
29
|
}
|
|
@@ -39,7 +39,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
39
39
|
* @param dataId dataId of the block
|
|
40
40
|
*/
|
|
41
41
|
removeIndexedDataId(dataId) {
|
|
42
|
-
return
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
yield this.timestampByLocation.delete(dataId);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -50,7 +50,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
50
50
|
* @param timestamp timestamp of the block
|
|
51
51
|
*/
|
|
52
52
|
updateTimestampByLocation(dataId, timestamp) {
|
|
53
|
-
return
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
yield this.timestampByLocation.set(dataId, timestamp);
|
|
55
55
|
const lastTransactionTimestamp = yield this.getLastTransactionTimestamp();
|
|
56
56
|
if (!lastTransactionTimestamp || timestamp > lastTransactionTimestamp) {
|
|
@@ -65,7 +65,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
65
65
|
* @returns timestamp of the location, null if not found
|
|
66
66
|
*/
|
|
67
67
|
getTimestampFromLocation(dataId) {
|
|
68
|
-
return
|
|
68
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
69
69
|
const timestamp = yield this.timestampByLocation.get(dataId);
|
|
70
70
|
return timestamp !== undefined ? timestamp : null;
|
|
71
71
|
});
|
|
@@ -77,7 +77,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
77
77
|
* @returns timestamp of the location, null if not found
|
|
78
78
|
*/
|
|
79
79
|
isDataInBoundaries(dataId, boundaries) {
|
|
80
|
-
return
|
|
80
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
81
81
|
const timestamp = yield this.timestampByLocation.get(dataId);
|
|
82
82
|
if (!timestamp) {
|
|
83
83
|
throw Error(`Unknown timestamp for the dataId ${dataId}`);
|
|
@@ -91,7 +91,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
91
91
|
* the timestamp of the latest transaction
|
|
92
92
|
*/
|
|
93
93
|
getLastTransactionTimestamp() {
|
|
94
|
-
return
|
|
94
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
95
95
|
return (yield this.timestampByLocation.get('last_transaction_timestamp')) || null;
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -99,7 +99,7 @@ class TimestampByLocationTransactionIndex {
|
|
|
99
99
|
* the timestamp of the latest transaction
|
|
100
100
|
*/
|
|
101
101
|
setLastTransactionTimestamp(value) {
|
|
102
|
-
return
|
|
102
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
103
103
|
yield this.timestampByLocation.set('last_transaction_timestamp', value);
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -23,7 +23,7 @@ class TransactionIndex {
|
|
|
23
23
|
}
|
|
24
24
|
// eslint-disable-next-line no-empty, @typescript-eslint/no-empty-function
|
|
25
25
|
initialize() {
|
|
26
|
-
return
|
|
26
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () { });
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Get the last indexed timestamp
|
|
@@ -39,7 +39,7 @@ class TransactionIndex {
|
|
|
39
39
|
* @param timestamp the timestamp of the transaction
|
|
40
40
|
*/
|
|
41
41
|
addTransaction(dataId, header, timestamp) {
|
|
42
|
-
return
|
|
42
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
if (!this.locationByTopic) {
|
|
44
44
|
throw new Error('TransactionIndex must be initialized');
|
|
45
45
|
}
|
|
@@ -56,7 +56,7 @@ class TransactionIndex {
|
|
|
56
56
|
* @param dataId the dataId to remove
|
|
57
57
|
*/
|
|
58
58
|
removeTransaction(dataId) {
|
|
59
|
-
return
|
|
59
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
60
60
|
if (!this.locationByTopic) {
|
|
61
61
|
throw new Error('TransactionIndex must be initialized');
|
|
62
62
|
}
|
|
@@ -71,7 +71,7 @@ class TransactionIndex {
|
|
|
71
71
|
* @param timestamp the timestamp of the transaction
|
|
72
72
|
*/
|
|
73
73
|
updateTimestamp(dataId, timestamp) {
|
|
74
|
-
return
|
|
74
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
if (!this.timestampByLocation) {
|
|
76
76
|
throw new Error('TransactionIndex must be initialized');
|
|
77
77
|
}
|
|
@@ -86,13 +86,13 @@ class TransactionIndex {
|
|
|
86
86
|
* @returns list of location of a channel
|
|
87
87
|
*/
|
|
88
88
|
getStorageLocationList(channelId, timestampBoundaries) {
|
|
89
|
-
return
|
|
89
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
if (!this.locationByTopic) {
|
|
91
91
|
throw new Error('TransactionIndex must be initialized');
|
|
92
92
|
}
|
|
93
93
|
// get transaction locations for the given channel
|
|
94
94
|
let storageLocationList = yield this.locationByTopic.getStorageLocationsFromChannelId(channelId);
|
|
95
|
-
storageLocationList = yield Bluebird.filter(storageLocationList, (dataId) =>
|
|
95
|
+
storageLocationList = yield Bluebird.filter(storageLocationList, (dataId) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
96
96
|
// if the dataId has not been suppressed
|
|
97
97
|
const exist = (yield this.timestampByLocation.getTimestampFromLocation(dataId)) !== null;
|
|
98
98
|
// if boundaries are passed, only return locations of transaction within these boundaries
|
|
@@ -110,7 +110,7 @@ class TransactionIndex {
|
|
|
110
110
|
* @returns list of location of the channels indexed by the topic
|
|
111
111
|
*/
|
|
112
112
|
getChannelIdsForTopic(topic, timestampBoundaries) {
|
|
113
|
-
return
|
|
113
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
114
114
|
if (!this.locationByTopic) {
|
|
115
115
|
throw new Error('TransactionIndex must be initialized');
|
|
116
116
|
}
|
|
@@ -144,7 +144,7 @@ class TransactionIndex {
|
|
|
144
144
|
* @returns list of location of the channels indexed by the topics
|
|
145
145
|
*/
|
|
146
146
|
getChannelIdsForMultipleTopics(topics, timestampBoundaries) {
|
|
147
|
-
return
|
|
147
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
148
148
|
if (!this.locationByTopic) {
|
|
149
149
|
throw new Error('TransactionIndex must be initialized');
|
|
150
150
|
}
|
|
@@ -175,7 +175,7 @@ class TransactionIndex {
|
|
|
175
175
|
* the list of indexed locations
|
|
176
176
|
*/
|
|
177
177
|
getIndexedLocations() {
|
|
178
|
-
return
|
|
178
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
179
179
|
const listDataIds = yield this.indexedLocation.get('list');
|
|
180
180
|
return listDataIds || [];
|
|
181
181
|
});
|
|
@@ -187,7 +187,7 @@ class TransactionIndex {
|
|
|
187
187
|
* @returns
|
|
188
188
|
*/
|
|
189
189
|
updateIndexedLocation(dataId) {
|
|
190
|
-
return
|
|
190
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
191
191
|
let listDataIds = yield this.indexedLocation.get('list');
|
|
192
192
|
if (!listDataIds) {
|
|
193
193
|
listDataIds = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-index.js","sourceRoot":"","sources":["../../src/transaction-index/transaction-index.ts"],"names":[],"mappings":";;;AAEA,qCAAqC;AACrC,6BAA6B;AAE7B,2DAAkD;AAClD,mEAA0D;AAE1D;;GAEG;AAEH,MAAqB,gBAAgB;IAWnC;;;OAGG;IACH,YAAY,KAA4B;QACtC,IAAI,CAAC,mBAAmB,GAAG,IAAI,+BAAmB,CAAC,KAAK,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,IAAI,2BAAe,CAAC,KAAK,CAAC,CAAC;QAElD,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,CAAW;YACxC,SAAS,EAAE,iBAAiB;YAC5B,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,0EAA0E;IAC7D,UAAU;
|
|
1
|
+
{"version":3,"file":"transaction-index.js","sourceRoot":"","sources":["../../src/transaction-index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V,mBAAmB,CACpB,CAAC;wBACF,IAAI,cAAc,EAAE;4BAClB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;4BACvB,MAAM;yBACP;qBACF;iBACF;gBACD,OAAO,MAAM,CAAC;aACf;iBAAM;gBACL,OAAO,UAAU,CAAC;aACnB;QACH,CAAC;KAAA;IAED;;OAEG;IACU,mBAAmB;;YAC9B,MAAM,WAAW,GAAyB,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACjF,OAAO,WAAW,IAAI,EAAE,CAAC;QAC3B,CAAC;KAAA;IAED;;;;;OAKG;IACW,qBAAqB,CAAC,MAAc;;YAChD,IAAI,WAAW,GAAyB,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC/E,IAAI,CAAC,WAAW,EAAE;gBAChB,WAAW,GAAG,EAAE,CAAC;aAClB;YAED,8BAA8B;YAC9B,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBACjC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACzB,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;aACrD;QACH,CAAC;KAAA;CACF;AAlOD,mCAkOC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@requestnetwork/data-access",
|
|
3
|
-
"version": "0.27.1-next.
|
|
3
|
+
"version": "0.27.1-next.1864+cfea8a31",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -39,25 +39,25 @@
|
|
|
39
39
|
"test:watch": "yarn test --watch"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@requestnetwork/multi-format": "0.15.11-next.
|
|
43
|
-
"@requestnetwork/types": "0.36.1-next.
|
|
44
|
-
"@requestnetwork/utils": "0.36.1-next.
|
|
42
|
+
"@requestnetwork/multi-format": "0.15.11-next.1864+cfea8a31",
|
|
43
|
+
"@requestnetwork/types": "0.36.1-next.1864+cfea8a31",
|
|
44
|
+
"@requestnetwork/utils": "0.36.1-next.1864+cfea8a31",
|
|
45
45
|
"bluebird": "3.7.2",
|
|
46
46
|
"keyv": "4.0.3",
|
|
47
|
-
"tslib": "2.
|
|
47
|
+
"tslib": "2.5.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/bluebird": "3.5.33",
|
|
51
51
|
"@types/jest": "26.0.13",
|
|
52
52
|
"@types/keyv": "3.1.1",
|
|
53
|
-
"@types/node": "
|
|
53
|
+
"@types/node": "16.11.7",
|
|
54
54
|
"jest": "26.4.2",
|
|
55
55
|
"nyc": "15.1.0",
|
|
56
56
|
"shx": "0.3.2",
|
|
57
57
|
"source-map-support": "0.5.19",
|
|
58
58
|
"ts-jest": "26.3.0",
|
|
59
|
-
"ts-node": "9.
|
|
60
|
-
"typescript": "4.
|
|
59
|
+
"ts-node": "10.9.1",
|
|
60
|
+
"typescript": "4.9.5"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "cfea8a31e39ba4315b8ffc9971cbb3155be2dde1"
|
|
63
63
|
}
|