@based/db 0.0.1
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 +43 -0
- package/dist/lib/darwin_aarch64/include/cdefs.h +317 -0
- package/dist/lib/darwin_aarch64/include/libdeflate.h +322 -0
- package/dist/lib/darwin_aarch64/include/libdeflate_strings.h +35 -0
- package/dist/lib/darwin_aarch64/include/linker_set.h +109 -0
- package/dist/lib/darwin_aarch64/include/queue.h +627 -0
- package/dist/lib/darwin_aarch64/include/selva/_export.h +7 -0
- package/dist/lib/darwin_aarch64/include/selva/align.h +9 -0
- package/dist/lib/darwin_aarch64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/darwin_aarch64/include/selva/base64.h +59 -0
- package/dist/lib/darwin_aarch64/include/selva/base64url.h +59 -0
- package/dist/lib/darwin_aarch64/include/selva/bitmap.h +95 -0
- package/dist/lib/darwin_aarch64/include/selva/crc32c.h +17 -0
- package/dist/lib/darwin_aarch64/include/selva/ctime.h +135 -0
- package/dist/lib/darwin_aarch64/include/selva/db.h +284 -0
- package/dist/lib/darwin_aarch64/include/selva/endian.h +301 -0
- package/dist/lib/darwin_aarch64/include/selva/fast_linear_search.h +23 -0
- package/dist/lib/darwin_aarch64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/darwin_aarch64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/darwin_aarch64/include/selva/fields.h +338 -0
- package/dist/lib/darwin_aarch64/include/selva/find.h +47 -0
- package/dist/lib/darwin_aarch64/include/selva/lpf.h +28 -0
- package/dist/lib/darwin_aarch64/include/selva/node_id_set.h +43 -0
- package/dist/lib/darwin_aarch64/include/selva/poptop.h +114 -0
- package/dist/lib/darwin_aarch64/include/selva/queue_r.h +190 -0
- package/dist/lib/darwin_aarch64/include/selva/selva_hash128.h +39 -0
- package/dist/lib/darwin_aarch64/include/selva/selva_lang.h +105 -0
- package/dist/lib/darwin_aarch64/include/selva/selva_math.h +37 -0
- package/dist/lib/darwin_aarch64/include/selva/selva_string.h +672 -0
- package/dist/lib/darwin_aarch64/include/selva/sort.h +119 -0
- package/dist/lib/darwin_aarch64/include/selva/strsearch.h +43 -0
- package/dist/lib/darwin_aarch64/include/selva/timestamp.h +25 -0
- package/dist/lib/darwin_aarch64/include/selva/traverse.h +65 -0
- package/dist/lib/darwin_aarch64/include/selva/types.h +110 -0
- package/dist/lib/darwin_aarch64/include/selva/vector.h +14 -0
- package/dist/lib/darwin_aarch64/include/selva/worker_ctx.h +13 -0
- package/dist/lib/darwin_aarch64/include/selva_error.h +137 -0
- package/dist/lib/darwin_aarch64/include/selva_lang_code.h +157 -0
- package/dist/lib/darwin_aarch64/include/tree.h +852 -0
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.8.0.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.0.8.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.0.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +317 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +322 -0
- package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
- package/dist/lib/linux_aarch64/include/queue.h +627 -0
- package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
- package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
- package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_aarch64/include/selva/base64.h +59 -0
- package/dist/lib/linux_aarch64/include/selva/base64url.h +59 -0
- package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +284 -0
- package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +23 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +338 -0
- package/dist/lib/linux_aarch64/include/selva/find.h +47 -0
- package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_aarch64/include/selva/queue_r.h +190 -0
- package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +39 -0
- package/dist/lib/linux_aarch64/include/selva/selva_lang.h +105 -0
- package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +672 -0
- package/dist/lib/linux_aarch64/include/selva/sort.h +119 -0
- package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_aarch64/include/selva/traverse.h +65 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +110 -0
- package/dist/lib/linux_aarch64/include/selva/vector.h +14 -0
- package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +13 -0
- package/dist/lib/linux_aarch64/include/selva_error.h +137 -0
- package/dist/lib/linux_aarch64/include/selva_lang_code.h +157 -0
- package/dist/lib/linux_aarch64/include/tree.h +852 -0
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0.8.2 +0 -0
- package/dist/lib/linux_x86_64/include/cdefs.h +317 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +322 -0
- package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
- package/dist/lib/linux_x86_64/include/queue.h +627 -0
- package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
- package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
- package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_x86_64/include/selva/base64.h +59 -0
- package/dist/lib/linux_x86_64/include/selva/base64url.h +59 -0
- package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +284 -0
- package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +23 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +338 -0
- package/dist/lib/linux_x86_64/include/selva/find.h +47 -0
- package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_x86_64/include/selva/queue_r.h +190 -0
- package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +39 -0
- package/dist/lib/linux_x86_64/include/selva/selva_lang.h +105 -0
- package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +672 -0
- package/dist/lib/linux_x86_64/include/selva/sort.h +119 -0
- package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_x86_64/include/selva/traverse.h +65 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +110 -0
- package/dist/lib/linux_x86_64/include/selva/vector.h +14 -0
- package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +13 -0
- package/dist/lib/linux_x86_64/include/selva_error.h +137 -0
- package/dist/lib/linux_x86_64/include/selva_lang_code.h +157 -0
- package/dist/lib/linux_x86_64/include/tree.h +852 -0
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0.8.2 +0 -0
- package/dist/src/client/crc32.d.ts +1 -0
- package/dist/src/client/crc32.js +281 -0
- package/dist/src/client/index.d.ts +58 -0
- package/dist/src/client/index.js +120 -0
- package/dist/src/client/modify/ModifyRes.d.ts +26 -0
- package/dist/src/client/modify/ModifyRes.js +98 -0
- package/dist/src/client/modify/alias.d.ts +4 -0
- package/dist/src/client/modify/alias.js +47 -0
- package/dist/src/client/modify/binary.d.ts +6 -0
- package/dist/src/client/modify/binary.js +61 -0
- package/dist/src/client/modify/create.d.ts +4 -0
- package/dist/src/client/modify/create.js +108 -0
- package/dist/src/client/modify/fixed.d.ts +5 -0
- package/dist/src/client/modify/fixed.js +118 -0
- package/dist/src/client/modify/hll.d.ts +4 -0
- package/dist/src/client/modify/hll.js +58 -0
- package/dist/src/client/modify/index.d.ts +4 -0
- package/dist/src/client/modify/index.js +4 -0
- package/dist/src/client/modify/modify.d.ts +5 -0
- package/dist/src/client/modify/modify.js +126 -0
- package/dist/src/client/modify/references/edge.d.ts +6 -0
- package/dist/src/client/modify/references/edge.js +158 -0
- package/dist/src/client/modify/references/reference.d.ts +11 -0
- package/dist/src/client/modify/references/reference.js +92 -0
- package/dist/src/client/modify/references/references.d.ts +17 -0
- package/dist/src/client/modify/references/references.js +271 -0
- package/dist/src/client/modify/remove.d.ts +2 -0
- package/dist/src/client/modify/remove.js +36 -0
- package/dist/src/client/modify/setCursor.d.ts +4 -0
- package/dist/src/client/modify/setCursor.js +36 -0
- package/dist/src/client/modify/string.d.ts +5 -0
- package/dist/src/client/modify/string.js +56 -0
- package/dist/src/client/modify/text.d.ts +5 -0
- package/dist/src/client/modify/text.js +14 -0
- package/dist/src/client/modify/types.d.ts +14 -0
- package/dist/src/client/modify/types.js +12 -0
- package/dist/src/client/modify/update.d.ts +5 -0
- package/dist/src/client/modify/update.js +80 -0
- package/dist/src/client/modify/upsert.d.ts +2 -0
- package/dist/src/client/modify/upsert.js +40 -0
- package/dist/src/client/operations.d.ts +31 -0
- package/dist/src/client/operations.js +110 -0
- package/dist/src/client/query/BasedDbQuery.d.ts +40 -0
- package/dist/src/client/query/BasedDbQuery.js +235 -0
- package/dist/src/client/query/BasedIterable.d.ts +26 -0
- package/dist/src/client/query/BasedIterable.js +113 -0
- package/dist/src/client/query/debug.d.ts +3 -0
- package/dist/src/client/query/debug.js +117 -0
- package/dist/src/client/query/display.d.ts +5 -0
- package/dist/src/client/query/display.js +233 -0
- package/dist/src/client/query/filter/FilterBranch.d.ts +13 -0
- package/dist/src/client/query/filter/FilterBranch.js +29 -0
- package/dist/src/client/query/filter/createFixedFilterBuffer.d.ts +3 -0
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +101 -0
- package/dist/src/client/query/filter/createReferenceFilter.d.ts +2 -0
- package/dist/src/client/query/filter/createReferenceFilter.js +24 -0
- package/dist/src/client/query/filter/createVariableFilterBuffer.d.ts +2 -0
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +81 -0
- package/dist/src/client/query/filter/filter.d.ts +10 -0
- package/dist/src/client/query/filter/filter.js +134 -0
- package/dist/src/client/query/filter/operators.d.ts +6 -0
- package/dist/src/client/query/filter/operators.js +98 -0
- package/dist/src/client/query/filter/parseFilterValue.d.ts +2 -0
- package/dist/src/client/query/filter/parseFilterValue.js +99 -0
- package/dist/src/client/query/filter/primitiveFilter.d.ts +4 -0
- package/dist/src/client/query/filter/primitiveFilter.js +47 -0
- package/dist/src/client/query/filter/toBuffer.d.ts +3 -0
- package/dist/src/client/query/filter/toBuffer.js +100 -0
- package/dist/src/client/query/filter/types.d.ts +6 -0
- package/dist/src/client/query/filter/types.js +7 -0
- package/dist/src/client/query/include/props.d.ts +6 -0
- package/dist/src/client/query/include/props.js +44 -0
- package/dist/src/client/query/include/toBuffer.d.ts +3 -0
- package/dist/src/client/query/include/toBuffer.js +82 -0
- package/dist/src/client/query/include/utils.d.ts +6 -0
- package/dist/src/client/query/include/utils.js +41 -0
- package/dist/src/client/query/include/walk.d.ts +3 -0
- package/dist/src/client/query/include/walk.js +70 -0
- package/dist/src/client/query/query.d.ts +10 -0
- package/dist/src/client/query/query.js +11 -0
- package/dist/src/client/query/queryDef.d.ts +3 -0
- package/dist/src/client/query/queryDef.js +54 -0
- package/dist/src/client/query/read/read.d.ts +8 -0
- package/dist/src/client/query/read/read.js +303 -0
- package/dist/src/client/query/registerQuery.d.ts +2 -0
- package/dist/src/client/query/registerQuery.js +31 -0
- package/dist/src/client/query/search/index.d.ts +6 -0
- package/dist/src/client/query/search/index.js +82 -0
- package/dist/src/client/query/sort.d.ts +3 -0
- package/dist/src/client/query/sort.js +18 -0
- package/dist/src/client/query/subscription/index.d.ts +5 -0
- package/dist/src/client/query/subscription/index.js +52 -0
- package/dist/src/client/query/subscription/markers.d.ts +10 -0
- package/dist/src/client/query/subscription/markers.js +213 -0
- package/dist/src/client/query/subscription/run.d.ts +5 -0
- package/dist/src/client/query/subscription/run.js +69 -0
- package/dist/src/client/query/subscription/types.d.ts +33 -0
- package/dist/src/client/query/subscription/types.js +3 -0
- package/dist/src/client/query/thresholds.d.ts +6 -0
- package/dist/src/client/query/thresholds.js +16 -0
- package/dist/src/client/query/toBuffer.d.ts +3 -0
- package/dist/src/client/query/toBuffer.js +229 -0
- package/dist/src/client/query/types.d.ts +88 -0
- package/dist/src/client/query/types.js +15 -0
- package/dist/src/client/query/validation.d.ts +15 -0
- package/dist/src/client/query/validation.js +59 -0
- package/dist/src/client/string.d.ts +5 -0
- package/dist/src/client/string.js +73 -0
- package/dist/src/client/tree.d.ts +1 -0
- package/dist/src/client/tree.js +5 -0
- package/dist/src/index.d.ts +31 -0
- package/dist/src/index.js +85 -0
- package/dist/src/native.d.ts +28 -0
- package/dist/src/native.js +96 -0
- package/dist/src/server/csmt/draw-dot.d.ts +2 -0
- package/dist/src/server/csmt/draw-dot.js +32 -0
- package/dist/src/server/csmt/index.d.ts +4 -0
- package/dist/src/server/csmt/index.js +5 -0
- package/dist/src/server/csmt/match.d.ts +7 -0
- package/dist/src/server/csmt/match.js +10 -0
- package/dist/src/server/csmt/memebership-proof.d.ts +7 -0
- package/dist/src/server/csmt/memebership-proof.js +122 -0
- package/dist/src/server/csmt/tree-utils.d.ts +6 -0
- package/dist/src/server/csmt/tree-utils.js +33 -0
- package/dist/src/server/csmt/tree.d.ts +2 -0
- package/dist/src/server/csmt/tree.js +209 -0
- package/dist/src/server/csmt/types.d.ts +40 -0
- package/dist/src/server/csmt/types.js +2 -0
- package/dist/src/server/index.d.ts +85 -0
- package/dist/src/server/index.js +407 -0
- package/dist/src/server/migrate/index.d.ts +7 -0
- package/dist/src/server/migrate/index.js +108 -0
- package/dist/src/server/migrate/worker.d.ts +1 -0
- package/dist/src/server/migrate/worker.js +81 -0
- package/dist/src/server/save.d.ts +2 -0
- package/dist/src/server/save.js +66 -0
- package/dist/src/server/schema/schema.d.ts +3 -0
- package/dist/src/server/schema/schema.js +4 -0
- package/dist/src/server/schema/selvaBuffer.d.ts +4 -0
- package/dist/src/server/schema/selvaBuffer.js +102 -0
- package/dist/src/server/schema/typeDef.d.ts +6 -0
- package/dist/src/server/schema/typeDef.js +315 -0
- package/dist/src/server/schema/types.d.ts +127 -0
- package/dist/src/server/schema/types.js +113 -0
- package/dist/src/server/schema/utils.d.ts +6 -0
- package/dist/src/server/schema/utils.js +21 -0
- package/dist/src/server/start.d.ts +6 -0
- package/dist/src/server/start.js +86 -0
- package/dist/src/server/tree.d.ts +13 -0
- package/dist/src/server/tree.js +33 -0
- package/dist/src/server/worker.d.ts +1 -0
- package/dist/src/server/worker.js +35 -0
- package/package.json +48 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PropDef, PropDefEdge, SchemaTypeDef } from '../../server/schema/schema.js';
|
|
2
|
+
export type MainIncludes = {
|
|
3
|
+
[start: string]: [number, PropDef];
|
|
4
|
+
};
|
|
5
|
+
export type IncludeTreeArr = (string | PropDef | IncludeTreeArr)[];
|
|
6
|
+
declare enum QueryDefType {
|
|
7
|
+
Edge = 1,
|
|
8
|
+
Reference = 2,
|
|
9
|
+
References = 3,
|
|
10
|
+
Root = 4
|
|
11
|
+
}
|
|
12
|
+
export type EdgeTarget = {
|
|
13
|
+
ref: PropDef | PropDefEdge | null;
|
|
14
|
+
};
|
|
15
|
+
export type Target = {
|
|
16
|
+
type: string;
|
|
17
|
+
id?: number | void;
|
|
18
|
+
ids?: Uint32Array | void;
|
|
19
|
+
propDef?: PropDef | PropDefEdge;
|
|
20
|
+
alias?: QueryByAliasObj;
|
|
21
|
+
};
|
|
22
|
+
export declare const isRefDef: (def: QueryDef) => def is QueryDefRest;
|
|
23
|
+
export type QueryDefFilter = {
|
|
24
|
+
size: number;
|
|
25
|
+
conditions: Map<number, Buffer[]>;
|
|
26
|
+
references?: Map<number, QueryDefFilter>;
|
|
27
|
+
fromRef?: PropDef;
|
|
28
|
+
schema?: SchemaTypeDef;
|
|
29
|
+
edges?: Map<number, Buffer[]>;
|
|
30
|
+
or?: QueryDefFilter;
|
|
31
|
+
and?: QueryDefFilter;
|
|
32
|
+
};
|
|
33
|
+
export type QueryDefSearch = {
|
|
34
|
+
size: number;
|
|
35
|
+
query: Buffer;
|
|
36
|
+
fields: {
|
|
37
|
+
weight: number;
|
|
38
|
+
field: number;
|
|
39
|
+
start: number;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
export type QueryDefSort = {
|
|
43
|
+
prop: PropDefEdge | PropDef;
|
|
44
|
+
order: 0 | 1;
|
|
45
|
+
};
|
|
46
|
+
export type QueryDefShared = {
|
|
47
|
+
filter: QueryDefFilter;
|
|
48
|
+
search: null | QueryDefSearch;
|
|
49
|
+
sort: null | QueryDefSort;
|
|
50
|
+
reverseProps: any;
|
|
51
|
+
range: {
|
|
52
|
+
offset: number;
|
|
53
|
+
limit: number;
|
|
54
|
+
};
|
|
55
|
+
include: {
|
|
56
|
+
stringFields: Set<string>;
|
|
57
|
+
props: Set<number>;
|
|
58
|
+
propsRead: {
|
|
59
|
+
[propName: number]: number;
|
|
60
|
+
};
|
|
61
|
+
main: {
|
|
62
|
+
include: MainIncludes;
|
|
63
|
+
len: number;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
references: Map<number, QueryDef>;
|
|
67
|
+
edges?: QueryDef;
|
|
68
|
+
};
|
|
69
|
+
export type QueryDefEdges = {
|
|
70
|
+
type: QueryDefType.Edge;
|
|
71
|
+
target: EdgeTarget;
|
|
72
|
+
schema: null;
|
|
73
|
+
props: PropDef['edges'];
|
|
74
|
+
reverseProps: PropDef['edges'];
|
|
75
|
+
} & QueryDefShared;
|
|
76
|
+
export type QueryDefRest = {
|
|
77
|
+
type: QueryDefType.References | QueryDefType.Reference | QueryDefType.Root;
|
|
78
|
+
target: Target;
|
|
79
|
+
schema: SchemaTypeDef | null;
|
|
80
|
+
props: SchemaTypeDef['props'] | PropDef['edges'];
|
|
81
|
+
} & QueryDefShared;
|
|
82
|
+
export type QueryDef = QueryDefEdges | QueryDefRest;
|
|
83
|
+
export type QueryTarget = EdgeTarget | Target;
|
|
84
|
+
export { QueryDefType };
|
|
85
|
+
export type QueryByAliasObj = {
|
|
86
|
+
[key: string]: string | QueryByAliasObj;
|
|
87
|
+
};
|
|
88
|
+
export declare const isAlias: (id: QueryByAliasObj | number | (QueryByAliasObj | number)[]) => id is QueryByAliasObj;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var QueryDefType;
|
|
2
|
+
(function (QueryDefType) {
|
|
3
|
+
QueryDefType[QueryDefType["Edge"] = 1] = "Edge";
|
|
4
|
+
QueryDefType[QueryDefType["Reference"] = 2] = "Reference";
|
|
5
|
+
QueryDefType[QueryDefType["References"] = 3] = "References";
|
|
6
|
+
QueryDefType[QueryDefType["Root"] = 4] = "Root";
|
|
7
|
+
})(QueryDefType || (QueryDefType = {}));
|
|
8
|
+
export const isRefDef = (def) => {
|
|
9
|
+
return (def.type === QueryDefType.Reference || def.type === QueryDefType.References);
|
|
10
|
+
};
|
|
11
|
+
export { QueryDefType };
|
|
12
|
+
export const isAlias = (id) => {
|
|
13
|
+
return typeof id === 'object' && id !== null && !Array.isArray(id);
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropDef, PropDefEdge } from '../../server/schema/types.js';
|
|
2
|
+
import { Operator } from './filter/operators.js';
|
|
3
|
+
import { QueryByAliasObj } from './types.js';
|
|
4
|
+
export declare const isValidId: (id: number) => void;
|
|
5
|
+
export declare const checkMaxIdsPerQuery: (ids: (number | QueryByAliasObj)[]) => void;
|
|
6
|
+
export declare const checkMaxBufferSize: (buf: Buffer) => void;
|
|
7
|
+
export declare const checkTotalBufferSize: (bufers: Buffer[]) => void;
|
|
8
|
+
export declare const hasFields: (fields: {
|
|
9
|
+
[key: string]: PropDefEdge;
|
|
10
|
+
} | {
|
|
11
|
+
[path: string]: PropDef;
|
|
12
|
+
}) => void;
|
|
13
|
+
export declare const hasField: (field: string) => void;
|
|
14
|
+
export declare const checkOperator: (operator: Operator | boolean) => void;
|
|
15
|
+
export declare const checkValue: (value: any, operator: Operator) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { MAX_IDS_PER_QUERY, MIN_ID_VALUE, MAX_ID_VALUE, MAX_BUFFER_SIZE, } from './thresholds.js';
|
|
2
|
+
import { validOperators } from './filter/operators.js';
|
|
3
|
+
export const isValidId = (id) => {
|
|
4
|
+
if (typeof id != 'number') {
|
|
5
|
+
throw new Error('Id has to be a number');
|
|
6
|
+
}
|
|
7
|
+
else if (id < MIN_ID_VALUE || id > MAX_ID_VALUE) {
|
|
8
|
+
throw new Error(`Invalid Id: The Id should range between ${MIN_ID_VALUE} and ${MAX_ID_VALUE}.)`);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export const checkMaxIdsPerQuery = (ids) => {
|
|
12
|
+
if (ids.length > MAX_IDS_PER_QUERY) {
|
|
13
|
+
throw new Error(`The number of IDs cannot exceed ${MAX_IDS_PER_QUERY}.`);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export const checkMaxBufferSize = (buf) => {
|
|
17
|
+
if (buf.byteLength > MAX_BUFFER_SIZE) {
|
|
18
|
+
throw new Error(`The buffer size exceeds the maximum threshold of ${MAX_BUFFER_SIZE} bytes.` +
|
|
19
|
+
`Crrent size is ${buf.byteLength} bytes.`);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
export const checkTotalBufferSize = (bufers) => {
|
|
23
|
+
let totalSize = 0;
|
|
24
|
+
for (const buffer of bufers) {
|
|
25
|
+
totalSize += buffer.byteLength;
|
|
26
|
+
if (totalSize > MAX_BUFFER_SIZE) {
|
|
27
|
+
throw new Error(`The total buffer size exceeds the maximum threshold of ${MAX_BUFFER_SIZE} bytes.` +
|
|
28
|
+
`Crrent size is ${totalSize} bytes.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const hasFields = (fields) => {
|
|
33
|
+
if (Object.keys(fields).length === 0) {
|
|
34
|
+
throw new Error('No fields available to include');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const hasField = (field) => {
|
|
38
|
+
if (!field) {
|
|
39
|
+
throw new Error(`Invalid field: ${field}`);
|
|
40
|
+
}
|
|
41
|
+
else if (typeof field !== 'string' || field.trim() === '') {
|
|
42
|
+
throw new Error('Field must be a non-empty string');
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const checkOperator = (operator) => {
|
|
46
|
+
if (operator !== undefined &&
|
|
47
|
+
typeof operator !== 'boolean' &&
|
|
48
|
+
!validOperators.includes(operator)) {
|
|
49
|
+
throw new Error(`Invalid operator: ${operator}`);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
export const checkValue = (value, operator) => {
|
|
53
|
+
if (operator === '..' || operator === '!..') {
|
|
54
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
55
|
+
throw new Error(`Invalid value for operator ${operator}: expected an array with two elements`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { LangCode } from '@based/schema';
|
|
2
|
+
export declare const write: (buf: Buffer, value: string, offset: number, noCompression: boolean, lang?: LangCode) => number;
|
|
3
|
+
export declare const compress: (str: string) => Buffer;
|
|
4
|
+
export declare const decompress: (buf: Buffer) => string;
|
|
5
|
+
export declare const read: (buf: Buffer, offset: number, len: number) => string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import native from '../native.js';
|
|
2
|
+
// type 0 = no compression; 1 = deflate
|
|
3
|
+
// [lang] [type] [uncompressed size 4] [compressed string] [crc32]
|
|
4
|
+
// var cnt = 0
|
|
5
|
+
// var bytesSaved = 0
|
|
6
|
+
// make this into a package
|
|
7
|
+
// write the type Byte
|
|
8
|
+
export const write = (buf, value, offset, noCompression, lang) => {
|
|
9
|
+
value = value.normalize('NFKD');
|
|
10
|
+
buf[offset] = lang || 0;
|
|
11
|
+
// 50 maybe if lvl 1
|
|
12
|
+
if (value.length > 200 && !noCompression) {
|
|
13
|
+
const s = Buffer.byteLength(value, 'utf8');
|
|
14
|
+
buf.write(value, offset + 6 + s, 'utf8');
|
|
15
|
+
let crc = native.crc32(buf.subarray(offset + 6 + s, offset + 6 + 2 * s));
|
|
16
|
+
const size = native.compress(buf, offset + 6, s);
|
|
17
|
+
if (size === 0) {
|
|
18
|
+
buf[offset + 1] = 0; // not compressed
|
|
19
|
+
const len = buf.write(value, offset + 2, 'utf8');
|
|
20
|
+
buf[offset + len + 2] = crc;
|
|
21
|
+
buf[offset + len + 3] = crc >>>= 8;
|
|
22
|
+
buf[offset + len + 4] = crc >>>= 8;
|
|
23
|
+
buf[offset + len + 5] = crc >>>= 8;
|
|
24
|
+
return len + 6;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
buf[offset + 1] = 1; // compressed
|
|
28
|
+
buf.writeUInt32LE(s, offset + 2);
|
|
29
|
+
buf[offset + size + 6] = crc;
|
|
30
|
+
buf[offset + size + 7] = crc >>>= 8;
|
|
31
|
+
buf[offset + size + 8] = crc >>>= 8;
|
|
32
|
+
buf[offset + size + 9] = crc >>>= 8;
|
|
33
|
+
return size + 10; // 0 C 4 4
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
buf[offset + 1] = 0; // not compressed
|
|
38
|
+
const len = buf.write(value, offset + 2, 'utf8');
|
|
39
|
+
let crc = native.crc32(buf.subarray(offset + 2, offset + len + 2));
|
|
40
|
+
buf[offset + len + 2] = crc;
|
|
41
|
+
buf[offset + len + 3] = crc >>>= 8;
|
|
42
|
+
buf[offset + len + 4] = crc >>>= 8;
|
|
43
|
+
buf[offset + len + 5] = crc >>>= 8;
|
|
44
|
+
return len + 6;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
let tmpCompressBlock;
|
|
48
|
+
export const compress = (str) => {
|
|
49
|
+
if (!tmpCompressBlock || tmpCompressBlock.byteLength < str.length * 3) {
|
|
50
|
+
tmpCompressBlock = Buffer.allocUnsafe(str.length * 3);
|
|
51
|
+
}
|
|
52
|
+
const s = write(tmpCompressBlock, str, 0, false);
|
|
53
|
+
const nBuffer = Buffer.allocUnsafe(s);
|
|
54
|
+
tmpCompressBlock.copy(nBuffer, 0, 0, s);
|
|
55
|
+
return nBuffer;
|
|
56
|
+
};
|
|
57
|
+
export const decompress = (buf) => {
|
|
58
|
+
return read(buf, 0, buf.byteLength);
|
|
59
|
+
};
|
|
60
|
+
export const read = (buf, offset, len) => {
|
|
61
|
+
const type = buf[offset + 1];
|
|
62
|
+
if (type == 1) {
|
|
63
|
+
const origSize = buf.readUint32LE(offset + 2);
|
|
64
|
+
const newBuffer = Buffer.allocUnsafe(origSize);
|
|
65
|
+
native.decompress(buf, newBuffer, offset + 6, len - 6);
|
|
66
|
+
return newBuffer.toString('utf8');
|
|
67
|
+
}
|
|
68
|
+
else if (type == 0) {
|
|
69
|
+
return buf.toString('utf8', offset + 2, len + offset - 4);
|
|
70
|
+
}
|
|
71
|
+
return '';
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const makeCsmtKeyFromNodeId: (typeId: number, blockCapacity: number, nodeId: number) => number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { compress, decompress } from './client/string.js';
|
|
2
|
+
import { ModifyCtx } from './client/operations.js';
|
|
3
|
+
import { DbServer } from './server/index.js';
|
|
4
|
+
import { DbClient } from './client/index.js';
|
|
5
|
+
export * from './server/schema/typeDef.js';
|
|
6
|
+
export * from './client/modify/modify.js';
|
|
7
|
+
export { compress, decompress };
|
|
8
|
+
export { ModifyCtx };
|
|
9
|
+
export { DbClient, DbServer };
|
|
10
|
+
export declare class BasedDb {
|
|
11
|
+
client: DbClient;
|
|
12
|
+
server: DbServer;
|
|
13
|
+
fileSystemPath: string;
|
|
14
|
+
maxModifySize: number;
|
|
15
|
+
constructor({ path, maxModifySize, }: {
|
|
16
|
+
path: string;
|
|
17
|
+
maxModifySize?: number;
|
|
18
|
+
});
|
|
19
|
+
create: DbClient['create'];
|
|
20
|
+
update: DbClient['update'];
|
|
21
|
+
upsert: DbClient['upsert'];
|
|
22
|
+
remove: DbClient['remove'];
|
|
23
|
+
query: DbClient['query'];
|
|
24
|
+
putSchema: DbClient['putSchema'];
|
|
25
|
+
drain: DbClient['drain'];
|
|
26
|
+
start: DbServer['start'];
|
|
27
|
+
stop: DbServer['stop'];
|
|
28
|
+
save: DbServer['save'];
|
|
29
|
+
migrateSchema: DbServer['migrateSchema'];
|
|
30
|
+
destroy(): Promise<void>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { compress, decompress } from './client/string.js';
|
|
2
|
+
import { ModifyCtx } from './client/operations.js';
|
|
3
|
+
import { DbServer } from './server/index.js';
|
|
4
|
+
import { DbClient } from './client/index.js';
|
|
5
|
+
export * from './server/schema/typeDef.js';
|
|
6
|
+
export * from './client/modify/modify.js';
|
|
7
|
+
export { compress, decompress };
|
|
8
|
+
export { ModifyCtx }; // TODO move this somewhere
|
|
9
|
+
export { DbClient, DbServer };
|
|
10
|
+
export class BasedDb {
|
|
11
|
+
client;
|
|
12
|
+
server;
|
|
13
|
+
fileSystemPath;
|
|
14
|
+
maxModifySize;
|
|
15
|
+
constructor({ path, maxModifySize, }) {
|
|
16
|
+
const server = new DbServer({
|
|
17
|
+
path,
|
|
18
|
+
maxModifySize,
|
|
19
|
+
onSchemaChange(schema) {
|
|
20
|
+
client.putLocalSchema(schema);
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
const client = new DbClient({
|
|
24
|
+
maxModifySize,
|
|
25
|
+
hooks: {
|
|
26
|
+
putSchema(schema, fromStart) {
|
|
27
|
+
return Promise.resolve(server.putSchema(schema, fromStart));
|
|
28
|
+
},
|
|
29
|
+
flushModify(buf) {
|
|
30
|
+
server.modify(buf);
|
|
31
|
+
return Promise.resolve({
|
|
32
|
+
offsets: {},
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
getQueryBuf(buf) {
|
|
36
|
+
return Promise.resolve(server.getQueryBuf(buf));
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
this.server = server;
|
|
41
|
+
this.client = client;
|
|
42
|
+
}
|
|
43
|
+
// client
|
|
44
|
+
create = function () {
|
|
45
|
+
return this.client.create.apply(this.client, arguments);
|
|
46
|
+
};
|
|
47
|
+
update = function () {
|
|
48
|
+
return this.client.update.apply(this.client, arguments);
|
|
49
|
+
};
|
|
50
|
+
upsert = function () {
|
|
51
|
+
return this.client.upsert.apply(this.client, arguments);
|
|
52
|
+
};
|
|
53
|
+
remove = function () {
|
|
54
|
+
return this.client.remove.apply(this.client, arguments);
|
|
55
|
+
};
|
|
56
|
+
query = function () {
|
|
57
|
+
return this.client.query.apply(this.client, arguments);
|
|
58
|
+
};
|
|
59
|
+
putSchema = function () {
|
|
60
|
+
return this.client.putSchema.apply(this.client, arguments);
|
|
61
|
+
};
|
|
62
|
+
drain = function () {
|
|
63
|
+
return this.client.drain.apply(this.client, arguments);
|
|
64
|
+
};
|
|
65
|
+
// server
|
|
66
|
+
start = function () {
|
|
67
|
+
return this.server.start.apply(this.server, arguments);
|
|
68
|
+
};
|
|
69
|
+
stop = function () {
|
|
70
|
+
this.client.stop();
|
|
71
|
+
return this.server.stop.apply(this.server, arguments);
|
|
72
|
+
};
|
|
73
|
+
save = function () {
|
|
74
|
+
return this.server.save.apply(this.server, arguments);
|
|
75
|
+
};
|
|
76
|
+
migrateSchema = function () {
|
|
77
|
+
return this.server.migrateSchema.apply(this.server, arguments);
|
|
78
|
+
};
|
|
79
|
+
// both
|
|
80
|
+
destroy() {
|
|
81
|
+
this.client.destroy();
|
|
82
|
+
return this.server.destroy();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
workerCtxInit: () => void;
|
|
3
|
+
markMerkleBlock: (buf: Buffer) => any;
|
|
4
|
+
externalFromInt(address: BigInt): any;
|
|
5
|
+
intFromExternal(external: any): BigInt;
|
|
6
|
+
modify: (data: Buffer, types: Buffer, dbCtx: any) => any;
|
|
7
|
+
getQueryBuf: (q: Buffer, dbCtx: any) => Buffer | null;
|
|
8
|
+
start: (id: number) => any;
|
|
9
|
+
stop: (dbCtx: any) => any;
|
|
10
|
+
saveCommon: (path: string, dbCtx: any) => number;
|
|
11
|
+
saveRange: (path: string, typeCode: number, start: number, end: number, dbCtx: any, hashOut: Buffer) => number;
|
|
12
|
+
loadCommon: (path: string, dbCtx: any) => number;
|
|
13
|
+
loadRange: (path: string, dbCtx: any) => number;
|
|
14
|
+
updateSchemaType: (prefix: number, buf: Buffer, dbCtx: any) => any;
|
|
15
|
+
getTypeInfo: (typeId: number, dbCtx: any) => any;
|
|
16
|
+
getNodeRangeHash: (typeId: number, start: number, end: number, bufOut: Buffer, dbCtx: any) => any;
|
|
17
|
+
createHash: () => {
|
|
18
|
+
update: (buf: Buffer) => any;
|
|
19
|
+
digest: (encoding?: BufferEncoding) => Buffer | string;
|
|
20
|
+
reset: () => void;
|
|
21
|
+
};
|
|
22
|
+
compress: (buf: Buffer, offset: number, stringSize: number) => any;
|
|
23
|
+
decompress: (input: Buffer, output: Buffer, offset: number, len: number) => any;
|
|
24
|
+
crc32: (buf: Buffer) => any;
|
|
25
|
+
createSortIndex: (buf: Buffer, dbCtx: any) => any;
|
|
26
|
+
destroySortIndex: (buf: Buffer, dbCtx: any) => any;
|
|
27
|
+
};
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// @ts-ignore
|
|
2
|
+
import db from '../../basedDbNative.cjs';
|
|
3
|
+
var compressor = null;
|
|
4
|
+
var decompressor = null;
|
|
5
|
+
export default {
|
|
6
|
+
workerCtxInit: () => {
|
|
7
|
+
return db.workerCtxInit();
|
|
8
|
+
},
|
|
9
|
+
markMerkleBlock: (buf) => {
|
|
10
|
+
// pstart,
|
|
11
|
+
},
|
|
12
|
+
externalFromInt(address) {
|
|
13
|
+
return db.externalFromInt(address);
|
|
14
|
+
},
|
|
15
|
+
intFromExternal(external) {
|
|
16
|
+
return db.intFromExternal(external);
|
|
17
|
+
},
|
|
18
|
+
modify: (data, types, dbCtx) => {
|
|
19
|
+
db.modify(data, types, dbCtx);
|
|
20
|
+
},
|
|
21
|
+
getQueryBuf: (q, dbCtx) => {
|
|
22
|
+
return db.getQueryBuf(dbCtx, q);
|
|
23
|
+
},
|
|
24
|
+
start: (id) => {
|
|
25
|
+
return db.start(id);
|
|
26
|
+
},
|
|
27
|
+
stop: (dbCtx) => {
|
|
28
|
+
return db.stop(dbCtx);
|
|
29
|
+
},
|
|
30
|
+
saveCommon: (path, dbCtx) => {
|
|
31
|
+
const buf = Buffer.concat([Buffer.from(path), Buffer.from([0])]);
|
|
32
|
+
return db.saveCommon(buf, dbCtx);
|
|
33
|
+
},
|
|
34
|
+
saveRange: (path, typeCode, start, end, dbCtx, hashOut) => {
|
|
35
|
+
const buf = Buffer.concat([Buffer.from(path), Buffer.from([0])]);
|
|
36
|
+
return db.saveRange(buf, typeCode, start, end, dbCtx, hashOut);
|
|
37
|
+
},
|
|
38
|
+
loadCommon: (path, dbCtx) => {
|
|
39
|
+
const buf = Buffer.concat([Buffer.from(path), Buffer.from([0])]);
|
|
40
|
+
return db.loadCommon(buf, dbCtx);
|
|
41
|
+
},
|
|
42
|
+
loadRange: (path, dbCtx) => {
|
|
43
|
+
const buf = Buffer.concat([Buffer.from(path), Buffer.from([0])]);
|
|
44
|
+
return db.loadRange(buf, dbCtx);
|
|
45
|
+
},
|
|
46
|
+
updateSchemaType: (prefix, buf, dbCtx) => {
|
|
47
|
+
return db.updateSchema(prefix, buf, dbCtx);
|
|
48
|
+
},
|
|
49
|
+
getTypeInfo: (typeId, dbCtx) => {
|
|
50
|
+
return db.getTypeInfo(typeId, dbCtx);
|
|
51
|
+
},
|
|
52
|
+
getNodeRangeHash: (typeId, start, end, bufOut, dbCtx) => {
|
|
53
|
+
return db.getNodeRangeHash(typeId, start, end, bufOut, dbCtx);
|
|
54
|
+
},
|
|
55
|
+
createHash: () => {
|
|
56
|
+
const state = db.hashCreate();
|
|
57
|
+
const hash = {
|
|
58
|
+
update: (buf) => {
|
|
59
|
+
db.hashUpdate(state, buf);
|
|
60
|
+
return hash;
|
|
61
|
+
},
|
|
62
|
+
digest: (encoding) => {
|
|
63
|
+
const buf = Buffer.allocUnsafe(16);
|
|
64
|
+
db.hashDigest(state, buf);
|
|
65
|
+
return encoding ? buf.toString(encoding) : buf;
|
|
66
|
+
},
|
|
67
|
+
reset: () => {
|
|
68
|
+
db.hashReset(state);
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
return hash;
|
|
72
|
+
},
|
|
73
|
+
// needs to pass dbCtx: any
|
|
74
|
+
compress: (buf, offset, stringSize) => {
|
|
75
|
+
if (compressor === null) {
|
|
76
|
+
compressor = db.createCompressor();
|
|
77
|
+
}
|
|
78
|
+
return db.compress(compressor, buf, offset, stringSize);
|
|
79
|
+
},
|
|
80
|
+
decompress: (input, output, offset, len) => {
|
|
81
|
+
if (decompressor === null) {
|
|
82
|
+
decompressor = db.createDecompressor();
|
|
83
|
+
}
|
|
84
|
+
return db.decompress(decompressor, input, output, offset, len);
|
|
85
|
+
},
|
|
86
|
+
crc32: (buf) => {
|
|
87
|
+
return db.crc32(buf);
|
|
88
|
+
},
|
|
89
|
+
createSortIndex: (buf, dbCtx) => {
|
|
90
|
+
return db.createSortIndex(dbCtx, buf);
|
|
91
|
+
},
|
|
92
|
+
destroySortIndex: (buf, dbCtx) => {
|
|
93
|
+
return db.destroySortIndex(dbCtx, buf);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
function makeLabel(node) {
|
|
2
|
+
return `${node.key}\n${node.hash.toString('base64').substring(0, 5)}`;
|
|
3
|
+
}
|
|
4
|
+
export default function draw(csmt) {
|
|
5
|
+
const root = csmt.getRoot();
|
|
6
|
+
const lines = [];
|
|
7
|
+
const nodes = [];
|
|
8
|
+
let i = 0;
|
|
9
|
+
const walk = (node, prev) => {
|
|
10
|
+
const cur = i;
|
|
11
|
+
const left = node.left;
|
|
12
|
+
const right = node.right;
|
|
13
|
+
const isLeaf = !left && !right;
|
|
14
|
+
nodes.push(`n${cur} [label="${makeLabel(node)}"${isLeaf ? ' shape=box' : ''}];`);
|
|
15
|
+
if (cur > 0) {
|
|
16
|
+
lines.push(`n${prev} -- n${cur}`);
|
|
17
|
+
}
|
|
18
|
+
if (left) {
|
|
19
|
+
i++;
|
|
20
|
+
walk(left, cur);
|
|
21
|
+
}
|
|
22
|
+
if (right) {
|
|
23
|
+
i++;
|
|
24
|
+
walk(right, cur);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
if (root) {
|
|
28
|
+
walk(root, i);
|
|
29
|
+
}
|
|
30
|
+
return `graph ethane {\n${nodes.join('\n')}\n${lines.join('\n')}\n}`;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=draw-dot.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TreeKey, TreeNode } from './types.js';
|
|
2
|
+
export declare enum Direction {
|
|
3
|
+
Left = "L",
|
|
4
|
+
Right = "R"
|
|
5
|
+
}
|
|
6
|
+
export type Proof = [TreeKey | null, TreeKey | null] | [TreeKey | Buffer, TreeKey | Direction][];
|
|
7
|
+
export default function membershipProof(root: TreeNode | null, k: TreeKey): Proof;
|