@requestnetwork/data-access 0.23.1-next.1351 → 0.23.1-next.710

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.
Files changed (67) hide show
  1. package/README.md +0 -4
  2. package/dist/block.d.ts +4 -4
  3. package/dist/block.d.ts.map +1 -1
  4. package/dist/block.js +9 -9
  5. package/dist/block.js.map +1 -1
  6. package/dist/combined-data-access.d.ts +13 -0
  7. package/dist/combined-data-access.d.ts.map +1 -0
  8. package/dist/combined-data-access.js +44 -0
  9. package/dist/combined-data-access.js.map +1 -0
  10. package/dist/data-read.d.ts +17 -0
  11. package/dist/data-read.d.ts.map +1 -0
  12. package/dist/data-read.js +158 -0
  13. package/dist/data-read.js.map +1 -0
  14. package/dist/data-write.d.ts +10 -0
  15. package/dist/data-write.d.ts.map +1 -0
  16. package/dist/data-write.js +48 -0
  17. package/dist/data-write.js.map +1 -0
  18. package/dist/in-memory-indexer.d.ts +18 -0
  19. package/dist/in-memory-indexer.d.ts.map +1 -0
  20. package/dist/in-memory-indexer.js +110 -0
  21. package/dist/in-memory-indexer.js.map +1 -0
  22. package/dist/index.d.ts +6 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +11 -5
  25. package/dist/index.js.map +1 -1
  26. package/dist/mock-data-access.d.ts +13 -0
  27. package/dist/mock-data-access.d.ts.map +1 -0
  28. package/dist/mock-data-access.js +29 -0
  29. package/dist/mock-data-access.js.map +1 -0
  30. package/dist/pending-store.d.ts +16 -0
  31. package/dist/pending-store.d.ts.map +1 -0
  32. package/dist/pending-store.js +33 -0
  33. package/dist/pending-store.js.map +1 -0
  34. package/dist/types.d.ts +7 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/dist/types.js +3 -0
  37. package/dist/types.js.map +1 -0
  38. package/package.json +18 -29
  39. package/CHANGELOG.md +0 -1466
  40. package/dist/data-access.d.ts +0 -140
  41. package/dist/data-access.d.ts.map +0 -1
  42. package/dist/data-access.js +0 -425
  43. package/dist/data-access.js.map +0 -1
  44. package/dist/ignored-location.d.ts +0 -58
  45. package/dist/ignored-location.d.ts.map +0 -1
  46. package/dist/ignored-location.js +0 -104
  47. package/dist/ignored-location.js.map +0 -1
  48. package/dist/interval-timer.d.ts +0 -36
  49. package/dist/interval-timer.d.ts.map +0 -1
  50. package/dist/interval-timer.js +0 -90
  51. package/dist/interval-timer.js.map +0 -1
  52. package/dist/transaction-index/index.d.ts +0 -5
  53. package/dist/transaction-index/index.d.ts.map +0 -1
  54. package/dist/transaction-index/index.js +0 -17
  55. package/dist/transaction-index/index.js.map +0 -1
  56. package/dist/transaction-index/location-by-topic.d.ts +0 -53
  57. package/dist/transaction-index/location-by-topic.d.ts.map +0 -1
  58. package/dist/transaction-index/location-by-topic.js +0 -111
  59. package/dist/transaction-index/location-by-topic.js.map +0 -1
  60. package/dist/transaction-index/timestamp-by-location.d.ts +0 -60
  61. package/dist/transaction-index/timestamp-by-location.d.ts.map +0 -1
  62. package/dist/transaction-index/timestamp-by-location.js +0 -116
  63. package/dist/transaction-index/timestamp-by-location.js.map +0 -1
  64. package/dist/transaction-index/transaction-index.d.ts +0 -74
  65. package/dist/transaction-index/transaction-index.d.ts.map +0 -1
  66. package/dist/transaction-index/transaction-index.js +0 -212
  67. package/dist/transaction-index/transaction-index.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,10 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Block = exports.TransactionIndex = exports.DataAccess = void 0;
4
- var data_access_1 = require("./data-access");
5
- Object.defineProperty(exports, "DataAccess", { enumerable: true, get: function () { return data_access_1.default; } });
6
- var transaction_index_1 = require("./transaction-index");
7
- Object.defineProperty(exports, "TransactionIndex", { enumerable: true, get: function () { return transaction_index_1.default; } });
3
+ exports.MockDataAccess = exports.PendingStore = exports.DataAccessRead = exports.DataAccessWrite = exports.CombinedDataAccess = exports.Block = void 0;
8
4
  var block_1 = require("./block");
9
5
  Object.defineProperty(exports, "Block", { enumerable: true, get: function () { return block_1.default; } });
6
+ var combined_data_access_1 = require("./combined-data-access");
7
+ Object.defineProperty(exports, "CombinedDataAccess", { enumerable: true, get: function () { return combined_data_access_1.CombinedDataAccess; } });
8
+ var data_write_1 = require("./data-write");
9
+ Object.defineProperty(exports, "DataAccessWrite", { enumerable: true, get: function () { return data_write_1.DataAccessWrite; } });
10
+ var data_read_1 = require("./data-read");
11
+ Object.defineProperty(exports, "DataAccessRead", { enumerable: true, get: function () { return data_read_1.DataAccessRead; } });
12
+ var pending_store_1 = require("./pending-store");
13
+ Object.defineProperty(exports, "PendingStore", { enumerable: true, get: function () { return pending_store_1.PendingStore; } });
14
+ var mock_data_access_1 = require("./mock-data-access");
15
+ Object.defineProperty(exports, "MockDataAccess", { enumerable: true, get: function () { return mock_data_access_1.MockDataAccess; } });
10
16
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAsD;AAA7C,yGAAA,OAAO,OAAc;AAC9B,yDAAkE;AAAzD,qHAAA,OAAO,OAAoB;AACpC,iCAA2C;AAAlC,8FAAA,OAAO,OAAS"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iCAA2C;AAAlC,8FAAA,OAAO,OAAS;AACzB,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA;AAC3B,2CAA+C;AAAtC,6GAAA,eAAe,OAAA;AACxB,yCAA6C;AAApC,2GAAA,cAAc,OAAA;AACvB,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAErB,uDAAoD;AAA3C,kHAAA,cAAc,OAAA"}
@@ -0,0 +1,13 @@
1
+ import { DataAccessTypes, StorageTypes } from '@requestnetwork/types';
2
+ import { CombinedDataAccess } from './combined-data-access';
3
+ /**
4
+ * Mock Data access that bypasses the initialization.
5
+ * This class is meant to be used with HttpRequestNetwork and useMockStorage=true.
6
+ * Data-access initialization is asynchronous and this class is a hack to avoid having an asynchronous operation in the HttpRequestNetwork constructor.
7
+ */
8
+ export declare class MockDataAccess extends CombinedDataAccess {
9
+ private readonly dataIndex;
10
+ constructor(storage: StorageTypes.IStorage);
11
+ persistTransaction: (transactionData: DataAccessTypes.ITransaction, channelId: string, topics?: string[] | undefined) => Promise<DataAccessTypes.IReturnPersistTransaction>;
12
+ }
13
+ //# sourceMappingURL=mock-data-access.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-data-access.d.ts","sourceRoot":"","sources":["../src/mock-data-access.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAKtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;GAIG;AACH,qBAAa,cAAe,SAAQ,kBAAkB;IACpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAkB;gBAEhC,OAAO,EAAE,YAAY,CAAC,QAAQ;IAW1C,kBAAkB,oBACC,gBAAgB,YAAY,aAClC,MAAM,WACR,MAAM,EAAE,GAAG,SAAS,KAC5B,QAAQ,gBAAgB,yBAAyB,CAAC,CAInD;CACH"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MockDataAccess = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const data_write_1 = require("./data-write");
6
+ const data_read_1 = require("./data-read");
7
+ const pending_store_1 = require("./pending-store");
8
+ const in_memory_indexer_1 = require("./in-memory-indexer");
9
+ const combined_data_access_1 = require("./combined-data-access");
10
+ /**
11
+ * Mock Data access that bypasses the initialization.
12
+ * This class is meant to be used with HttpRequestNetwork and useMockStorage=true.
13
+ * Data-access initialization is asynchronous and this class is a hack to avoid having an asynchronous operation in the HttpRequestNetwork constructor.
14
+ */
15
+ class MockDataAccess extends combined_data_access_1.CombinedDataAccess {
16
+ constructor(storage) {
17
+ const dataIndex = new in_memory_indexer_1.InMemoryIndexer(storage);
18
+ const pendingStore = new pending_store_1.PendingStore();
19
+ super(new data_read_1.DataAccessRead(dataIndex, { network: 'mock', pendingStore }), new data_write_1.DataAccessWrite(storage, pendingStore));
20
+ this.persistTransaction = (transactionData, channelId, topics) => tslib_1.__awaiter(this, void 0, void 0, function* () {
21
+ const result = yield this.writer.persistTransaction(transactionData, channelId, topics);
22
+ this.dataIndex.addIndex(channelId, topics || [], result.meta.transactionStorageLocation);
23
+ return result;
24
+ });
25
+ this.dataIndex = dataIndex;
26
+ }
27
+ }
28
+ exports.MockDataAccess = MockDataAccess;
29
+ //# sourceMappingURL=mock-data-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock-data-access.js","sourceRoot":"","sources":["../src/mock-data-access.ts"],"names":[],"mappings":";;;;AACA,6CAA+C;AAC/C,2CAA6C;AAC7C,mDAA+C;AAC/C,2DAAsD;AACtD,iEAA4D;AAE5D;;;;GAIG;AACH,MAAa,cAAe,SAAQ,yCAAkB;IAGpD,YAAY,OAA8B;QACxC,MAAM,SAAS,GAAG,IAAI,mCAAe,CAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,YAAY,GAAG,IAAI,4BAAY,EAAE,CAAC;QAExC,KAAK,CACH,IAAI,0BAAc,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,EAChE,IAAI,4BAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAC3C,CAAC;QAIJ,uBAAkB,GAAG,CACnB,eAA6C,EAC7C,SAAiB,EACjB,MAA6B,EACuB,EAAE;YACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;YACxF,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACzF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAA,CAAC;QAXA,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAWF;AAvBD,wCAuBC"}
@@ -0,0 +1,16 @@
1
+ import { DataAccessTypes } from '@requestnetwork/types';
2
+ /**
3
+ * A simple in-memory store to share state between DataReader and DataWriter
4
+ * Useful to retrieve a transaction that was just emitted but is not confirmed yet
5
+ **/
6
+ export declare class PendingStore implements DataAccessTypes.IPendingStore {
7
+ private pending;
8
+ /** Gets a pending tx */
9
+ get(channelId: string): DataAccessTypes.PendingItem | undefined;
10
+ findByTopics(topics: string[]): (DataAccessTypes.PendingItem & {
11
+ channelId: string;
12
+ })[];
13
+ add(channelId: string, pendingItem: DataAccessTypes.PendingItem): void;
14
+ remove(channelId: string): void;
15
+ }
16
+ //# sourceMappingURL=pending-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-store.d.ts","sourceRoot":"","sources":["../src/pending-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;IAGI;AACJ,qBAAa,YAAa,YAAW,eAAe,CAAC,aAAa;IAChE,OAAO,CAAC,OAAO,CAAkD;IAEjE,wBAAwB;IACjB,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC,WAAW,GAAG,SAAS;IAI/D,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,eAAe,CAAC,WAAW,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,EAAE;IAUvF,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,CAAC,WAAW,GAAG,IAAI;IAItE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;CAGvC"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PendingStore = void 0;
4
+ /**
5
+ * A simple in-memory store to share state between DataReader and DataWriter
6
+ * Useful to retrieve a transaction that was just emitted but is not confirmed yet
7
+ **/
8
+ class PendingStore {
9
+ constructor() {
10
+ this.pending = new Map();
11
+ }
12
+ /** Gets a pending tx */
13
+ get(channelId) {
14
+ return this.pending.get(channelId);
15
+ }
16
+ findByTopics(topics) {
17
+ const results = [];
18
+ for (const [channelId, pendingItem] of this.pending.entries()) {
19
+ if (topics.find((topic) => pendingItem.topics.includes(topic))) {
20
+ results.push(Object.assign({ channelId }, pendingItem));
21
+ }
22
+ }
23
+ return results;
24
+ }
25
+ add(channelId, pendingItem) {
26
+ this.pending.set(channelId, pendingItem);
27
+ }
28
+ remove(channelId) {
29
+ this.pending.delete(channelId);
30
+ }
31
+ }
32
+ exports.PendingStore = PendingStore;
33
+ //# sourceMappingURL=pending-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending-store.js","sourceRoot":"","sources":["../src/pending-store.ts"],"names":[],"mappings":";;;AAEA;;;IAGI;AACJ,MAAa,YAAY;IAAzB;QACU,YAAO,GAAG,IAAI,GAAG,EAAuC,CAAC;IAwBnE,CAAC;IAtBC,wBAAwB;IACjB,GAAG,CAAC,SAAiB;QAC1B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IACrC,CAAC;IAEM,YAAY,CAAC,MAAgB;QAClC,MAAM,OAAO,GAA4D,EAAE,CAAC;QAC5E,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE;YAC7D,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC9D,OAAO,CAAC,IAAI,iBAAG,SAAS,IAAK,WAAW,EAAG,CAAC;aAC7C;SACF;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,GAAG,CAAC,SAAiB,EAAE,WAAwC;QACpE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAC3C,CAAC;IAEM,MAAM,CAAC,SAAiB;QAC7B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjC,CAAC;CACF;AAzBD,oCAyBC"}
@@ -0,0 +1,7 @@
1
+ import { DataAccessTypes, LogTypes } from '@requestnetwork/types';
2
+ export type DataAccessBaseOptions = {
3
+ network: string;
4
+ logger?: LogTypes.ILogger;
5
+ pendingStore?: DataAccessTypes.IPendingStore;
6
+ };
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC;IAC1B,YAAY,CAAC,EAAE,eAAe,CAAC,aAAa,CAAC;CAC9C,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestnetwork/data-access",
3
- "version": "0.23.1-next.1351+563f6287",
3
+ "version": "0.23.1-next.710+35e1281e",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "license": "MIT",
21
21
  "engines": {
22
- "node": ">=8.0.0"
22
+ "node": ">=18.0.0"
23
23
  },
24
24
  "main": "dist/index.js",
25
25
  "types": "dist/index.d.ts",
@@ -31,39 +31,28 @@
31
31
  "dist"
32
32
  ],
33
33
  "scripts": {
34
- "build": "tsc -b",
35
- "clean": "shx rm -rf dist tsconfig.tsbuildinfo",
36
- "lint": "tslint --project . && eslint \"src/**/*.ts\"",
37
- "lint-staged": "lint-staged",
34
+ "build": "tsc -b tsconfig.build.json",
35
+ "clean": "rm -rf dist tsconfig.tsbuildinfo tsconfig.build.tsbuildinfo",
36
+ "lint": "eslint . --fix",
37
+ "lint:check": "eslint .",
38
38
  "test": "jest",
39
39
  "test:watch": "yarn test --watch"
40
40
  },
41
41
  "dependencies": {
42
- "@requestnetwork/multi-format": "0.15.1-next.1351+563f6287",
43
- "@requestnetwork/types": "0.29.1-next.1351+563f6287",
44
- "@requestnetwork/utils": "0.28.1-next.1351+563f6287",
45
- "bluebird": "3.7.2",
46
- "keyv": "4.0.3"
42
+ "@requestnetwork/multi-format": "0.15.1-next.710+35e1281e",
43
+ "@requestnetwork/types": "0.29.1-next.710+35e1281e",
44
+ "@requestnetwork/utils": "0.28.1-next.710+35e1281e",
45
+ "tslib": "2.5.0"
47
46
  },
48
47
  "devDependencies": {
49
- "@types/bluebird": "3.5.32",
50
- "@types/jest": "26.0.13",
51
- "@types/keyv": "3.1.1",
52
- "@types/node": "14.6.4",
53
- "@typescript-eslint/parser": "4.1.1",
54
- "eslint": "7.9.0",
55
- "eslint-plugin-spellcheck": "0.0.17",
56
- "eslint-plugin-typescript": "0.14.0",
57
- "jest": "26.4.2",
58
- "lint-staged": "10.3.0",
59
- "nyc": "15.1.0",
60
- "prettier": "2.1.1",
61
- "shx": "0.3.2",
48
+ "@types/jest": "29.5.6",
49
+ "@types/node": "18.11.9",
50
+ "jest": "29.5.0",
51
+ "jest-junit": "16.0.0",
62
52
  "source-map-support": "0.5.19",
63
- "ts-jest": "26.3.0",
64
- "ts-node": "9.0.0",
65
- "tslint": "6.1.3",
66
- "typescript": "4.0.2"
53
+ "ts-jest": "29.1.0",
54
+ "ts-node": "10.9.1",
55
+ "typescript": "5.1.3"
67
56
  },
68
- "gitHead": "563f62876aef60db83bd277d12e35450b61513f9"
57
+ "gitHead": "35e1281ee292d73494b1e115cc7fbcc36ecbb7b2"
69
58
  }