@xyo-network/archivist 2.22.11 → 2.22.14
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/README.md +4 -2
- package/dist/cjs/XyoMemoryArchivist.d.ts +12 -6
- package/dist/cjs/XyoMemoryArchivist.js +7 -3
- package/dist/cjs/XyoMemoryArchivist.js.map +1 -1
- package/dist/cjs/model/Archivist.d.ts +21 -7
- package/dist/docs.json +3338 -1
- package/dist/esm/XyoMemoryArchivist.d.ts +12 -6
- package/dist/esm/XyoMemoryArchivist.js +6 -3
- package/dist/esm/XyoMemoryArchivist.js.map +1 -1
- package/dist/esm/model/Archivist.d.ts +21 -7
- package/package.json +6 -9
- package/src/XyoMemoryArchivist.ts +23 -6
- package/src/model/Archivist.ts +29 -7
- package/babel.config.json +0 -5
- package/dist/cjs/XyoBoundWitnessArchivist.d.ts +0 -6
- package/dist/cjs/XyoBoundWitnessArchivist.js +0 -23
- package/dist/cjs/XyoBoundWitnessArchivist.js.map +0 -1
- package/dist/cjs/XyoBoundWitnessMemoryArchivist.d.ts +0 -12
- package/dist/cjs/XyoBoundWitnessMemoryArchivist.js +0 -51
- package/dist/cjs/XyoBoundWitnessMemoryArchivist.js.map +0 -1
- package/dist/esm/XyoArchivistBase.d.ts +0 -13
- package/dist/esm/XyoArchivistBase.js +0 -16
- package/dist/esm/XyoArchivistBase.js.map +0 -1
- package/dist/esm/XyoBoundWitnessArchivist.d.ts +0 -6
- package/dist/esm/XyoBoundWitnessArchivist.js +0 -15
- package/dist/esm/XyoBoundWitnessArchivist.js.map +0 -1
- package/dist/esm/XyoBoundWitnessMemoryArchivist.d.ts +0 -12
- package/dist/esm/XyoBoundWitnessMemoryArchivist.js +0 -44
- package/dist/esm/XyoBoundWitnessMemoryArchivist.js.map +0 -1
- package/jest.config.cjs +0 -26
package/README.md
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
[![codeclimate-badge][]][codeclimate-link]
|
|
11
11
|
[![snyk-badge][]][snyk-link]
|
|
12
12
|
|
|
13
|
-
> The XYO Foundation provides this source code available in our efforts to
|
|
13
|
+
> The XYO Foundation provides this source code available in our efforts to
|
|
14
|
+
> advance the understanding of the XYO Protocol and its possible uses.
|
|
14
15
|
> We continue to maintain this software in the interest of developer education.
|
|
15
16
|
> Usage of this source code is not intended for production.
|
|
16
17
|
|
|
@@ -25,7 +26,8 @@
|
|
|
25
26
|
|
|
26
27
|
## Description
|
|
27
28
|
|
|
28
|
-
> Primary SDK for using the XYO Protocol 2.0 from TypeScript/JavaScript.
|
|
29
|
+
> Primary SDK for using the XYO Protocol 2.0 from TypeScript/JavaScript.
|
|
30
|
+
> Designed to work in both browser based and Node JS based solutions.
|
|
29
31
|
|
|
30
32
|
## Install
|
|
31
33
|
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import { XyoPayload } from '@xyo-network/payload';
|
|
2
|
+
import { PromisableArray } from './model';
|
|
2
3
|
import { XyoArchivist } from './XyoArchivist';
|
|
3
|
-
import { XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
4
|
+
import { XyoArchivistConfig, XyoArchivistConfigWrapper } from './XyoArchivistConfig';
|
|
4
5
|
import { XyoPayloadFindQuery } from './XyoPayloadFindFilter';
|
|
5
|
-
export
|
|
6
|
+
export interface XyoMemoryArchivistConfig<T extends XyoPayload = XyoPayload> extends XyoArchivistConfig<T> {
|
|
7
|
+
max?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class XyoMemoryArchivist<C extends XyoMemoryArchivistConfig<XyoPayload> = XyoMemoryArchivistConfig<XyoPayload>> extends XyoArchivistConfigWrapper<XyoPayload, C> implements XyoArchivist {
|
|
10
|
+
get max(): number;
|
|
6
11
|
private cache;
|
|
7
|
-
|
|
12
|
+
constructor(config?: C);
|
|
13
|
+
delete(hashes: string[]): PromisableArray<boolean>;
|
|
8
14
|
clear(): void | Promise<void>;
|
|
9
15
|
get(hashes: string[]): Promise<(XyoPayload | null)[]>;
|
|
10
|
-
insert(payloads: XyoPayload[]):
|
|
11
|
-
find<R extends XyoPayload = XyoPayload>(query: XyoPayloadFindQuery):
|
|
16
|
+
insert(payloads: XyoPayload[]): PromisableArray<XyoPayload>;
|
|
17
|
+
find<R extends XyoPayload = XyoPayload>(query: XyoPayloadFindQuery): PromisableArray<R>;
|
|
12
18
|
all(): Promise<XyoPayload[]> | XyoPayload[];
|
|
13
|
-
commit(): Promise<import("@xyo-network/payload").XyoPayloadBase[]
|
|
19
|
+
commit(): Promise<import("@xyo-network/payload").XyoPayloadBase[]>;
|
|
14
20
|
}
|
|
@@ -8,9 +8,13 @@ const payload_1 = require("@xyo-network/payload");
|
|
|
8
8
|
const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
|
|
9
9
|
const XyoArchivistConfig_1 = require("./XyoArchivistConfig");
|
|
10
10
|
class XyoMemoryArchivist extends XyoArchivistConfig_1.XyoArchivistConfigWrapper {
|
|
11
|
-
constructor() {
|
|
12
|
-
super(
|
|
13
|
-
this.cache = new lru_cache_1.default({ max:
|
|
11
|
+
constructor(config) {
|
|
12
|
+
super(config);
|
|
13
|
+
this.cache = new lru_cache_1.default({ max: this.max });
|
|
14
|
+
}
|
|
15
|
+
get max() {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
return (_b = (_a = this.config) === null || _a === void 0 ? void 0 : _a.max) !== null && _b !== void 0 ? _b : 10000;
|
|
14
18
|
}
|
|
15
19
|
delete(hashes) {
|
|
16
20
|
return hashes.map((hash) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../src/XyoMemoryArchivist.ts"],"names":[],"mappings":";;;;AAAA,2CAAyC;AACzC,4DAAmF;AACnF,kDAAoE;AACpE,kEAAgC;
|
|
1
|
+
{"version":3,"file":"XyoMemoryArchivist.js","sourceRoot":"","sources":["../../src/XyoMemoryArchivist.ts"],"names":[],"mappings":";;;;AAAA,2CAAyC;AACzC,4DAAm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C,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA,CAAA;YAC9D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAClB,OAAO,MAAM,CAAA;;KACd;CACF;AAlED,gDAkEC"}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export declare type Promisable<T> = Promise<T> | T;
|
|
2
|
+
export declare type PromisableArray<T> = Promisable<T[]>;
|
|
3
|
+
export declare type OptionalPromisable<T> = Promisable<T | undefined>;
|
|
4
|
+
export declare type OptionalPromisableArray<T> = PromisableArray<T | undefined>;
|
|
5
|
+
export declare type NullablePromisable<T> = Promisable<T | null>;
|
|
6
|
+
export declare type NullablePromisableArray<T> = PromisableArray<T | null>;
|
|
7
|
+
export interface ReadArchivist<TReadResponse, TId = string> {
|
|
8
|
+
get(ids: TId[]): NullablePromisableArray<TReadResponse>;
|
|
9
|
+
all?(): PromisableArray<TReadResponse>;
|
|
10
|
+
}
|
|
11
|
+
export interface WriteArchivist<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TId = string> {
|
|
12
|
+
insert(item: TWrite[]): PromisableArray<TWriteResponse>;
|
|
13
|
+
delete?(ids: TId[]): PromisableArray<boolean>;
|
|
7
14
|
clear?(): void;
|
|
8
|
-
|
|
15
|
+
}
|
|
16
|
+
export interface QueryArchivist<TReadResponse, TQueryResponse = TReadResponse, TQuery = unknown> {
|
|
17
|
+
find(query: TQuery): PromisableArray<TQueryResponse>;
|
|
18
|
+
}
|
|
19
|
+
export interface StashArchivist<TReadResponse> {
|
|
20
|
+
commit?(): PromisableArray<TReadResponse>;
|
|
21
|
+
}
|
|
22
|
+
export interface Archivist<TReadResponse, TWriteResponse = TReadResponse, TWrite = TReadResponse, TQueryResponse = TReadResponse, TQuery = unknown, TId = string> extends ReadArchivist<TReadResponse, TId>, QueryArchivist<TReadResponse, TQueryResponse, TQuery>, WriteArchivist<TReadResponse, TWriteResponse, TWrite, TId>, StashArchivist<TReadResponse> {
|
|
9
23
|
}
|