@xyo-network/api 2.21.19 → 2.21.22
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/Archivist/Model/Archivist.d.ts +6 -4
- package/dist/cjs/Archivist/XyoApiArchivist.d.ts +13 -0
- package/dist/cjs/Archivist/XyoApiArchivist.js +35 -0
- package/dist/cjs/Archivist/XyoApiArchivist.js.map +1 -0
- package/dist/cjs/Archivist/XyoArchivist.d.ts +17 -0
- package/dist/cjs/Archivist/XyoArchivist.js +35 -0
- package/dist/cjs/Archivist/XyoArchivist.js.map +1 -0
- package/dist/cjs/Archivist/XyoMemoryArchivist.d.ts +12 -0
- package/dist/cjs/Archivist/XyoMemoryArchivist.js +65 -0
- package/dist/cjs/Archivist/XyoMemoryArchivist.js.map +1 -0
- package/dist/cjs/Archivist/index.d.ts +3 -0
- package/dist/cjs/Archivist/index.js +3 -0
- package/dist/cjs/Archivist/index.js.map +1 -1
- package/dist/esm/Archivist/Model/Archivist.d.ts +6 -4
- package/dist/esm/Archivist/XyoApiArchivist.d.ts +13 -0
- package/dist/esm/Archivist/XyoApiArchivist.js +22 -0
- package/dist/esm/Archivist/XyoApiArchivist.js.map +1 -0
- package/dist/esm/Archivist/XyoArchivist.d.ts +17 -0
- package/dist/esm/Archivist/XyoArchivist.js +28 -0
- package/dist/esm/Archivist/XyoArchivist.js.map +1 -0
- package/dist/esm/Archivist/XyoMemoryArchivist.d.ts +12 -0
- package/dist/esm/Archivist/XyoMemoryArchivist.js +58 -0
- package/dist/esm/Archivist/XyoMemoryArchivist.js.map +1 -0
- package/dist/esm/Archivist/index.d.ts +3 -0
- package/dist/esm/Archivist/index.js +3 -0
- package/dist/esm/Archivist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/Archivist/Account/Api.spec.ts +2 -2
- package/src/Archivist/Api.spec.ts +10 -10
- package/src/Archivist/Model/Archivist.ts +6 -4
- package/src/Archivist/Payload/Api.spec.ts +2 -2
- package/src/Archivist/XyoApiArchivist.ts +32 -0
- package/src/Archivist/XyoArchivist.ts +40 -0
- package/src/Archivist/XyoMemoryArchivist.ts +62 -0
- package/src/Archivist/index.ts +3 -0
- package/src/Diviner/LocationDiviner/LocationDivinerApi.spec.ts +3 -3
- package/src/User/Api.spec.ts +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export interface QueryableArchivist<TQueryResponse, TQuery> {
|
|
2
|
-
find(query: TQuery): Promise<TQueryResponse
|
|
2
|
+
find(query: TQuery): Promise<TQueryResponse> | TQueryResponse;
|
|
3
3
|
}
|
|
4
4
|
export interface ReadArchivist<TReadResponse, TId = string> {
|
|
5
|
-
get(id: TId): Promise<TReadResponse
|
|
5
|
+
get(id: TId): Promise<TReadResponse | undefined> | TReadResponse | undefined;
|
|
6
6
|
}
|
|
7
|
-
export interface WriteArchivist<TWriteResponse, TWrite> {
|
|
8
|
-
insert(item: TWrite): Promise<TWriteResponse
|
|
7
|
+
export interface WriteArchivist<TWriteResponse, TWrite, TId = string> {
|
|
8
|
+
insert(item: TWrite): Promise<TWriteResponse> | TWriteResponse;
|
|
9
|
+
delete?(id: TId): Promise<boolean> | boolean;
|
|
10
|
+
clear?(): void;
|
|
9
11
|
}
|
|
10
12
|
export declare type ReadWriteArchivist<TWriteResponse, TWrite, TReadResponse = TWriteResponse, TId = string> = ReadArchivist<TReadResponse, TId> & WriteArchivist<TWriteResponse, TWrite>;
|
|
11
13
|
export declare type Archivist<TWriteResponse, TWrite, TReadResponse = TWriteResponse, TId = string, TQueryResponse = unknown, TQuery = unknown> = ReadWriteArchivist<TWriteResponse, TWrite, TReadResponse, TId> & QueryableArchivist<TQueryResponse, TQuery>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account';
|
|
2
|
+
import { XyoBoundWitnessWithPartialMeta } from '@xyo-network/boundwitness';
|
|
3
|
+
import { XyoArchivistApi } from './Api';
|
|
4
|
+
import { XyoPayloadFindFilter } from './Payload';
|
|
5
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
6
|
+
export declare class XyoApiArchivist extends XyoArchivist {
|
|
7
|
+
protected api: XyoArchivistApi;
|
|
8
|
+
protected archive: string;
|
|
9
|
+
constructor(api: XyoArchivistApi, archive: string, parent?: XyoArchivist, account?: XyoAccount);
|
|
10
|
+
get(hash: string): Promise<import("@xyo-network/payload").XyoPayload<object> | undefined>;
|
|
11
|
+
insert(payload: XyoBoundWitnessWithPartialMeta): Promise<string[]>;
|
|
12
|
+
find(filter: XyoPayloadFindFilter): Promise<import("@xyo-network/payload").XyoPayloadWithPartialMeta<unknown>[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XyoApiArchivist = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sdk_js_1 = require("@xylabs/sdk-js");
|
|
6
|
+
const XyoArchivist_1 = require("./XyoArchivist");
|
|
7
|
+
class XyoApiArchivist extends XyoArchivist_1.XyoArchivist {
|
|
8
|
+
constructor(api, archive, parent, account) {
|
|
9
|
+
super(parent, account);
|
|
10
|
+
this.api = api;
|
|
11
|
+
this.archive = archive;
|
|
12
|
+
}
|
|
13
|
+
get(hash) {
|
|
14
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
const [payloads] = yield this.api.archive(this.archive).payload.hash(hash).get('tuple');
|
|
16
|
+
return payloads === null || payloads === void 0 ? void 0 : payloads.pop();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
insert(payload) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
return (_b = (_a = (yield this.api.archive(this.archive).block.post([payload]))) === null || _a === void 0 ? void 0 : _a.map((value) => (0, sdk_js_1.assertEx)(value._hash))) !== null && _b !== void 0 ? _b : [];
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
find(filter) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
const [payloads = []] = (_a = (yield this.api.archive(this.archive).payload.find(filter, 'tuple'))) !== null && _a !== void 0 ? _a : [];
|
|
29
|
+
const [blocks = []] = (_b = (yield this.api.archive(this.archive).block.find(filter, 'tuple'))) !== null && _b !== void 0 ? _b : [];
|
|
30
|
+
return payloads.concat(blocks);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.XyoApiArchivist = XyoApiArchivist;
|
|
35
|
+
//# sourceMappingURL=XyoApiArchivist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoApiArchivist.js","sourceRoot":"","sources":["../../../src/Archivist/XyoApiArchivist.ts"],"names":[],"mappings":";;;;AAAA,2CAAyC;AAMzC,iDAA6C;AAE7C,MAAa,eAAgB,SAAQ,2BAAY;IAG/C,YAAY,GAAoB,EAAE,OAAe,EAAE,MAAqB,EAAE,OAAoB;QAC5F,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAEY,GAAG,CAAC,IAAY;;YAC3B,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;YACvF,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,EAAE,CAAA;QACxB,CAAC;KAAA;IAEY,MAAM,CAAC,OAAuC;;;YACzD,OAAO,MAAA,MAAA,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,0CAAE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,iBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,mCAAI,EAAE,CAAA;;KACjH;IAEY,IAAI,CAAC,MAA4B;;;YAC5C,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,MAAA,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,mCAAI,EAAE,CAAA;YAClG,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,MAAA,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,mCAAI,EAAE,CAAA;YAC9F,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;;KAC/B;CACF;AAvBD,0CAuBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account';
|
|
2
|
+
import { XyoBoundWitness, XyoBoundWitnessWithPartialMeta } from '@xyo-network/boundwitness';
|
|
3
|
+
import { XyoPayload, XyoPayloadWithPartialMeta } from '@xyo-network/payload';
|
|
4
|
+
import { Archivist } from './Model';
|
|
5
|
+
import { XyoPayloadFindFilter } from './Payload';
|
|
6
|
+
export declare abstract class XyoArchivist<TWrite extends XyoBoundWitness = XyoBoundWitnessWithPartialMeta, TRead extends XyoPayload = XyoPayloadWithPartialMeta> implements Archivist<string[], TWrite, TRead | undefined, string, TRead[], XyoPayloadFindFilter> {
|
|
7
|
+
protected parent?: XyoArchivist;
|
|
8
|
+
protected account?: XyoAccount;
|
|
9
|
+
constructor(parent?: XyoArchivist, account?: XyoAccount);
|
|
10
|
+
abstract insert(item: TWrite): string[] | Promise<string[]>;
|
|
11
|
+
abstract find(query: XyoPayloadFindFilter): TRead[] | Promise<TRead[]>;
|
|
12
|
+
abstract get(hash: string): TRead | Promise<TRead | undefined> | undefined;
|
|
13
|
+
all(): TRead[] | Promise<TRead[] | undefined> | undefined;
|
|
14
|
+
delete(_hash: string): boolean | Promise<boolean>;
|
|
15
|
+
clear(): void | Promise<void>;
|
|
16
|
+
commit(): Promise<string>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XyoArchivist = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const sdk_js_1 = require("@xylabs/sdk-js");
|
|
6
|
+
const boundwitness_1 = require("@xyo-network/boundwitness");
|
|
7
|
+
class XyoArchivist {
|
|
8
|
+
constructor(parent, account) {
|
|
9
|
+
this.parent = parent;
|
|
10
|
+
this.account = account;
|
|
11
|
+
}
|
|
12
|
+
all() {
|
|
13
|
+
throw Error('getAll not supported');
|
|
14
|
+
}
|
|
15
|
+
delete(_hash) {
|
|
16
|
+
throw Error('delete not supported');
|
|
17
|
+
}
|
|
18
|
+
clear() {
|
|
19
|
+
throw Error('clear not supported');
|
|
20
|
+
}
|
|
21
|
+
commit() {
|
|
22
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const parent = (0, sdk_js_1.assertEx)(this.parent, 'Parent is required for commit');
|
|
24
|
+
const account = (0, sdk_js_1.assertEx)(this.account, 'Account is required for commit');
|
|
25
|
+
const payloads = (0, sdk_js_1.assertEx)(yield parent.all(), 'Nothing to commit');
|
|
26
|
+
const builder = new boundwitness_1.XyoBoundWitnessBuilder();
|
|
27
|
+
const block = builder.payloads(payloads).witness(account).build();
|
|
28
|
+
const [hash] = yield parent.insert(block);
|
|
29
|
+
yield this.clear();
|
|
30
|
+
return hash;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.XyoArchivist = XyoArchivist;
|
|
35
|
+
//# sourceMappingURL=XyoArchivist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoArchivist.js","sourceRoot":"","sources":["../../../src/Archivist/XyoArchivist.ts"],"names":[],"mappings":";;;;AAAA,2CAAyC;AAEzC,4DAAmH;AAMnH,MAAsB,YAAY;IAKhC,YAAY,MAAqB,EAAE,OAAoB;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAIM,GAAG;QACR,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACM,MAAM,CAAC,KAAa;QACzB,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACM,KAAK;QACV,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACpC,CAAC;IACY,MAAM;;YACjB,MAAM,MAAM,GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAA;YACrE,MAAM,OAAO,GAAG,IAAA,iBAAQ,EAAC,IAAI,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAA;YACxE,MAAM,QAAQ,GAAG,IAAA,iBAAQ,EAAC,MAAM,MAAM,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAA;YAClE,MAAM,OAAO,GAAG,IAAI,qCAAsB,EAAE,CAAA;YAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;YACjE,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACzC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAClB,OAAO,IAAI,CAAA;QACb,CAAC;KAAA;CACF;AA/BD,oCA+BC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { XyoBoundWitnessWithMeta } from '@xyo-network/boundwitness';
|
|
2
|
+
import { XyoPayload, XyoPayloadWithPartialMeta } from '@xyo-network/payload';
|
|
3
|
+
import { XyoPayloadFindFilter } from './Payload';
|
|
4
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
5
|
+
export declare class XyoMemoryArchivist extends XyoArchivist {
|
|
6
|
+
private cache;
|
|
7
|
+
delete(hash: string): boolean;
|
|
8
|
+
clear(): void;
|
|
9
|
+
get(hash: string): XyoPayloadWithPartialMeta<unknown> | Promise<XyoPayloadWithPartialMeta<unknown> | undefined> | undefined;
|
|
10
|
+
insert(payload: XyoBoundWitnessWithMeta): string[];
|
|
11
|
+
find<T extends XyoPayload = XyoPayload>(filter: XyoPayloadFindFilter): T[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XyoMemoryArchivist = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const boundwitness_1 = require("@xyo-network/boundwitness");
|
|
6
|
+
const payload_1 = require("@xyo-network/payload");
|
|
7
|
+
const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
|
|
8
|
+
const XyoArchivist_1 = require("./XyoArchivist");
|
|
9
|
+
class XyoMemoryArchivist extends XyoArchivist_1.XyoArchivist {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.cache = new lru_cache_1.default({ max: 10000 });
|
|
13
|
+
}
|
|
14
|
+
delete(hash) {
|
|
15
|
+
return this.cache.delete(hash);
|
|
16
|
+
}
|
|
17
|
+
clear() {
|
|
18
|
+
this.cache.clear();
|
|
19
|
+
}
|
|
20
|
+
get(hash) {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
return (_a = this.cache.get(hash)) !== null && _a !== void 0 ? _a : (_b = this.parent) === null || _b === void 0 ? void 0 : _b.get(hash);
|
|
23
|
+
}
|
|
24
|
+
insert(payload) {
|
|
25
|
+
var _a;
|
|
26
|
+
const wrapper = new boundwitness_1.XyoBoundWitnessWrapper(payload);
|
|
27
|
+
const payloadWithmeta = Object.assign(Object.assign({}, payload), { _hash: wrapper.hash, _timestamp: Date.now() });
|
|
28
|
+
const hashes = [];
|
|
29
|
+
hashes.push(payloadWithmeta._hash);
|
|
30
|
+
this.cache.set(payloadWithmeta._hash, payloadWithmeta);
|
|
31
|
+
(_a = payload._payloads) === null || _a === void 0 ? void 0 : _a.forEach((payload) => {
|
|
32
|
+
const wrapper = new payload_1.XyoPayloadWrapper(payload);
|
|
33
|
+
const payloadWithmeta = Object.assign(Object.assign({}, payload), { _hash: wrapper.hash, _timestamp: Date.now() });
|
|
34
|
+
hashes.push(payloadWithmeta._hash);
|
|
35
|
+
this.cache.set(payloadWithmeta._hash, payloadWithmeta);
|
|
36
|
+
});
|
|
37
|
+
return hashes;
|
|
38
|
+
}
|
|
39
|
+
find(filter) {
|
|
40
|
+
const result = [];
|
|
41
|
+
if (filter.type === 'schema') {
|
|
42
|
+
const filterSchema = filter.schema !== undefined ? (Array.isArray(filter.schema) ? filter.schema : [filter.schema]) : undefined;
|
|
43
|
+
this.cache.forEach((value) => {
|
|
44
|
+
let match = value;
|
|
45
|
+
match = filterSchema === undefined || filterSchema.includes(value.schema) ? value : undefined;
|
|
46
|
+
if (match) {
|
|
47
|
+
result.push(match);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (filter.type === 'hash') {
|
|
52
|
+
const filterHash = filter.hash !== undefined ? (Array.isArray(filter.hash) ? filter.hash : [filter.hash]) : undefined;
|
|
53
|
+
this.cache.forEach((value) => {
|
|
54
|
+
let match = value;
|
|
55
|
+
match = filterHash === undefined || filterHash.includes(new payload_1.XyoPayloadWrapper(value).hash) ? value : undefined;
|
|
56
|
+
if (match) {
|
|
57
|
+
result.push(match);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.XyoMemoryArchivist = XyoMemoryArchivist;
|
|
65
|
+
//# sourceMappingURL=XyoMemoryArchivist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../../src/Archivist/XyoMemoryArchivist.ts"],"names":[],"mappings":";;;;AAAA,4DAA2F;AAC3F,kDAA+F;AAC/F,kEAAgC;AAGhC,iDAA6C;AAE7C,MAAa,kBAAmB,SAAQ,2BAAY;IAApD;;QACU,UAAK,GAAgD,IAAI,mBAAQ,CAAoC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;IAqD9H,CAAC;IAnDQ,MAAM,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAEM,GAAG,CAAC,IAAY;;QACrB,OAAO,MAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,GAAG,CAAC,IAAI,CAAC,CAAA;IACvD,CAAC;IAEM,MAAM,CAAC,OAAgC;;QAC5C,MAAM,OAAO,GAAG,IAAI,qCAAsB,CAAC,OAAO,CAAC,CAAA;QACnD,MAAM,eAAe,mCAAQ,OAAO,KAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE,GAAE,CAAA;QACnF,MAAM,MAAM,GAAa,EAAE,CAAA;QAC3B,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;Q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A;iBACxB;YACH,CAAC,CAAC,CAAA;SACH;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE;YAC1B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;YACrH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC3B,IAAI,KAAK,GAA2B,KAAK,CAAA;gBACzC,KAAK,GAAG,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,QAAQ,CAAC,IAAI,2BAAiB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;gBAC9G,IAAI,KAAK,EAAE;oBACT,MAAM,CAAC,IAAI,CAAC,KAAU,CAAC,CAAA;iBACxB;YACH,CAAC,CAAC,CAAA;SACH;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAtDD,gDAsDC"}
|
|
@@ -8,4 +8,7 @@ tslib_1.__exportStar(require("./Archives"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./Block"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./Model"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./Payload"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./XyoApiArchivist"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./XyoArchivist"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./XyoMemoryArchivist"), exports);
|
|
11
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Archivist/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,gDAAqB;AACrB,oDAAyB;AACzB,qDAA0B;AAC1B,kDAAuB;AACvB,kDAAuB;AACvB,oDAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Archivist/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,gDAAqB;AACrB,oDAAyB;AACzB,qDAA0B;AAC1B,kDAAuB;AACvB,kDAAuB;AACvB,oDAAyB;AACzB,4DAAiC;AACjC,yDAA8B;AAC9B,+DAAoC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export interface QueryableArchivist<TQueryResponse, TQuery> {
|
|
2
|
-
find(query: TQuery): Promise<TQueryResponse
|
|
2
|
+
find(query: TQuery): Promise<TQueryResponse> | TQueryResponse;
|
|
3
3
|
}
|
|
4
4
|
export interface ReadArchivist<TReadResponse, TId = string> {
|
|
5
|
-
get(id: TId): Promise<TReadResponse
|
|
5
|
+
get(id: TId): Promise<TReadResponse | undefined> | TReadResponse | undefined;
|
|
6
6
|
}
|
|
7
|
-
export interface WriteArchivist<TWriteResponse, TWrite> {
|
|
8
|
-
insert(item: TWrite): Promise<TWriteResponse
|
|
7
|
+
export interface WriteArchivist<TWriteResponse, TWrite, TId = string> {
|
|
8
|
+
insert(item: TWrite): Promise<TWriteResponse> | TWriteResponse;
|
|
9
|
+
delete?(id: TId): Promise<boolean> | boolean;
|
|
10
|
+
clear?(): void;
|
|
9
11
|
}
|
|
10
12
|
export declare type ReadWriteArchivist<TWriteResponse, TWrite, TReadResponse = TWriteResponse, TId = string> = ReadArchivist<TReadResponse, TId> & WriteArchivist<TWriteResponse, TWrite>;
|
|
11
13
|
export declare type Archivist<TWriteResponse, TWrite, TReadResponse = TWriteResponse, TId = string, TQueryResponse = unknown, TQuery = unknown> = ReadWriteArchivist<TWriteResponse, TWrite, TReadResponse, TId> & QueryableArchivist<TQueryResponse, TQuery>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account';
|
|
2
|
+
import { XyoBoundWitnessWithPartialMeta } from '@xyo-network/boundwitness';
|
|
3
|
+
import { XyoArchivistApi } from './Api';
|
|
4
|
+
import { XyoPayloadFindFilter } from './Payload';
|
|
5
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
6
|
+
export declare class XyoApiArchivist extends XyoArchivist {
|
|
7
|
+
protected api: XyoArchivistApi;
|
|
8
|
+
protected archive: string;
|
|
9
|
+
constructor(api: XyoArchivistApi, archive: string, parent?: XyoArchivist, account?: XyoAccount);
|
|
10
|
+
get(hash: string): Promise<import("@xyo-network/payload").XyoPayload<object> | undefined>;
|
|
11
|
+
insert(payload: XyoBoundWitnessWithPartialMeta): Promise<string[]>;
|
|
12
|
+
find(filter: XyoPayloadFindFilter): Promise<import("@xyo-network/payload").XyoPayloadWithPartialMeta<unknown>[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/sdk-js';
|
|
2
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
3
|
+
export class XyoApiArchivist extends XyoArchivist {
|
|
4
|
+
constructor(api, archive, parent, account) {
|
|
5
|
+
super(parent, account);
|
|
6
|
+
this.api = api;
|
|
7
|
+
this.archive = archive;
|
|
8
|
+
}
|
|
9
|
+
async get(hash) {
|
|
10
|
+
const [payloads] = await this.api.archive(this.archive).payload.hash(hash).get('tuple');
|
|
11
|
+
return payloads?.pop();
|
|
12
|
+
}
|
|
13
|
+
async insert(payload) {
|
|
14
|
+
return (await this.api.archive(this.archive).block.post([payload]))?.map((value) => assertEx(value._hash)) ?? [];
|
|
15
|
+
}
|
|
16
|
+
async find(filter) {
|
|
17
|
+
const [payloads = []] = (await this.api.archive(this.archive).payload.find(filter, 'tuple')) ?? [];
|
|
18
|
+
const [blocks = []] = (await this.api.archive(this.archive).block.find(filter, 'tuple')) ?? [];
|
|
19
|
+
return payloads.concat(blocks);
|
|
20
|
+
}
|
|
21
|
+
}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AC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;QAClG,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;QAC9F,OAAO,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { XyoAccount } from '@xyo-network/account';
|
|
2
|
+
import { XyoBoundWitness, XyoBoundWitnessWithPartialMeta } from '@xyo-network/boundwitness';
|
|
3
|
+
import { XyoPayload, XyoPayloadWithPartialMeta } from '@xyo-network/payload';
|
|
4
|
+
import { Archivist } from './Model';
|
|
5
|
+
import { XyoPayloadFindFilter } from './Payload';
|
|
6
|
+
export declare abstract class XyoArchivist<TWrite extends XyoBoundWitness = XyoBoundWitnessWithPartialMeta, TRead extends XyoPayload = XyoPayloadWithPartialMeta> implements Archivist<string[], TWrite, TRead | undefined, string, TRead[], XyoPayloadFindFilter> {
|
|
7
|
+
protected parent?: XyoArchivist;
|
|
8
|
+
protected account?: XyoAccount;
|
|
9
|
+
constructor(parent?: XyoArchivist, account?: XyoAccount);
|
|
10
|
+
abstract insert(item: TWrite): string[] | Promise<string[]>;
|
|
11
|
+
abstract find(query: XyoPayloadFindFilter): TRead[] | Promise<TRead[]>;
|
|
12
|
+
abstract get(hash: string): TRead | Promise<TRead | undefined> | undefined;
|
|
13
|
+
all(): TRead[] | Promise<TRead[] | undefined> | undefined;
|
|
14
|
+
delete(_hash: string): boolean | Promise<boolean>;
|
|
15
|
+
clear(): void | Promise<void>;
|
|
16
|
+
commit(): Promise<string>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/sdk-js';
|
|
2
|
+
import { XyoBoundWitnessBuilder } from '@xyo-network/boundwitness';
|
|
3
|
+
export class XyoArchivist {
|
|
4
|
+
constructor(parent, account) {
|
|
5
|
+
this.parent = parent;
|
|
6
|
+
this.account = account;
|
|
7
|
+
}
|
|
8
|
+
all() {
|
|
9
|
+
throw Error('getAll not supported');
|
|
10
|
+
}
|
|
11
|
+
delete(_hash) {
|
|
12
|
+
throw Error('delete not supported');
|
|
13
|
+
}
|
|
14
|
+
clear() {
|
|
15
|
+
throw Error('clear not supported');
|
|
16
|
+
}
|
|
17
|
+
async commit() {
|
|
18
|
+
const parent = assertEx(this.parent, 'Parent is required for commit');
|
|
19
|
+
const account = assertEx(this.account, 'Account is required for commit');
|
|
20
|
+
const payloads = assertEx(await parent.all(), 'Nothing to commit');
|
|
21
|
+
const builder = new XyoBoundWitnessBuilder();
|
|
22
|
+
const block = builder.payloads(payloads).witness(account).build();
|
|
23
|
+
const [hash] = await parent.insert(block);
|
|
24
|
+
await this.clear();
|
|
25
|
+
return hash;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=XyoArchivist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoArchivist.js","sourceRoot":"","sources":["../../../src/Archivist/XyoArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAmB,sBAAsB,EAAkC,MAAM,2BAA2B,CAAA;AAMnH,MAAM,OAAgB,YAAY;IAKhC,YAAY,MAAqB,EAAE,OAAoB;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAIM,GAAG;QACR,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACM,MAAM,CAAC,KAAa;QACzB,MAAM,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACrC,CAAC;IACM,KAAK;QACV,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAA;IACpC,CAAC;IACM,KAAK,CAAC,MAAM;QACjB,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,+BAA+B,CAAC,CAAA;QACrE,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAA;QACxE,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,MAAM,CAAC,GAAG,EAAE,EAAE,mBAAmB,CAAC,CAAA;QAClE,MAAM,OAAO,GAAG,IAAI,sBAAsB,EAAE,CAAA;QAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAA;QACjE,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QACzC,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { XyoBoundWitnessWithMeta } from '@xyo-network/boundwitness';
|
|
2
|
+
import { XyoPayload, XyoPayloadWithPartialMeta } from '@xyo-network/payload';
|
|
3
|
+
import { XyoPayloadFindFilter } from './Payload';
|
|
4
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
5
|
+
export declare class XyoMemoryArchivist extends XyoArchivist {
|
|
6
|
+
private cache;
|
|
7
|
+
delete(hash: string): boolean;
|
|
8
|
+
clear(): void;
|
|
9
|
+
get(hash: string): XyoPayloadWithPartialMeta<unknown> | Promise<XyoPayloadWithPartialMeta<unknown> | undefined> | undefined;
|
|
10
|
+
insert(payload: XyoBoundWitnessWithMeta): string[];
|
|
11
|
+
find<T extends XyoPayload = XyoPayload>(filter: XyoPayloadFindFilter): T[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { XyoBoundWitnessWrapper } from '@xyo-network/boundwitness';
|
|
2
|
+
import { XyoPayloadWrapper } from '@xyo-network/payload';
|
|
3
|
+
import LruCache from 'lru-cache';
|
|
4
|
+
import { XyoArchivist } from './XyoArchivist';
|
|
5
|
+
export class XyoMemoryArchivist extends XyoArchivist {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.cache = new LruCache({ max: 10000 });
|
|
9
|
+
}
|
|
10
|
+
delete(hash) {
|
|
11
|
+
return this.cache.delete(hash);
|
|
12
|
+
}
|
|
13
|
+
clear() {
|
|
14
|
+
this.cache.clear();
|
|
15
|
+
}
|
|
16
|
+
get(hash) {
|
|
17
|
+
return this.cache.get(hash) ?? this.parent?.get(hash);
|
|
18
|
+
}
|
|
19
|
+
insert(payload) {
|
|
20
|
+
const wrapper = new XyoBoundWitnessWrapper(payload);
|
|
21
|
+
const payloadWithmeta = { ...payload, _hash: wrapper.hash, _timestamp: Date.now() };
|
|
22
|
+
const hashes = [];
|
|
23
|
+
hashes.push(payloadWithmeta._hash);
|
|
24
|
+
this.cache.set(payloadWithmeta._hash, payloadWithmeta);
|
|
25
|
+
payload._payloads?.forEach((payload) => {
|
|
26
|
+
const wrapper = new XyoPayloadWrapper(payload);
|
|
27
|
+
const payloadWithmeta = { ...payload, _hash: wrapper.hash, _timestamp: Date.now() };
|
|
28
|
+
hashes.push(payloadWithmeta._hash);
|
|
29
|
+
this.cache.set(payloadWithmeta._hash, payloadWithmeta);
|
|
30
|
+
});
|
|
31
|
+
return hashes;
|
|
32
|
+
}
|
|
33
|
+
find(filter) {
|
|
34
|
+
const result = [];
|
|
35
|
+
if (filter.type === 'schema') {
|
|
36
|
+
const filterSchema = filter.schema !== undefined ? (Array.isArray(filter.schema) ? filter.schema : [filter.schema]) : undefined;
|
|
37
|
+
this.cache.forEach((value) => {
|
|
38
|
+
let match = value;
|
|
39
|
+
match = filterSchema === undefined || filterSchema.includes(value.schema) ? value : undefined;
|
|
40
|
+
if (match) {
|
|
41
|
+
result.push(match);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (filter.type === 'hash') {
|
|
46
|
+
const filterHash = filter.hash !== undefined ? (Array.isArray(filter.hash) ? filter.hash : [filter.hash]) : undefined;
|
|
47
|
+
this.cache.forEach((value) => {
|
|
48
|
+
let match = value;
|
|
49
|
+
match = filterHash === undefined || filterHash.includes(new XyoPayloadWrapper(value).hash) ? value : undefined;
|
|
50
|
+
if (match) {
|
|
51
|
+
result.push(match);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=XyoMemoryArchivist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../../src/Archivist/XyoMemoryArchivist.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAC3F,OAAO,EAAyC,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAC/F,OAAO,QAAQ,MAAM,WAAW,CAAA;AAGhC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,OAAO,kBAAmB,SAAQ,YAAY;IAApD;;QACU,UAAK,GAAgD,IAAI,QAAQ,CAAoC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;IAqD9H,CAAC;IAnDQ,MAAM,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAChC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAEM,GAAG,CAAC,IAAY;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC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ources":["../../../src/Archivist/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Archivist/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,OAAO,CAAA;AACrB,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,sBAAsB,CAAA"}
|
package/package.json
CHANGED
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xylabs/sdk-js": "^2.6.2",
|
|
13
|
-
"@xyo-network/account": "^2.21.
|
|
14
|
-
"@xyo-network/boundwitness": "^2.21.
|
|
15
|
-
"@xyo-network/core": "^2.21.
|
|
16
|
-
"@xyo-network/payload": "^2.21.
|
|
17
|
-
"@xyo-network/typeof": "^2.21.
|
|
13
|
+
"@xyo-network/account": "^2.21.22",
|
|
14
|
+
"@xyo-network/boundwitness": "^2.21.22",
|
|
15
|
+
"@xyo-network/core": "^2.21.22",
|
|
16
|
+
"@xyo-network/payload": "^2.21.22",
|
|
17
|
+
"@xyo-network/typeof": "^2.21.22",
|
|
18
18
|
"axios": "^0.27.2",
|
|
19
|
+
"lru-cache": "^7.13.1",
|
|
19
20
|
"pako": "^2.0.4",
|
|
20
21
|
"uuid": "^8.3.2"
|
|
21
22
|
},
|
|
@@ -25,7 +26,6 @@
|
|
|
25
26
|
"@types/pako": "^2.0.0",
|
|
26
27
|
"@types/uuid": "^8.3.4",
|
|
27
28
|
"@xylabs/tsconfig": "^1.0.14",
|
|
28
|
-
"dotenv": "^16.0.1",
|
|
29
29
|
"tslib": "^2.4.0"
|
|
30
30
|
},
|
|
31
31
|
"browser": "dist/esm/index.js",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
},
|
|
62
62
|
"sideEffects": true,
|
|
63
63
|
"types": "dist/esm/index.d.ts",
|
|
64
|
-
"version": "2.21.
|
|
64
|
+
"version": "2.21.22",
|
|
65
65
|
"packageManager": "yarn@3.1.1"
|
|
66
66
|
}
|
|
@@ -32,7 +32,7 @@ describe('XyoAuthApi', () => {
|
|
|
32
32
|
} catch (ex) {
|
|
33
33
|
const error = ex as XyoApiError
|
|
34
34
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
35
|
-
|
|
35
|
+
expect(error === undefined)
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
timeout
|
|
@@ -60,7 +60,7 @@ describe('XyoAuthApi', () => {
|
|
|
60
60
|
} catch (ex) {
|
|
61
61
|
const error = ex as AxiosError
|
|
62
62
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
63
|
-
|
|
63
|
+
expect(error === undefined)
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
timeout
|
|
@@ -25,7 +25,7 @@ describe('postBoundWitness', () => {
|
|
|
25
25
|
} catch (ex) {
|
|
26
26
|
const error = ex as XyoApiError
|
|
27
27
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
28
|
-
|
|
28
|
+
expect(error === undefined)
|
|
29
29
|
}
|
|
30
30
|
})
|
|
31
31
|
})
|
|
@@ -45,7 +45,7 @@ describe('postBoundWitnesses', () => {
|
|
|
45
45
|
} catch (ex) {
|
|
46
46
|
const error = ex as XyoApiError
|
|
47
47
|
console.log(JSON.stringify(error, null, 2))
|
|
48
|
-
|
|
48
|
+
expect(error === undefined)
|
|
49
49
|
}
|
|
50
50
|
})
|
|
51
51
|
})
|
|
@@ -74,7 +74,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
74
74
|
} catch (ex) {
|
|
75
75
|
const error = ex as XyoApiError
|
|
76
76
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
77
|
-
|
|
77
|
+
expect(error === undefined)
|
|
78
78
|
}
|
|
79
79
|
})
|
|
80
80
|
})
|
|
@@ -93,7 +93,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
93
93
|
} catch (ex) {
|
|
94
94
|
const error = ex as XyoApiError
|
|
95
95
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
96
|
-
|
|
96
|
+
expect(error === undefined)
|
|
97
97
|
}
|
|
98
98
|
})
|
|
99
99
|
})
|
|
@@ -111,7 +111,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
111
111
|
} catch (ex) {
|
|
112
112
|
const error = ex as XyoApiError
|
|
113
113
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
114
|
-
|
|
114
|
+
expect(error === undefined)
|
|
115
115
|
}
|
|
116
116
|
})
|
|
117
117
|
})
|
|
@@ -130,7 +130,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
130
130
|
} catch (ex) {
|
|
131
131
|
const error = ex as XyoApiError
|
|
132
132
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
133
|
-
|
|
133
|
+
expect(error === undefined)
|
|
134
134
|
}
|
|
135
135
|
})
|
|
136
136
|
})
|
|
@@ -147,7 +147,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
147
147
|
} catch (ex) {
|
|
148
148
|
const error = ex as XyoApiError
|
|
149
149
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
150
|
-
|
|
150
|
+
expect(error === undefined)
|
|
151
151
|
}
|
|
152
152
|
})
|
|
153
153
|
})
|
|
@@ -162,7 +162,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
162
162
|
} catch (ex) {
|
|
163
163
|
const error = ex as XyoApiError
|
|
164
164
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
165
|
-
|
|
165
|
+
expect(error === undefined)
|
|
166
166
|
}
|
|
167
167
|
})
|
|
168
168
|
})
|
|
@@ -184,7 +184,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
184
184
|
} catch (ex) {
|
|
185
185
|
const error = ex as XyoApiError
|
|
186
186
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
187
|
-
|
|
187
|
+
expect(error === undefined)
|
|
188
188
|
}
|
|
189
189
|
})
|
|
190
190
|
})
|
|
@@ -206,7 +206,7 @@ describe.skip('XyoArchivistApi', () => {
|
|
|
206
206
|
} catch (ex) {
|
|
207
207
|
const error = ex as XyoApiError
|
|
208
208
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
209
|
-
|
|
209
|
+
expect(error === undefined)
|
|
210
210
|
}
|
|
211
211
|
})
|
|
212
212
|
})
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export interface QueryableArchivist<TQueryResponse, TQuery> {
|
|
2
|
-
find(query: TQuery): Promise<TQueryResponse>
|
|
2
|
+
find(query: TQuery): Promise<TQueryResponse> | TQueryResponse
|
|
3
3
|
}
|
|
4
4
|
export interface ReadArchivist<TReadResponse, TId = string> {
|
|
5
|
-
get(id: TId): Promise<TReadResponse>
|
|
5
|
+
get(id: TId): Promise<TReadResponse | undefined> | TReadResponse | undefined
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface WriteArchivist<TWriteResponse, TWrite> {
|
|
9
|
-
insert(item: TWrite): Promise<TWriteResponse>
|
|
8
|
+
export interface WriteArchivist<TWriteResponse, TWrite, TId = string> {
|
|
9
|
+
insert(item: TWrite): Promise<TWriteResponse> | TWriteResponse
|
|
10
|
+
delete?(id: TId): Promise<boolean> | boolean
|
|
11
|
+
clear?(): void
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export type ReadWriteArchivist<TWriteResponse, TWrite, TReadResponse = TWriteResponse, TId = string> = ReadArchivist<TReadResponse, TId> & WriteArchivist<TWriteResponse, TWrite>
|
|
@@ -35,7 +35,7 @@ describe('XyoArchivistPayloadApi', () => {
|
|
|
35
35
|
} catch (ex) {
|
|
36
36
|
const error = ex as XyoApiError
|
|
37
37
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
38
|
-
|
|
38
|
+
expect(error === undefined)
|
|
39
39
|
}
|
|
40
40
|
})
|
|
41
41
|
})
|
|
@@ -54,7 +54,7 @@ describe('XyoArchivistPayloadApi', () => {
|
|
|
54
54
|
} catch (ex) {
|
|
55
55
|
const error = ex as XyoApiError
|
|
56
56
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
57
|
-
|
|
57
|
+
expect(error === undefined)
|
|
58
58
|
}
|
|
59
59
|
})
|
|
60
60
|
})
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
+
import { XyoAccount } from '@xyo-network/account'
|
|
3
|
+
import { XyoBoundWitnessWithPartialMeta } from '@xyo-network/boundwitness'
|
|
4
|
+
|
|
5
|
+
import { XyoArchivistApi } from './Api'
|
|
6
|
+
import { XyoPayloadFindFilter } from './Payload'
|
|
7
|
+
import { XyoArchivist } from './XyoArchivist'
|
|
8
|
+
|
|
9
|
+
export class XyoApiArchivist extends XyoArchivist {
|
|
10
|
+
protected api: XyoArchivistApi
|
|
11
|
+
protected archive: string
|
|
12
|
+
constructor(api: XyoArchivistApi, archive: string, parent?: XyoArchivist, account?: XyoAccount) {
|
|
13
|
+
super(parent, account)
|
|
14
|
+
this.api = api
|
|
15
|
+
this.archive = archive
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public async get(hash: string) {
|
|
19
|
+
const [payloads] = await this.api.archive(this.archive).payload.hash(hash).get('tuple')
|
|
20
|
+
return payloads?.pop()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async insert(payload: XyoBoundWitnessWithPartialMeta) {
|
|
24
|
+
return (await this.api.archive(this.archive).block.post([payload]))?.map((value) => assertEx(value._hash)) ?? []
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async find(filter: XyoPayloadFindFilter) {
|
|
28
|
+
const [payloads = []] = (await this.api.archive(this.archive).payload.find(filter, 'tuple')) ?? []
|
|
29
|
+
const [blocks = []] = (await this.api.archive(this.archive).block.find(filter, 'tuple')) ?? []
|
|
30
|
+
return payloads.concat(blocks)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
+
import { XyoAccount } from '@xyo-network/account'
|
|
3
|
+
import { XyoBoundWitness, XyoBoundWitnessBuilder, XyoBoundWitnessWithPartialMeta } from '@xyo-network/boundwitness'
|
|
4
|
+
import { XyoPayload, XyoPayloadWithPartialMeta } from '@xyo-network/payload'
|
|
5
|
+
|
|
6
|
+
import { Archivist } from './Model'
|
|
7
|
+
import { XyoPayloadFindFilter } from './Payload'
|
|
8
|
+
|
|
9
|
+
export abstract class XyoArchivist<TWrite extends XyoBoundWitness = XyoBoundWitnessWithPartialMeta, TRead extends XyoPayload = XyoPayloadWithPartialMeta>
|
|
10
|
+
implements Archivist<string[], TWrite, TRead | undefined, string, TRead[], XyoPayloadFindFilter>
|
|
11
|
+
{
|
|
12
|
+
protected parent?: XyoArchivist
|
|
13
|
+
protected account?: XyoAccount
|
|
14
|
+
constructor(parent?: XyoArchivist, account?: XyoAccount) {
|
|
15
|
+
this.parent = parent
|
|
16
|
+
this.account = account
|
|
17
|
+
}
|
|
18
|
+
abstract insert(item: TWrite): string[] | Promise<string[]>
|
|
19
|
+
abstract find(query: XyoPayloadFindFilter): TRead[] | Promise<TRead[]>
|
|
20
|
+
abstract get(hash: string): TRead | Promise<TRead | undefined> | undefined
|
|
21
|
+
public all(): TRead[] | Promise<TRead[] | undefined> | undefined {
|
|
22
|
+
throw Error('getAll not supported')
|
|
23
|
+
}
|
|
24
|
+
public delete(_hash: string): boolean | Promise<boolean> {
|
|
25
|
+
throw Error('delete not supported')
|
|
26
|
+
}
|
|
27
|
+
public clear(): void | Promise<void> {
|
|
28
|
+
throw Error('clear not supported')
|
|
29
|
+
}
|
|
30
|
+
public async commit() {
|
|
31
|
+
const parent = assertEx(this.parent, 'Parent is required for commit')
|
|
32
|
+
const account = assertEx(this.account, 'Account is required for commit')
|
|
33
|
+
const payloads = assertEx(await parent.all(), 'Nothing to commit')
|
|
34
|
+
const builder = new XyoBoundWitnessBuilder()
|
|
35
|
+
const block = builder.payloads(payloads).witness(account).build()
|
|
36
|
+
const [hash] = await parent.insert(block)
|
|
37
|
+
await this.clear()
|
|
38
|
+
return hash
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { XyoBoundWitnessWithMeta, XyoBoundWitnessWrapper } from '@xyo-network/boundwitness'
|
|
2
|
+
import { XyoPayload, XyoPayloadWithPartialMeta, XyoPayloadWrapper } from '@xyo-network/payload'
|
|
3
|
+
import LruCache from 'lru-cache'
|
|
4
|
+
|
|
5
|
+
import { XyoPayloadFindFilter } from './Payload'
|
|
6
|
+
import { XyoArchivist } from './XyoArchivist'
|
|
7
|
+
|
|
8
|
+
export class XyoMemoryArchivist extends XyoArchivist {
|
|
9
|
+
private cache: LruCache<string, XyoPayloadWithPartialMeta> = new LruCache<string, XyoPayloadWithPartialMeta>({ max: 10000 })
|
|
10
|
+
|
|
11
|
+
public delete(hash: string) {
|
|
12
|
+
return this.cache.delete(hash)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public clear() {
|
|
16
|
+
this.cache.clear()
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public get(hash: string) {
|
|
20
|
+
return this.cache.get(hash) ?? this.parent?.get(hash)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public insert(payload: XyoBoundWitnessWithMeta) {
|
|
24
|
+
const wrapper = new XyoBoundWitnessWrapper(payload)
|
|
25
|
+
const payloadWithmeta = { ...payload, _hash: wrapper.hash, _timestamp: Date.now() }
|
|
26
|
+
const hashes: string[] = []
|
|
27
|
+
hashes.push(payloadWithmeta._hash)
|
|
28
|
+
this.cache.set(payloadWithmeta._hash, payloadWithmeta)
|
|
29
|
+
payload._payloads?.forEach((payload) => {
|
|
30
|
+
const wrapper = new XyoPayloadWrapper(payload)
|
|
31
|
+
const payloadWithmeta = { ...payload, _hash: wrapper.hash, _timestamp: Date.now() }
|
|
32
|
+
hashes.push(payloadWithmeta._hash)
|
|
33
|
+
this.cache.set(payloadWithmeta._hash, payloadWithmeta)
|
|
34
|
+
})
|
|
35
|
+
return hashes
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public find<T extends XyoPayload = XyoPayload>(filter: XyoPayloadFindFilter): T[] {
|
|
39
|
+
const result: T[] = []
|
|
40
|
+
if (filter.type === 'schema') {
|
|
41
|
+
const filterSchema = filter.schema !== undefined ? (Array.isArray(filter.schema) ? filter.schema : [filter.schema]) : undefined
|
|
42
|
+
this.cache.forEach((value) => {
|
|
43
|
+
let match: XyoPayload | undefined = value
|
|
44
|
+
match = filterSchema === undefined || filterSchema.includes(value.schema) ? value : undefined
|
|
45
|
+
if (match) {
|
|
46
|
+
result.push(match as T)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
if (filter.type === 'hash') {
|
|
51
|
+
const filterHash = filter.hash !== undefined ? (Array.isArray(filter.hash) ? filter.hash : [filter.hash]) : undefined
|
|
52
|
+
this.cache.forEach((value) => {
|
|
53
|
+
let match: XyoPayload | undefined = value
|
|
54
|
+
match = filterHash === undefined || filterHash.includes(new XyoPayloadWrapper(value).hash) ? value : undefined
|
|
55
|
+
if (match) {
|
|
56
|
+
result.push(match as T)
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
return result
|
|
61
|
+
}
|
|
62
|
+
}
|
package/src/Archivist/index.ts
CHANGED
|
@@ -68,7 +68,7 @@ describeSkipIfNoDiviner('XyoLocationDivinerApi', () => {
|
|
|
68
68
|
} catch (ex) {
|
|
69
69
|
const error = ex as AxiosError
|
|
70
70
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
71
|
-
|
|
71
|
+
expect(error === undefined)
|
|
72
72
|
}
|
|
73
73
|
})
|
|
74
74
|
it('posts a location time range query', async () => {
|
|
@@ -80,7 +80,7 @@ describeSkipIfNoDiviner('XyoLocationDivinerApi', () => {
|
|
|
80
80
|
} catch (ex) {
|
|
81
81
|
const error = ex as AxiosError
|
|
82
82
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
83
|
-
|
|
83
|
+
expect(error === undefined)
|
|
84
84
|
}
|
|
85
85
|
})
|
|
86
86
|
})
|
|
@@ -94,7 +94,7 @@ describeSkipIfNoDiviner('XyoLocationDivinerApi', () => {
|
|
|
94
94
|
} catch (ex) {
|
|
95
95
|
const error = ex as AxiosError
|
|
96
96
|
console.log(JSON.stringify(error.response?.data, null, 2))
|
|
97
|
-
|
|
97
|
+
expect(error === undefined)
|
|
98
98
|
}
|
|
99
99
|
})
|
|
100
100
|
})
|