@xyo-network/archivist 2.22.9 → 2.22.10
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/cjs/XyoArchivist.d.ts +0 -13
- package/dist/cjs/XyoArchivist.js +0 -20
- package/dist/cjs/XyoArchivist.js.map +1 -1
- package/dist/cjs/XyoArchivistConfig.d.ts +17 -0
- package/dist/cjs/XyoArchivistConfig.js +26 -0
- package/dist/cjs/XyoArchivistConfig.js.map +1 -0
- package/dist/cjs/XyoMemoryArchivist.d.ts +4 -2
- package/dist/cjs/XyoMemoryArchivist.js +5 -2
- package/dist/cjs/XyoMemoryArchivist.js.map +1 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/Archivist.d.ts +1 -0
- package/dist/esm/XyoArchivist.d.ts +0 -13
- package/dist/esm/XyoArchivist.js +1 -18
- package/dist/esm/XyoArchivist.js.map +1 -1
- package/dist/esm/XyoArchivistBase.d.ts +13 -0
- package/dist/esm/XyoArchivistBase.js +16 -0
- package/dist/esm/XyoArchivistBase.js.map +1 -0
- package/dist/esm/XyoArchivistConfig.d.ts +17 -0
- package/dist/esm/XyoArchivistConfig.js +18 -0
- package/dist/esm/XyoArchivistConfig.js.map +1 -0
- package/dist/esm/XyoMemoryArchivist.d.ts +4 -2
- package/dist/esm/XyoMemoryArchivist.js +5 -2
- package/dist/esm/XyoMemoryArchivist.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/Archivist.d.ts +1 -0
- package/package.json +5 -5
- package/src/XyoArchivist.ts +0 -26
- package/src/XyoArchivistConfig.ts +34 -0
- package/src/XyoMemoryArchivist.ts +7 -2
- package/src/index.ts +1 -0
- package/src/model/Archivist.ts +1 -0
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import { XyoAccount } from '@xyo-network/account';
|
|
2
1
|
import { XyoPayload } from '@xyo-network/payload';
|
|
3
2
|
import { Archivist } from './model';
|
|
4
3
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter';
|
|
5
4
|
export declare type XyoArchivist<T extends XyoPayload = XyoPayload> = Archivist<T, T, T, T, XyoPayloadFindQuery>;
|
|
6
|
-
export declare abstract class XyoArchivistBase<T extends XyoPayload = XyoPayload> implements XyoArchivist<T> {
|
|
7
|
-
protected parent?: XyoArchivist<T>;
|
|
8
|
-
protected account?: XyoAccount;
|
|
9
|
-
constructor(parent?: XyoArchivist<T>, account?: XyoAccount);
|
|
10
|
-
abstract insert(payloads: T[]): T[] | Promise<T[]>;
|
|
11
|
-
abstract find<R extends T = T>(query: XyoPayloadFindQuery): R[] | Promise<R[]>;
|
|
12
|
-
abstract get(hash: string[]): (T | null)[] | Promise<(T | null)[]>;
|
|
13
|
-
all(): T[] | Promise<T[]>;
|
|
14
|
-
delete(_hashes: string[]): boolean[] | Promise<boolean[]>;
|
|
15
|
-
clear(): void | Promise<void>;
|
|
16
|
-
commit(): void;
|
|
17
|
-
}
|
package/dist/cjs/XyoArchivist.js
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.XyoArchivistBase = void 0;
|
|
4
|
-
class XyoArchivistBase {
|
|
5
|
-
constructor(parent, account) {
|
|
6
|
-
this.parent = parent;
|
|
7
|
-
this.account = account;
|
|
8
|
-
}
|
|
9
|
-
all() {
|
|
10
|
-
throw Error('getAll not supported');
|
|
11
|
-
}
|
|
12
|
-
delete(_hashes) {
|
|
13
|
-
throw Error('delete not supported');
|
|
14
|
-
}
|
|
15
|
-
clear() {
|
|
16
|
-
throw Error('clear not supported');
|
|
17
|
-
}
|
|
18
|
-
commit() {
|
|
19
|
-
throw Error('commit not supported');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.XyoArchivistBase = XyoArchivistBase;
|
|
23
3
|
//# sourceMappingURL=XyoArchivist.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoArchivist.js","sourceRoot":"","sources":["../../src/XyoArchivist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XyoArchivist.js","sourceRoot":"","sources":["../../src/XyoArchivist.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account';
|
|
2
|
+
import { XyoPayload } from '@xyo-network/payload';
|
|
3
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
4
|
+
export interface XyoArchivistConfig<T extends XyoPayload = XyoPayload> {
|
|
5
|
+
parent?: XyoArchivist<T>;
|
|
6
|
+
account?: XyoAccount;
|
|
7
|
+
cacheParentReads?: boolean;
|
|
8
|
+
writeThrough?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class XyoArchivistConfigWrapper<T extends XyoPayload = XyoPayload, C extends XyoArchivistConfig<T> = XyoArchivistConfig<T>> {
|
|
11
|
+
protected config?: C;
|
|
12
|
+
constructor(config?: C);
|
|
13
|
+
get parent(): XyoArchivist<T> | undefined;
|
|
14
|
+
get account(): XyoAccount | undefined;
|
|
15
|
+
get writeThrough(): boolean | undefined;
|
|
16
|
+
get cacheParentReads(): boolean | undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XyoArchivistConfigWrapper = void 0;
|
|
4
|
+
class XyoArchivistConfigWrapper {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
get parent() {
|
|
9
|
+
var _a;
|
|
10
|
+
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.parent;
|
|
11
|
+
}
|
|
12
|
+
get account() {
|
|
13
|
+
var _a;
|
|
14
|
+
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.account;
|
|
15
|
+
}
|
|
16
|
+
get writeThrough() {
|
|
17
|
+
var _a;
|
|
18
|
+
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.writeThrough;
|
|
19
|
+
}
|
|
20
|
+
get cacheParentReads() {
|
|
21
|
+
var _a;
|
|
22
|
+
return (_a = this.config) === null || _a === void 0 ? void 0 : _a.cacheParentReads;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.XyoArchivistConfigWrapper = XyoArchivistConfigWrapper;
|
|
26
|
+
//# sourceMappingURL=XyoArchivistConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoArchivistConfig.js","sourceRoot":"","sources":["../../src/XyoArchivistConfig.ts"],"names":[],"mappings":";;;AAYA,MAAa,yBAAyB;IAEpC,YAAY,MAAU;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,IAAW,MAAM;;QACf,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,MAAM,CAAA;IAC5B,CAAC;IAED,IAAW,OAAO;;QAChB,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,OAAO,CAAA;IAC7B,CAAC;IAED,IAAW,YAAY;;QACrB,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,YAAY,CAAA;IAClC,CAAC;IAED,IAAW,gBAAgB;;QACzB,OAAO,MAAA,IAAI,CAAC,MAAM,0CAAE,gBAAgB,CAAA;IACtC,CAAC;CACF;AArBD,8DAqBC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { XyoPayload } from '@xyo-network/payload';
|
|
2
|
-
import {
|
|
2
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
3
|
+
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
3
4
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter';
|
|
4
|
-
export declare class XyoMemoryArchivist extends
|
|
5
|
+
export declare class XyoMemoryArchivist extends XyoArchivistConfigWrapper<XyoPayload> implements XyoArchivist {
|
|
5
6
|
private cache;
|
|
6
7
|
delete(hashes: string[]): boolean[] | Promise<boolean[]>;
|
|
7
8
|
clear(): void | Promise<void>;
|
|
8
9
|
get(hashes: string[]): Promise<(XyoPayload | null)[]>;
|
|
9
10
|
insert(payloads: XyoPayload[]): XyoPayload[] | Promise<XyoPayload[]>;
|
|
10
11
|
find<R extends XyoPayload = XyoPayload>(query: XyoPayloadFindQuery): R[] | Promise<R[]>;
|
|
12
|
+
all(): Promise<XyoPayload[]> | XyoPayload[];
|
|
11
13
|
commit(): Promise<import("@xyo-network/payload").XyoPayloadBase[] | undefined>;
|
|
12
14
|
}
|
|
@@ -6,8 +6,8 @@ const sdk_js_1 = require("@xylabs/sdk-js");
|
|
|
6
6
|
const boundwitness_1 = require("@xyo-network/boundwitness");
|
|
7
7
|
const payload_1 = require("@xyo-network/payload");
|
|
8
8
|
const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
|
|
9
|
-
const
|
|
10
|
-
class XyoMemoryArchivist extends
|
|
9
|
+
const XyoArchivistConfig_1 = require("./XyoArchivistConfig");
|
|
10
|
+
class XyoMemoryArchivist extends XyoArchivistConfig_1.XyoArchivistConfigWrapper {
|
|
11
11
|
constructor() {
|
|
12
12
|
super(...arguments);
|
|
13
13
|
this.cache = new lru_cache_1.default({ max: 10000 });
|
|
@@ -45,6 +45,9 @@ class XyoMemoryArchivist extends XyoArchivist_1.XyoArchivistBase {
|
|
|
45
45
|
});
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
|
+
all() {
|
|
49
|
+
return this.cache.dump().map((value) => value[1].value);
|
|
50
|
+
}
|
|
48
51
|
commit() {
|
|
49
52
|
var _a;
|
|
50
53
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../src/XyoMemoryArchivist.ts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MAAM,uDAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAA;YAC9D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAClB,OAAO,MAAM,CAAA;;KACd;CACF;AAtDD,gDAsDC"}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./model"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./XyoArchivist"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./XyoArchivistConfig"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./XyoMemoryArchivist"), exports);
|
|
7
8
|
tslib_1.__exportStar(require("./XyoPayloadFindFilter"), exports);
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,yDAA8B;AAC9B,+DAAoC;AACpC,iEAAsC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,yDAA8B;AAC9B,+DAAoC;AACpC,+DAAoC;AACpC,iEAAsC"}
|
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
import { XyoAccount } from '@xyo-network/account';
|
|
2
1
|
import { XyoPayload } from '@xyo-network/payload';
|
|
3
2
|
import { Archivist } from './model';
|
|
4
3
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter';
|
|
5
4
|
export declare type XyoArchivist<T extends XyoPayload = XyoPayload> = Archivist<T, T, T, T, XyoPayloadFindQuery>;
|
|
6
|
-
export declare abstract class XyoArchivistBase<T extends XyoPayload = XyoPayload> implements XyoArchivist<T> {
|
|
7
|
-
protected parent?: XyoArchivist<T>;
|
|
8
|
-
protected account?: XyoAccount;
|
|
9
|
-
constructor(parent?: XyoArchivist<T>, account?: XyoAccount);
|
|
10
|
-
abstract insert(payloads: T[]): T[] | Promise<T[]>;
|
|
11
|
-
abstract find<R extends T = T>(query: XyoPayloadFindQuery): R[] | Promise<R[]>;
|
|
12
|
-
abstract get(hash: string[]): (T | null)[] | Promise<(T | null)[]>;
|
|
13
|
-
all(): T[] | Promise<T[]>;
|
|
14
|
-
delete(_hashes: string[]): boolean[] | Promise<boolean[]>;
|
|
15
|
-
clear(): void | Promise<void>;
|
|
16
|
-
commit(): void;
|
|
17
|
-
}
|
package/dist/esm/XyoArchivist.js
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
constructor(parent, account) {
|
|
3
|
-
this.parent = parent;
|
|
4
|
-
this.account = account;
|
|
5
|
-
}
|
|
6
|
-
all() {
|
|
7
|
-
throw Error('getAll not supported');
|
|
8
|
-
}
|
|
9
|
-
delete(_hashes) {
|
|
10
|
-
throw Error('delete not supported');
|
|
11
|
-
}
|
|
12
|
-
clear() {
|
|
13
|
-
throw Error('clear not supported');
|
|
14
|
-
}
|
|
15
|
-
commit() {
|
|
16
|
-
throw Error('commit not supported');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
1
|
+
export {};
|
|
19
2
|
//# sourceMappingURL=XyoArchivist.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoArchivist.js","sourceRoot":"","sources":["../../src/XyoArchivist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"XyoArchivist.js","sourceRoot":"","sources":["../../src/XyoArchivist.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XyoPayload } from '@xyo-network/payload';
|
|
2
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
3
|
+
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
4
|
+
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter';
|
|
5
|
+
export declare abstract class XyoArchivistBase<T extends XyoPayload = XyoPayload> extends XyoArchivistConfigWrapper<T> implements XyoArchivist<T> {
|
|
6
|
+
abstract insert(payloads: T[]): T[] | Promise<T[]>;
|
|
7
|
+
abstract find<R extends T = T>(query: XyoPayloadFindQuery): R[] | Promise<R[]>;
|
|
8
|
+
abstract get(hash: string[]): (T | null)[] | Promise<(T | null)[]>;
|
|
9
|
+
all(): T[] | Promise<T[]>;
|
|
10
|
+
delete(_hashes: string[]): boolean[] | Promise<boolean[]>;
|
|
11
|
+
clear(): void | Promise<void>;
|
|
12
|
+
commit(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
2
|
+
export class XyoArchivistBase extends XyoArchivistConfigWrapper {
|
|
3
|
+
all() {
|
|
4
|
+
throw Error('getAll not supported');
|
|
5
|
+
}
|
|
6
|
+
delete(_hashes) {
|
|
7
|
+
throw Error('delete not supported');
|
|
8
|
+
}
|
|
9
|
+
clear() {
|
|
10
|
+
throw Error('clear not supported');
|
|
11
|
+
}
|
|
12
|
+
commit() {
|
|
13
|
+
throw Error('commit not supported');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=XyoArchivistBase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoArchivistBase.js","sourceRoot":"","sources":["../../src/XyoArchivistBase.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAGhE,MAAM,OAAgB,gBAAoD,SAAQ,yBAA4B;IAIrG,GAAG;QACR,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACM,MAAM,CAAC,OAAiB;QAC7B,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACM,KAAK;QACV,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACpC,CAAC;IACM,MAAM;QACX,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account';
|
|
2
|
+
import { XyoPayload } from '@xyo-network/payload';
|
|
3
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
4
|
+
export interface XyoArchivistConfig<T extends XyoPayload = XyoPayload> {
|
|
5
|
+
parent?: XyoArchivist<T>;
|
|
6
|
+
account?: XyoAccount;
|
|
7
|
+
cacheParentReads?: boolean;
|
|
8
|
+
writeThrough?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class XyoArchivistConfigWrapper<T extends XyoPayload = XyoPayload, C extends XyoArchivistConfig<T> = XyoArchivistConfig<T>> {
|
|
11
|
+
protected config?: C;
|
|
12
|
+
constructor(config?: C);
|
|
13
|
+
get parent(): XyoArchivist<T> | undefined;
|
|
14
|
+
get account(): XyoAccount | undefined;
|
|
15
|
+
get writeThrough(): boolean | undefined;
|
|
16
|
+
get cacheParentReads(): boolean | undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export class XyoArchivistConfigWrapper {
|
|
2
|
+
constructor(config) {
|
|
3
|
+
this.config = config;
|
|
4
|
+
}
|
|
5
|
+
get parent() {
|
|
6
|
+
return this.config?.parent;
|
|
7
|
+
}
|
|
8
|
+
get account() {
|
|
9
|
+
return this.config?.account;
|
|
10
|
+
}
|
|
11
|
+
get writeThrough() {
|
|
12
|
+
return this.config?.writeThrough;
|
|
13
|
+
}
|
|
14
|
+
get cacheParentReads() {
|
|
15
|
+
return this.config?.cacheParentReads;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=XyoArchivistConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoArchivistConfig.js","sourceRoot":"","sources":["../../src/XyoArchivistConfig.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,yBAAyB;IAEpC,YAAY,MAAU;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,MAAM,EAAE,MAAM,CAAA;IAC5B,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,MAAM,EAAE,OAAO,CAAA;IAC7B,CAAC;IAED,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,MAAM,EAAE,YAAY,CAAA;IAClC,CAAC;IAED,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,MAAM,EAAE,gBAAgB,CAAA;IACtC,CAAC;CACF"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { XyoPayload } from '@xyo-network/payload';
|
|
2
|
-
import {
|
|
2
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
3
|
+
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
3
4
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter';
|
|
4
|
-
export declare class XyoMemoryArchivist extends
|
|
5
|
+
export declare class XyoMemoryArchivist extends XyoArchivistConfigWrapper<XyoPayload> implements XyoArchivist {
|
|
5
6
|
private cache;
|
|
6
7
|
delete(hashes: string[]): boolean[] | Promise<boolean[]>;
|
|
7
8
|
clear(): void | Promise<void>;
|
|
8
9
|
get(hashes: string[]): Promise<(XyoPayload | null)[]>;
|
|
9
10
|
insert(payloads: XyoPayload[]): XyoPayload[] | Promise<XyoPayload[]>;
|
|
10
11
|
find<R extends XyoPayload = XyoPayload>(query: XyoPayloadFindQuery): R[] | Promise<R[]>;
|
|
12
|
+
all(): Promise<XyoPayload[]> | XyoPayload[];
|
|
11
13
|
commit(): Promise<import("@xyo-network/payload").XyoPayloadBase[] | undefined>;
|
|
12
14
|
}
|
|
@@ -2,8 +2,8 @@ import { assertEx } from '@xylabs/sdk-js';
|
|
|
2
2
|
import { XyoBoundWitnessBuilder } from '@xyo-network/boundwitness';
|
|
3
3
|
import { XyoPayloadWrapper } from '@xyo-network/payload';
|
|
4
4
|
import LruCache from 'lru-cache';
|
|
5
|
-
import {
|
|
6
|
-
export class XyoMemoryArchivist extends
|
|
5
|
+
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
6
|
+
export class XyoMemoryArchivist extends XyoArchivistConfigWrapper {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
9
9
|
this.cache = new LruCache({ max: 10000 });
|
|
@@ -38,6 +38,9 @@ export class XyoMemoryArchivist extends XyoArchivistBase {
|
|
|
38
38
|
});
|
|
39
39
|
return result;
|
|
40
40
|
}
|
|
41
|
+
all() {
|
|
42
|
+
return this.cache.dump().map((value) => value[1].value);
|
|
43
|
+
}
|
|
41
44
|
async commit() {
|
|
42
45
|
const parent = assertEx(this.parent, 'Parent is required for commit');
|
|
43
46
|
const account = assertEx(this.account, 'Account is required for commit');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../src/XyoMemoryArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAmB,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACnF,OAAO,EAAc,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,QAAQ,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../src/XyoMemoryArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAmB,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AACnF,OAAO,EAAc,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,QAAQ,MAAM,WAAW,CAAA;AA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1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA"}
|
package/package.json
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xylabs/sdk-js": "^2.6.2",
|
|
13
|
-
"@xyo-network/account": "^2.22.
|
|
14
|
-
"@xyo-network/boundwitness": "^2.22.
|
|
15
|
-
"@xyo-network/core": "^2.22.
|
|
16
|
-
"@xyo-network/payload": "^2.22.
|
|
13
|
+
"@xyo-network/account": "^2.22.10",
|
|
14
|
+
"@xyo-network/boundwitness": "^2.22.10",
|
|
15
|
+
"@xyo-network/core": "^2.22.10",
|
|
16
|
+
"@xyo-network/payload": "^2.22.10",
|
|
17
17
|
"axios": "^0.27.2",
|
|
18
18
|
"lru-cache": "^7.13.1",
|
|
19
19
|
"pako": "^2.0.4"
|
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
},
|
|
57
57
|
"sideEffects": true,
|
|
58
58
|
"types": "dist/esm/index.d.ts",
|
|
59
|
-
"version": "2.22.
|
|
59
|
+
"version": "2.22.10",
|
|
60
60
|
"packageManager": "yarn@3.1.1"
|
|
61
61
|
}
|
package/src/XyoArchivist.ts
CHANGED
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import { XyoAccount } from '@xyo-network/account'
|
|
2
1
|
import { XyoPayload } from '@xyo-network/payload'
|
|
3
2
|
|
|
4
3
|
import { Archivist } from './model'
|
|
5
4
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter'
|
|
6
5
|
|
|
7
6
|
export type XyoArchivist<T extends XyoPayload = XyoPayload> = Archivist<T, T, T, T, XyoPayloadFindQuery>
|
|
8
|
-
|
|
9
|
-
export abstract class XyoArchivistBase<T extends XyoPayload = XyoPayload> implements XyoArchivist<T> {
|
|
10
|
-
protected parent?: XyoArchivist<T>
|
|
11
|
-
protected account?: XyoAccount
|
|
12
|
-
constructor(parent?: XyoArchivist<T>, account?: XyoAccount) {
|
|
13
|
-
this.parent = parent
|
|
14
|
-
this.account = account
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
abstract insert(payloads: T[]): T[] | Promise<T[]>
|
|
18
|
-
abstract find<R extends T = T>(query: XyoPayloadFindQuery): R[] | Promise<R[]>
|
|
19
|
-
abstract get(hash: string[]): (T | null)[] | Promise<(T | null)[]>
|
|
20
|
-
public all(): T[] | Promise<T[]> {
|
|
21
|
-
throw Error('getAll not supported')
|
|
22
|
-
}
|
|
23
|
-
public delete(_hashes: string[]): boolean[] | Promise<boolean[]> {
|
|
24
|
-
throw Error('delete not supported')
|
|
25
|
-
}
|
|
26
|
-
public clear(): void | Promise<void> {
|
|
27
|
-
throw Error('clear not supported')
|
|
28
|
-
}
|
|
29
|
-
public commit() {
|
|
30
|
-
throw Error('commit not supported')
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account'
|
|
2
|
+
import { XyoPayload } from '@xyo-network/payload'
|
|
3
|
+
|
|
4
|
+
import { XyoArchivist } from './XyoArchivist'
|
|
5
|
+
|
|
6
|
+
export interface XyoArchivistConfig<T extends XyoPayload = XyoPayload> {
|
|
7
|
+
parent?: XyoArchivist<T>
|
|
8
|
+
account?: XyoAccount
|
|
9
|
+
cacheParentReads?: boolean
|
|
10
|
+
writeThrough?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class XyoArchivistConfigWrapper<T extends XyoPayload = XyoPayload, C extends XyoArchivistConfig<T> = XyoArchivistConfig<T>> {
|
|
14
|
+
protected config?: C
|
|
15
|
+
constructor(config?: C) {
|
|
16
|
+
this.config = config
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public get parent() {
|
|
20
|
+
return this.config?.parent
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public get account() {
|
|
24
|
+
return this.config?.account
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public get writeThrough() {
|
|
28
|
+
return this.config?.writeThrough
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public get cacheParentReads() {
|
|
32
|
+
return this.config?.cacheParentReads
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -3,10 +3,11 @@ import { XyoBoundWitness, XyoBoundWitnessBuilder } from '@xyo-network/boundwitne
|
|
|
3
3
|
import { XyoPayload, XyoPayloadWrapper } from '@xyo-network/payload'
|
|
4
4
|
import LruCache from 'lru-cache'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { XyoArchivist } from './XyoArchivist'
|
|
7
|
+
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig'
|
|
7
8
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter'
|
|
8
9
|
|
|
9
|
-
export class XyoMemoryArchivist extends
|
|
10
|
+
export class XyoMemoryArchivist extends XyoArchivistConfigWrapper<XyoPayload> implements XyoArchivist {
|
|
10
11
|
private cache = new LruCache<string, XyoPayload>({ max: 10000 })
|
|
11
12
|
|
|
12
13
|
public delete(hashes: string[]): boolean[] | Promise<boolean[]> {
|
|
@@ -46,6 +47,10 @@ export class XyoMemoryArchivist extends XyoArchivistBase<XyoPayload> {
|
|
|
46
47
|
return result
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
public all(): Promise<XyoPayload[]> | XyoPayload[] {
|
|
51
|
+
return this.cache.dump().map((value) => value[1].value)
|
|
52
|
+
}
|
|
53
|
+
|
|
49
54
|
public async commit() {
|
|
50
55
|
const parent = assertEx(this.parent, 'Parent is required for commit')
|
|
51
56
|
const account = assertEx(this.account, 'Account is required for commit')
|
package/src/index.ts
CHANGED
package/src/model/Archivist.ts
CHANGED