@web3-storage/pail 0.4.2 → 0.5.0-alpha.0
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/cli.js +3 -2
- package/dist/src/api.d.ts +11 -5
- package/dist/src/api.d.ts.map +1 -1
- package/dist/src/batch/index.d.ts.map +1 -1
- package/dist/src/batch/shard.d.ts +0 -1
- package/dist/src/batch/shard.d.ts.map +1 -1
- package/dist/src/batch.d.ts +62 -0
- package/dist/src/batch.d.ts.map +1 -0
- package/dist/src/block.d.ts.map +1 -1
- package/dist/src/crdt/batch.d.ts +3 -0
- package/dist/src/crdt/batch.d.ts.map +1 -0
- package/dist/src/diff.d.ts +1 -1
- package/dist/src/diff.d.ts.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/shard.d.ts +7 -15
- package/dist/src/shard.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -9
- package/src/api.ts +12 -7
- package/src/batch/api.ts +0 -2
- package/src/batch/index.js +13 -12
- package/src/batch/index2.js +0 -0
- package/src/batch/shard.js +0 -52
- package/src/crdt/batch/api.ts +0 -1
- package/src/diff.js +25 -25
- package/src/index.js +93 -69
- package/src/shard.js +21 -89
package/cli.js
CHANGED
|
@@ -10,8 +10,9 @@ import clc from 'cli-color'
|
|
|
10
10
|
import archy from 'archy'
|
|
11
11
|
// eslint-disable-next-line no-unused-vars
|
|
12
12
|
import * as API from './src/api.js'
|
|
13
|
-
import { put, get, del, entries } from './src/index.js'
|
|
14
|
-
import { ShardFetcher, ShardBlock
|
|
13
|
+
import { put, get, del, entries } from './src/v1/index.js'
|
|
14
|
+
import { ShardFetcher, ShardBlock } from './src/v1/shard.js'
|
|
15
|
+
import { MaxShardSize } from './src/shard.js'
|
|
15
16
|
import { difference } from './src/diff.js'
|
|
16
17
|
import { merge } from './src/merge.js'
|
|
17
18
|
|
package/dist/src/api.d.ts
CHANGED
|
@@ -14,7 +14,6 @@ export interface Shard extends ShardConfig {
|
|
|
14
14
|
}
|
|
15
15
|
export type ShardLink = Link<Shard, typeof dagCBOR.code, typeof sha256.code, 1>;
|
|
16
16
|
export interface ShardBlockView extends BlockView<Shard, typeof dagCBOR.code, typeof sha256.code, 1> {
|
|
17
|
-
prefix: string;
|
|
18
17
|
}
|
|
19
18
|
export interface ShardDiff {
|
|
20
19
|
additions: ShardBlockView[];
|
|
@@ -24,10 +23,17 @@ export interface BlockFetcher {
|
|
|
24
23
|
get<T = unknown, C extends number = number, A extends number = number, V extends Version = 1>(link: Link<T, C, A, V>): Promise<Block<T, C, A, V> | undefined>;
|
|
25
24
|
}
|
|
26
25
|
export interface ShardConfig {
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
|
|
26
|
+
/** Shard compatibility version. */
|
|
27
|
+
version: number;
|
|
28
|
+
/**
|
|
29
|
+
* Characters allowed in keys, referring to a known character set.
|
|
30
|
+
* e.g. "ascii" refers to the printable ASCII characters in the code range 32-126.
|
|
31
|
+
*/
|
|
32
|
+
keyChars: string;
|
|
33
|
+
/** Max key size in bytes - default 4096 bytes. */
|
|
34
|
+
maxKeySize: number;
|
|
35
|
+
/** The key prefix from the root to this shard. */
|
|
36
|
+
prefix: string;
|
|
31
37
|
}
|
|
32
38
|
export type ShardOptions = Partial<ShardConfig>;
|
|
33
39
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/src/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAEvD,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAA;AAE9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,CAAC,CAAA;AAE7C,MAAM,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAElE,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAA;AAExE,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,2BAA2B,CAAC,CAAA;AAEpG,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,GAAG,2BAA2B,CAAC,CAAA;AAEvH,MAAM,WAAW,KAAM,SAAQ,WAAW;IACxC,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,OAAO,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;AAE/E,MAAM,WAAW,cAAe,SAAQ,SAAS,CAAC,KAAK,EAAE,OAAO,OAAO,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,CAAA;AAEvD,MAAM,MAAM,oBAAoB,GAAG,WAAW,CAAA;AAE9C,MAAM,MAAM,mBAAmB,GAAG,CAAC,SAAS,CAAC,CAAA;AAE7C,MAAM,MAAM,2BAA2B,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAElE,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAA;AAExE,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,mBAAmB,GAAG,2BAA2B,CAAC,CAAA;AAEpG,6CAA6C;AAC7C,MAAM,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,mBAAmB,GAAG,2BAA2B,CAAC,CAAA;AAEvH,MAAM,WAAW,KAAM,SAAQ,WAAW;IACxC,OAAO,EAAE,UAAU,EAAE,CAAA;CACtB;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,OAAO,OAAO,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;AAE/E,MAAM,WAAW,cAAe,SAAQ,SAAS,CAAC,KAAK,EAAE,OAAO,OAAO,CAAC,IAAI,EAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;CAAG;AAEvG,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,cAAc,EAAE,CAAA;IAC3B,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,CAAC,SAAS,OAAO,GAAG,CAAC,EAAG,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACnH,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAA;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAA;IAClB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/batch/index.js"],"names":[],"mappings":"AAgEO,4BANI,IAAI,YAAY,SAChB,gBAAgB,OAChB,MAAM,SACN,IAAI,WAAW,GACb,QAAQ,IAAI,CAAC,CA4FzB;AAWM,iCALI,YAAY,OACZ,MAAM,SACN,gBAAgB,GACd,QAAQ;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/batch/index.js"],"names":[],"mappings":"AAgEO,4BANI,IAAI,YAAY,SAChB,gBAAgB,OAChB,MAAM,SACN,IAAI,WAAW,GACb,QAAQ,IAAI,CAAC,CA4FzB;AAWM,iCALI,YAAY,OACZ,MAAM,SACN,gBAAgB,GACd,QAAQ;IAAE,KAAK,EAAE,gBAAgB,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAe7D;AAQM,8BAFI,gBAAgB;;;;GAkC1B;AAaM,+BAJI,IAAI,YAAY,QAChB,IAAI,SAAS,GACX,QAAQ,WAAW,CAAC,CAEyD;AAE1F;IAUE,oBAAmC;IATnC;;;OAGG;IACH,8EAGC;IADC,aAAoC;CAIvC;qBAnPoB,UAAU;8BAGD,YAAY;6BAFb,aAAa;AAI1C,gCAAgC;AAChC,iCADiB,GAAG,CAAC,OAAO;IAsC1B;;;;;OAKG;IACH;QAJkC,MAAM,EAA7B,IAAI,YAAY;QACI,IAAI,EAAxB,IAAI,SAAS;QACA,MAAM,EAAnB,MAAM;yBAMhB;IA5CD;;;;;;;;OAQG;IACH;QAPkC,MAAM,EAA7B,IAAI,YAAY;QACc,OAAO,EAArC,uBAAuB;QACV,MAAM,EAAnB,MAAM;QACO,OAAO,EAApB,MAAM;QACO,YAAY,EAAzB,MAAM;QACmB,IAAI,EAA7B,IAAI,cAAc;OAS5B;IANC,yBAAoB;IACpB,eAAoB;IACpB,iCAAsB;IACtB,yBAAgB;IAChB,gBAAsB;IACtB,qBAAgC;IAGlC;;;;OAIG;IACH,SAJW,MAAM,SACN,IAAI,WAAW,GACb,QAAQ,IAAI,CAAC,CAKzB;IAED;;;;OAIC;;CAaF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard.d.ts","sourceRoot":"","sources":["../../../src/batch/shard.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shard.d.ts","sourceRoot":"","sources":["../../../src/batch/shard.js"],"names":[],"mappings":"AAQO,iEAFM,IAAI,YAAY,CAO3B;qBAZmB,UAAU"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export function create(blocks: API.BlockFetcher, root: API.ShardLink): Promise<API.Batcher>;
|
|
2
|
+
export type BatcherShardEntry = [
|
|
3
|
+
key: string,
|
|
4
|
+
value: API.ShardEntryValueValue | [API.ShardLink] | [API.ShardLink, Link.UnknownLink],
|
|
5
|
+
batcher?: Batcher
|
|
6
|
+
];
|
|
7
|
+
import * as API from './api.js';
|
|
8
|
+
/** @implements {API.Batcher} */
|
|
9
|
+
declare class Batcher implements API.Batcher {
|
|
10
|
+
/**
|
|
11
|
+
* @param {ShardFetcher} shards Shard storage.
|
|
12
|
+
* @param {API.ShardLink} link CID of the shard block.
|
|
13
|
+
* @param {string} prefix
|
|
14
|
+
*/
|
|
15
|
+
static create(shards: ShardFetcher, link: API.ShardLink, prefix: string): Promise<Batcher>;
|
|
16
|
+
/**
|
|
17
|
+
* @param {object} arg
|
|
18
|
+
* @param {ShardFetcher} arg.shards Shard storage.
|
|
19
|
+
* @param {BatcherShardEntry[]} arg.entries The entries in this shard.
|
|
20
|
+
* @param {string} arg.prefix Key prefix.
|
|
21
|
+
* @param {API.ShardConfig} arg.config Shard config.
|
|
22
|
+
* @param {API.ShardBlockView} [arg.base] Original shard this batcher is based on.
|
|
23
|
+
*/
|
|
24
|
+
constructor({ shards, entries, prefix, config, base }: {
|
|
25
|
+
shards: ShardFetcher;
|
|
26
|
+
entries: BatcherShardEntry[];
|
|
27
|
+
prefix: string;
|
|
28
|
+
config: API.ShardConfig;
|
|
29
|
+
base?: API.ShardBlockView | undefined;
|
|
30
|
+
});
|
|
31
|
+
shards: ShardFetcher;
|
|
32
|
+
prefix: string;
|
|
33
|
+
entries: BatcherShardEntry[];
|
|
34
|
+
config: API.ShardConfig;
|
|
35
|
+
base: API.ShardBlockView | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* @param {string} key The key of the value to put.
|
|
38
|
+
* @param {API.UnknownLink} value The value to put.
|
|
39
|
+
* @returns {Promise<void>}
|
|
40
|
+
*/
|
|
41
|
+
put(key: string, value: API.UnknownLink): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Traverse from this batcher through the shard to the correct batcher for
|
|
44
|
+
* the passed key.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} key
|
|
47
|
+
* @returns {Promise<{ batcher: Batcher, key: string }>}
|
|
48
|
+
*/
|
|
49
|
+
traverse(key: string): Promise<{
|
|
50
|
+
batcher: Batcher;
|
|
51
|
+
key: string;
|
|
52
|
+
}>;
|
|
53
|
+
commit(): Promise<{
|
|
54
|
+
root: import("multiformats").CID<API.Shard, 113, 18, 1>;
|
|
55
|
+
additions: API.ShardBlockView[];
|
|
56
|
+
removals: API.ShardBlockView[];
|
|
57
|
+
}>;
|
|
58
|
+
}
|
|
59
|
+
import * as Link from 'multiformats/link';
|
|
60
|
+
import { ShardFetcher } from './shard.js';
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/batch.js"],"names":[],"mappings":"AA2NO,+BAJI,IAAI,YAAY,QAChB,IAAI,SAAS,GACX,QAAQ,WAAW,CAAC,CAKhC;gCAvNY;IACZ,GAAO,EAAE,MAAM;IACf,KAAS,EAAE,IAAI,oBAAoB,sDAA4D;IAC/F,OAAW,CAAC,EAAE,OAAO;CAClB;qBATiB,UAAU;AAc/B,gCAAgC;AAChC,iCADiB,GAAG,CAAC,OAAO;IA4K1B;;;;OAIG;IACH,sBAJW,YAAY,QACZ,IAAI,SAAS,UACb,MAAM,oBAWhB;IAxLD;;;;;;;OAOG;IACH;QAN6B,MAAM,EAAxB,YAAY;QACa,OAAO,EAAhC,mBAAmB;QACP,MAAM,EAAlB,MAAM;QACe,MAAM,EAA3B,IAAI,WAAW;QACU,IAAI;OAQvC;IALC,qBAAoB;IACpB,eAAoB;IACpB,6BAAsB;IACtB,wBAAoB;IACpB,qCAAgB;IAGlB;;;;OAIG;IACH,SAJW,MAAM,SACN,IAAI,WAAW,GACb,QAAQ,IAAI,CAAC,CA6FzB;IAED;;;;;;OAMG;IACH,cAHW,MAAM,GACJ,QAAQ;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAetD;IAED;;;;OAgCC;CAiBF;sBA3MqB,mBAAmB;6BAGZ,YAAY"}
|
package/dist/src/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/block.js"],"names":[],"mappings":"AAIA,qCAAqC;AACrC,yCADiB,GAAG,CAAC,YAAY;IAK/B;;OAEG;IACH,sEAIC;
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/block.js"],"names":[],"mappings":"AAIA,qCAAqC;AACrC,yCADiB,GAAG,CAAC,YAAY;IAK/B;;OAEG;IACH,sEAIC;IAgCsB,0KAUI;IAjC3B;;;OAGG;IACH,SAHW,IAAI,WAAW,SACf,UAAU,iBAIpB;IAED;;;OAGG;IACH,aAHW,IAAI,WAAW,SACf,UAAU,QAIpB;IAED,mCAAmC;IACnC,YADY,IAAI,WAAW,iBAG1B;IAED,mCAAmC;IACnC,gBADY,IAAI,WAAW,QAG1B;IAED;;;sBAIC;;CACF;AAED;IAIE,2CAA2C;IAC3C,yBADY,IAAI,YAAY,EAAE,EAG7B;IAjBsB,0KAUI;;CAgB5B;qBAzEoB,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../../src/crdt/batch.js"],"names":[],"mappings":"AASO,+BAJI,IAAI,YAAY,QAChB,IAAI,SAAS,GACX,QAAQ,IAAI,OAAO,CAAC,CAKhC;qBAXoB,WAAW"}
|
package/dist/src/diff.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function difference(blocks: API.BlockFetcher, a: API.ShardLink, b: API.ShardLink
|
|
1
|
+
export function difference(blocks: API.BlockFetcher, a: API.ShardLink, b: API.ShardLink): Promise<CombinedDiff>;
|
|
2
2
|
export type K = string;
|
|
3
3
|
export type AddV = [before: null, after: API.UnknownLink];
|
|
4
4
|
export type UpdateV = [before: API.UnknownLink, after: API.UnknownLink];
|
package/dist/src/diff.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.js"],"names":[],"mappings":"AAoBO,mCALI,IAAI,YAAY,KAChB,IAAI,SAAS,KACb,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../src/diff.js"],"names":[],"mappings":"AAoBO,mCALI,IAAI,YAAY,KAChB,IAAI,SAAS,KACb,IAAI,SAAS,GACX,QAAQ,YAAY,CAAC,CAgHjC;gBA7HY,MAAM;mBACN,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,WAAW,CAAC;sBACtC,CAAC,MAAM,EAAE,IAAI,WAAW,EAAE,KAAK,EAAE,IAAI,WAAW,CAAC;sBACjD,CAAC,MAAM,EAAE,IAAI,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC;iBACtC,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,mIAAoB,CAAC;uBACrC,gDAAI;2BACJ;IAAE,IAAI,OAAW;IAAC,MAAM,EAAE,IAAI,SAAS,CAAA;CAAE;qBAVjC,UAAU"}
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":"AAeO,4BANI,IAAI,YAAY,QAChB,IAAI,SAAS,OACb,MAAM,SACN,IAAI,WAAW,GACb,QAAQ;IAAE,IAAI,EAAE,IAAI,SAAS,CAAA;CAAE,GAAG,IAAI,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":"AAeO,4BANI,IAAI,YAAY,QAChB,IAAI,SAAS,OACb,MAAM,SACN,IAAI,WAAW,GACb,QAAQ;IAAE,IAAI,EAAE,IAAI,SAAS,CAAA;CAAE,GAAG,IAAI,SAAS,CAAC,CAkI5D;AAWM,4BALI,IAAI,YAAY,QAChB,IAAI,SAAS,OACb,MAAM,GACJ,QAAQ,IAAI,WAAW,GAAG,SAAS,CAAC,CAWhD;AAWM,4BALI,IAAI,YAAY,QAChB,IAAI,SAAS,OACb,MAAM,GACJ,QAAQ;IAAE,IAAI,EAAE,IAAI,SAAS,CAAA;CAAE,GAAG,IAAI,SAAS,CAAC,CAoE5D;AAWM,gCANI,IAAI,YAAY,QAChB,IAAI,SAAS;;gBAGX,0CAA0C,CAsCtD;qBA9RoB,UAAU"}
|
package/dist/src/shard.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
1
|
+
export const KeyCharsASCII: "ascii";
|
|
2
|
+
export const MaxKeySize: 4096;
|
|
3
3
|
/**
|
|
4
4
|
* @extends {Block<API.Shard, typeof dagCBOR.code, typeof sha256.code, 1>}
|
|
5
5
|
* @implements {API.ShardBlockView}
|
|
@@ -12,21 +12,18 @@ export class ShardBlock extends Block<API.Shard, 113, 18, 1> implements API.Shar
|
|
|
12
12
|
* @param {API.ShardLink} config.cid
|
|
13
13
|
* @param {API.Shard} config.value
|
|
14
14
|
* @param {Uint8Array} config.bytes
|
|
15
|
-
* @param {string} config.prefix
|
|
16
15
|
*/
|
|
17
|
-
constructor({ cid, value, bytes
|
|
16
|
+
constructor({ cid, value, bytes }: {
|
|
18
17
|
cid: API.ShardLink;
|
|
19
18
|
value: API.Shard;
|
|
20
19
|
bytes: Uint8Array;
|
|
21
|
-
prefix: string;
|
|
22
20
|
});
|
|
23
|
-
prefix: string;
|
|
24
21
|
}
|
|
25
22
|
export function create(options?: Partial<API.ShardConfig> | undefined): API.Shard;
|
|
26
23
|
export function configure(options?: Partial<API.ShardConfig> | undefined): API.ShardConfig;
|
|
27
24
|
export function withEntries(entries: API.ShardEntry[], options?: Partial<API.ShardConfig> | undefined): API.Shard;
|
|
28
|
-
export function encodeBlock(value: API.Shard
|
|
29
|
-
export function decodeBlock(bytes: Uint8Array
|
|
25
|
+
export function encodeBlock(value: API.Shard): Promise<API.ShardBlockView>;
|
|
26
|
+
export function decodeBlock(bytes: Uint8Array): Promise<API.ShardBlockView>;
|
|
30
27
|
export function isShard(value: any): value is API.Shard;
|
|
31
28
|
export function isShardLink(value: any): value is API.ShardLink;
|
|
32
29
|
export class ShardFetcher {
|
|
@@ -35,17 +32,12 @@ export class ShardFetcher {
|
|
|
35
32
|
_blocks: API.BlockFetcher;
|
|
36
33
|
/**
|
|
37
34
|
* @param {API.ShardLink} link
|
|
38
|
-
* @param {string} [prefix]
|
|
39
35
|
* @returns {Promise<API.ShardBlockView>}
|
|
40
36
|
*/
|
|
41
|
-
get(link: API.ShardLink
|
|
37
|
+
get(link: API.ShardLink): Promise<API.ShardBlockView>;
|
|
42
38
|
}
|
|
43
39
|
export function putEntry(target: API.ShardEntry[], newEntry: API.ShardEntry): API.ShardEntry[];
|
|
44
|
-
export function
|
|
45
|
-
prefix: string;
|
|
46
|
-
matches: API.ShardEntry[];
|
|
47
|
-
} | undefined;
|
|
48
|
-
export function encodedLength(shard: API.Shard): number;
|
|
40
|
+
export function isPrintableASCII(s: string): boolean;
|
|
49
41
|
import * as API from './api.js';
|
|
50
42
|
import { Block } from 'multiformats/block';
|
|
51
43
|
//# sourceMappingURL=shard.d.ts.map
|
package/dist/src/shard.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shard.d.ts","sourceRoot":"","sources":["../../src/shard.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shard.d.ts","sourceRoot":"","sources":["../../src/shard.js"],"names":[],"mappings":"AAOA,oCAAoC;AACpC,8BAA8B;AAE9B;;;GAGG;AACH,wEAFgB,GAAG,CAAC,cAAc;IAchC,0CAA0C;IAC1C,2FAEC;IAdD;;;;;OAKG;IACH;QAJiC,GAAG,EAAzB,IAAI,SAAS;QACK,KAAK,EAAvB,IAAI,KAAK;QACU,KAAK,EAAxB,UAAU;OAKpB;CAMF;AAMM,wEAFM,IAAI,KAAK,CAEqD;AAMpE,2EAFM,IAAI,WAAW,CAO1B;AAOK,qCAJI,gBAAgB,mDAEd,IAAI,KAAK,CAE4D;AAS3E,mCAHI,IAAI,KAAK,GACP,QAAQ,IAAI,cAAc,CAAC,CAOvC;AAMM,mCAHI,UAAU,GACR,QAAQ,IAAI,cAAc,CAAC,CAQvC;AAMM,+BAHI,GAAG,sBAUoB;AAM3B,mCAHI,GAAG,0BAKe;AAE7B;IACE,uCAAuC;IACvC,oBADY,IAAI,YAAY,EAG3B;IADC,0BAAqB;IAGvB;;;OAGG;IACH,UAHW,IAAI,SAAS,GACX,QAAQ,IAAI,cAAc,CAAC,CAMvC;CACF;AAOM,iCAJI,gBAAgB,6BAEd,gBAAgB,CAqD5B;AAGM,oCADK,MAAM,WAC2C;qBA9KxC,UAAU;sBAJO,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"program":{"fileNames":["../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es5.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.dom.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.full.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/bases/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/link/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/cid.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/block/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/codecs/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/digest.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/hasher.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/varint.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/bytes.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/index.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/sha2.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/bases/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/block/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/hashes/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/link/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/cid.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/codecs/interface.d.ts","../node_modules/.pnpm/@ipld+dag-cbor@9.0.8/node_modules/@ipld/dag-cbor/dist/src/index.d.ts","../src/api.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/link.d.ts","../src/block.js","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/block.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/lib/token.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/lib/bl.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/interface.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/lib/length.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/lib/decode.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/lib/encode.d.ts","../node_modules/.pnpm/cborg@4.0.7/node_modules/cborg/types/cborg.d.ts","../src/shard.js","../src/diff.js","../src/index.js","../src/merge.js","../src/batch/api.ts","../src/batch/shard.js","../src/batch/index.js","../src/clock/api.ts","../src/clock/index.js","../src/crdt/api.ts","../src/crdt/index.js","../src/crdt/batch/api.ts","../src/crdt/batch/index.js"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc",{"version":"21e41a76098aa7a191028256e52a726baafd45a925ea5cf0222eb430c96c1d83","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"1df2366de6650547b3dc1d7c4147355c0f6b4729c964e3839636fa418982d131","f997c5be1eb27b8c37d50d3f61fc5671fb79efd80c499e0e16b5d56c32182f8d","0828334538f604701c9dd0bf54abb758803f9efb4acb4aedd9b18acde4b1bcdf","552223520e823223ee13c5764e9b69b1819c985818a8bcda435d8d1dbd909bee","671efcb4cb21897b43dec53d0218afcac3d1e13c7d50158b0c1a0b300acdb69e","e68d682c8224a5c2e5f5e3720537cec720c41a829e1367316ea9acf6fec48ecc","f9e46527ef7833f803a47c256179c05e5149a8dc776c5a6952572052c9e00b24","557b8c7481296f4b7ed362320f3bbb40bb87404edf880c81224f365a8d1e17f3","467a7c09abfde00a7fc41d06c1c599f01e944c9f4948d38a0bde82b766a7e364","7697d44896d7082a0195b088b1a5c49bb70aea87721448982bee34720cfa73f4","77c738b0671d324f6cb2c7c1d7dfc0282a5836c67af55c9ba6df315c62207f57","f2dc47a6b115cd100153d2aaa3dbec094e7a55c5e471c9df8cf7fd651925d63f","2d57b5c1d1ef4cf78480539c0e0650af78ccf387d95f0585b12dbd658691a30f","5b563db2a9fdba4950d49351dae9909146ca93bec867e748754d255769e169e0","4a3605bef1a5ef29fd5a1696dd95b0b4e2259e2d07a4d88fac79f3a9765c44a2","d3df79602ca0303c65d2197c9e71222db97a4a0e5a691bdab49a65f83397558f","90240231e730deed31569f6c686766a538e4a024bbc33ea1738fe924f477ba61","552223520e823223ee13c5764e9b69b1819c985818a8bcda435d8d1dbd909bee","49b7c3ddd683c09aa437dd92681699387441f522524b14d2331ce494a9bf2f27","f9e46527ef7833f803a47c256179c05e5149a8dc776c5a6952572052c9e00b24","096e5d8e4e2faca903221837f5c249153aa5d98405d4150bd41e54f7efbc8929",{"version":"0edd12211684abc8d60719241bc1c0a178f32413f319f5b81e27cc515ab12c5c","signature":"5f6f0c2f504a3fd3628abf2d0657fbe2e37ed8059f68757eb089ce35adc32f1b"},"894510c4bac920c0ffbdc60e3743438be522c3f2bc029367aaae438b7ecee16b",{"version":"3c60343b48438de7de857209f3272804f325705e05945d0b5c6b77d8c0b91271","signature":"6bb7ea47ab2fdff568fb0958e303868ab4d62acc1c8de4d4633d0ee767de7d8d"},"dfd8fa0db9817c18d04f46d320051bf96638e0ef03b732c1abedf7b00337f0e6","0e84a640a449bd767be2ebebf4acf7cac1b1f92e72941b30d370ca0c8f1a30b3","a32c2dd5736b27da05ddf1034df28c75e8db3ef26effe60df4bd608f5c7a03d8","f65fb2149519d5e7cdf1245e0d5e5c6369855d9f14cfd1da9a678750da3f3fe6","346a9400fd471109354689e5dc93384e56e7a33d0c3ce05e7d5901380f4dc6ce","15f502c247a60ad85c2a87635e7b0a71701a7f6d75fecba0f541e2b28d66f6fd","730fedb3e76078f11d9a8a595c3f337dadfb1c687810999b02394e853b668c5a","babe35042b7448cb38bbc24c357a358c5e1e71d2692a818f21a8550340e41329",{"version":"87400e2622608e49974ce16867e2f8fc6413e08172594a8620b027c2649a9971","signature":"73409439c0ea0c6c6b0d47d3caef6053678d81e4528ee9a77516478f602e7092"},{"version":"305ec608b339faf40414803f6bd066c667b24cd20851cdd3297a76cd692acd38","signature":"e6670b4952693ae74bb8d2228b8257d1736ebb058d6312ba3feea52c9da4ef98"},{"version":"b5d8997faf430ccf8b7821108fdf0a4a9027b5bc54153b6242354a8d573e2070","signature":"ed062bf7a44961474312776691fef0f3fb9c1b26a69ffff27c80073db0311353"},{"version":"229faf86cd68a721d11b73a0b398ee241a57172cb3eef98351fa6adc4ed96aec","signature":"6bfa5af024804ea22f15370d2feb92958199fd3827bc97bf0487d29fb488925f"},{"version":"755c81b4020b74b08ee753e352c302b8af4e96e87b82cfafdb8ee5bb583f5056","signature":"d284155626e041407da87b191b56bdebee51d13fe52333b62c8b5c4a1fa02bd8"},{"version":"d9216190118803417e29a98d112a66db64f17a639d7dc2ddc891b5f91e89cca9","signature":"5bbc200d7c413ce000e5aa036d4d80d88205500edf6bf23cf369b2c7087de78b"},{"version":"ecea96f1e8040ba76edef19306e6bf08d49f4ea3c6b791f5da12b8c97cb53866","signature":"34ce54a41b59354e167390b4db48112a2a2daf5a79c6c6a740c09f9b7dbc3e0c"},{"version":"634e303df54ddd9c2e20bce6784a7fef1ea06183d75161fbf57e3324d4d6f07e","signature":"de94446f7a45df1aa8cfbe6aba6041f18551e6cee0067f29ecbe8615baf45360"},{"version":"31e758d6640ef652be142972a0002fed5ff026c20a61c51266ac73463c34e4fb","signature":"8404e591edea1a6f802f4099ced1c87a143250519ae18e88be1d8bf0eaf6ace5"},{"version":"9cb65f8ee81b46b10869cb3640f3dc1c377e9830b73fd93f97991230e3b3e0b2","signature":"d65e247691eef67fc9b388fd2f73ba1d42c0a756ce0a6f1e4bf34aa8544017be"},{"version":"20e2f5c83e426e0665b2de8e00f57f736031644150965aeca80237b96d287293","signature":"18951b384763db13a5f0597e5ee1fa141e36fd80323938471e69e954c434818c"},{"version":"6e6ed3848a3f096cf172b6e81d2218b6f95f37772822cf749850271008e0a0b3","signature":"39eaa64d9ce59d3a874d8f8d738db4428f23f1983b0aa99e0fefdcaf6ec5f9ae"},{"version":"7c1891be80b5324cb8892d3e8872b01a178044276004a3f7045784378eb445d1","signature":"c69bc379f337d1e362506c4b44d64004801262c7b4c6ee280a131c86eb1ced15"}],"root":[82,84,[93,105]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":7,"outDir":"./","skipLibCheck":true,"strict":true,"target":9},"fileIdsList":[[79,80],[86,88,90,91],[86,87],[86,88],[88],[68,73],[64,65],[64],[66],[63],[63,69],[70],[65,68,69,70,71,72],[62,63,64,66,67],[62,63,66],[78,79],[78],[76],[75,76,77],[73,74,81],[82],[93,97,98],[83,89,92,93,97],[73,82,83],[73,82],[73,74,81,85,100],[82,100],[97,102],[84,93,99,101,103,104],[84,93,95,99,101,102],[82,93],[82,94,95],[74,81,82,83,85,89,92]],"referencedMap":[[81,1],[92,2],[88,3],[90,4],[91,5],[89,5],[85,6],[66,7],[65,8],[67,9],[69,10],[70,11],[74,12],[73,13],[68,14],[83,7],[64,15],[76,16],[79,17],[80,18],[78,19],[82,20],[97,21],[99,22],[98,23],[84,24],[100,25],[101,26],[102,27],[104,28],[105,29],[103,30],[94,31],[95,31],[96,32],[93,33]],"exportedModulesMap":[[81,1],[92,2],[88,3],[90,4],[91,5],[89,5],[85,6],[66,7],[65,8],[67,9],[69,10],[70,11],[74,12],[73,13],[68,14],[83,7],[64,15],[76,16],[79,17],[80,18],[78,19],[82,20],[97,21],[99,25],[100,25],[102,27],[104,28],[103,25]],"semanticDiagnosticsPerFile":[81,92,88,87,90,91,89,86,62,85,66,72,65,67,69,70,63,74,73,68,83,64,71,75,76,79,80,77,78,59,60,10,11,15,14,2,16,17,18,19,20,21,22,23,3,4,24,28,25,26,27,29,30,31,5,32,33,34,35,6,39,36,37,38,40,7,41,46,47,42,43,44,45,8,51,48,49,50,52,9,53,61,54,55,58,56,57,1,13,12,82,97,99,98,84,100,101,102,104,105,103,94,95,96,93],"latestChangedDtsFile":"./src/crdt/batch/index.d.ts"},"version":"5.3.3"}
|
|
1
|
+
{"program":{"fileNames":["../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es5.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.dom.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.sharedmemory.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.decorators.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../node_modules/.pnpm/typescript@5.3.3/node_modules/typescript/lib/lib.es2022.full.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/bases/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/link/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/cid.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/block/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/codecs/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/interface.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/digest.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/hasher.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/varint.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/bytes.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/index.d.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/hashes/sha2.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/bases/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/block/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/hashes/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/link/interface.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/cid.d.ts","../node_modules/.pnpm/multiformats@13.0.1/node_modules/multiformats/dist/src/codecs/interface.d.ts","../node_modules/.pnpm/@ipld+dag-cbor@9.0.8/node_modules/@ipld/dag-cbor/dist/src/index.d.ts","../src/api.ts","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/link.d.ts","../src/block.js","../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/dist/types/src/block.d.ts","../src/shard.js","../src/diff.js","../src/index.js","../src/merge.js","../src/clock/api.ts","../src/clock/index.js","../node_modules/@types/istanbul-lib-coverage/index.d.ts","../node_modules/@types/json5/index.d.ts"],"fileInfos":[{"version":"f33e5332b24c3773e930e212cbb8b6867c8ba3ec4492064ea78e55a524d57450","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","26f2f787e82c4222710f3b676b4d83eb5ad0a72fa7b746f03449e7a026ce5073","9a68c0c07ae2fa71b44384a839b7b8d81662a236d4b9ac30916718f7510b1b2d","5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","feecb1be483ed332fad555aff858affd90a48ab19ba7272ee084704eb7167569","5514e54f17d6d74ecefedc73c504eadffdeda79c7ea205cf9febead32d45c4bc",{"version":"21e41a76098aa7a191028256e52a726baafd45a925ea5cf0222eb430c96c1d83","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true},{"version":"138fb588d26538783b78d1e3b2c2cc12d55840b97bf5e08bca7f7a174fbe2f17","affectsGlobalScope":true},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"bc47685641087c015972a3f072480889f0d6c65515f12bd85222f49a98952ed7","affectsGlobalScope":true},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true},{"version":"93495ff27b8746f55d19fcbcdbaccc99fd95f19d057aed1bd2c0cafe1335fbf0","affectsGlobalScope":true},{"version":"6fc23bb8c3965964be8c597310a2878b53a0306edb71d4b5a4dfe760186bcc01","affectsGlobalScope":true},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true},{"version":"bb42a7797d996412ecdc5b2787720de477103a0b2e53058569069a0e2bae6c7e","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"61c37c1de663cf4171e1192466e52c7a382afa58da01b1dc75058f032ddf0839","affectsGlobalScope":true},{"version":"b541a838a13f9234aba650a825393ffc2292dc0fc87681a5d81ef0c96d281e7a","affectsGlobalScope":true},{"version":"e0275cd0e42990dc3a16f0b7c8bca3efe87f1c8ad404f80c6db1c7c0b828c59f","affectsGlobalScope":true},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true},{"version":"49ed889be54031e1044af0ad2c603d627b8bda8b50c1a68435fe85583901d072","affectsGlobalScope":true},{"version":"e93d098658ce4f0c8a0779e6cab91d0259efb88a318137f686ad76f8410ca270","affectsGlobalScope":true},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true},{"version":"bf14a426dbbf1022d11bd08d6b8e709a2e9d246f0c6c1032f3b2edb9a902adbe","affectsGlobalScope":true},{"version":"ec0104fee478075cb5171e5f4e3f23add8e02d845ae0165bfa3f1099241fa2aa","affectsGlobalScope":true},{"version":"2b72d528b2e2fe3c57889ca7baef5e13a56c957b946906d03767c642f386bbc3","affectsGlobalScope":true},{"version":"acae90d417bee324b1372813b5a00829d31c7eb670d299cd7f8f9a648ac05688","affectsGlobalScope":true},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true},{"version":"af3dd424cf267428f30ccfc376f47a2c0114546b55c44d8c0f1d57d841e28d74","affectsGlobalScope":true},{"version":"995c005ab91a498455ea8dfb63aa9f83fa2ea793c3d8aa344be4a1678d06d399","affectsGlobalScope":true},{"version":"51e547984877a62227042850456de71a5c45e7fe86b7c975c6e68896c86fa23b","affectsGlobalScope":true},{"version":"62a4966981264d1f04c44eb0f4b5bdc3d81c1a54725608861e44755aa24ad6a5","affectsGlobalScope":true},{"version":"4fa6ed14e98aa80b91f61b9805c653ee82af3502dc21c9da5268d3857772ca05","affectsGlobalScope":true},{"version":"e6633e05da3ff36e6da2ec170d0d03ccf33de50ca4dc6f5aeecb572cedd162fb","affectsGlobalScope":true},{"version":"86a34c7a13de9cabc43161348f663624b56871ed80986e41d214932ddd8d6719","affectsGlobalScope":true},{"version":"8444af78980e3b20b49324f4a16ba35024fef3ee069a0eb67616ea6ca821c47a","affectsGlobalScope":true},{"version":"caccc56c72713969e1cfe5c3d44e5bab151544d9d2b373d7dbe5a1e4166652be","affectsGlobalScope":true},{"version":"3287d9d085fbd618c3971944b65b4be57859f5415f495b33a6adc994edd2f004","affectsGlobalScope":true},{"version":"50d53ccd31f6667aff66e3d62adf948879a3a16f05d89882d1188084ee415bbc","affectsGlobalScope":true},{"version":"33358442698bb565130f52ba79bfd3d4d484ac85fe33f3cb1759c54d18201393","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"1df2366de6650547b3dc1d7c4147355c0f6b4729c964e3839636fa418982d131","f997c5be1eb27b8c37d50d3f61fc5671fb79efd80c499e0e16b5d56c32182f8d","0828334538f604701c9dd0bf54abb758803f9efb4acb4aedd9b18acde4b1bcdf","552223520e823223ee13c5764e9b69b1819c985818a8bcda435d8d1dbd909bee","671efcb4cb21897b43dec53d0218afcac3d1e13c7d50158b0c1a0b300acdb69e","e68d682c8224a5c2e5f5e3720537cec720c41a829e1367316ea9acf6fec48ecc","f9e46527ef7833f803a47c256179c05e5149a8dc776c5a6952572052c9e00b24","557b8c7481296f4b7ed362320f3bbb40bb87404edf880c81224f365a8d1e17f3","467a7c09abfde00a7fc41d06c1c599f01e944c9f4948d38a0bde82b766a7e364","7697d44896d7082a0195b088b1a5c49bb70aea87721448982bee34720cfa73f4","77c738b0671d324f6cb2c7c1d7dfc0282a5836c67af55c9ba6df315c62207f57","f2dc47a6b115cd100153d2aaa3dbec094e7a55c5e471c9df8cf7fd651925d63f","2d57b5c1d1ef4cf78480539c0e0650af78ccf387d95f0585b12dbd658691a30f","5b563db2a9fdba4950d49351dae9909146ca93bec867e748754d255769e169e0","4a3605bef1a5ef29fd5a1696dd95b0b4e2259e2d07a4d88fac79f3a9765c44a2","d3df79602ca0303c65d2197c9e71222db97a4a0e5a691bdab49a65f83397558f","90240231e730deed31569f6c686766a538e4a024bbc33ea1738fe924f477ba61","552223520e823223ee13c5764e9b69b1819c985818a8bcda435d8d1dbd909bee","49b7c3ddd683c09aa437dd92681699387441f522524b14d2331ce494a9bf2f27","f9e46527ef7833f803a47c256179c05e5149a8dc776c5a6952572052c9e00b24","096e5d8e4e2faca903221837f5c249153aa5d98405d4150bd41e54f7efbc8929",{"version":"31f71d04461366761d71c04419941fe88b6db27c97141842d6efa190acb75350","signature":"c2072d59e16f5f62b0c5f2426273a4fbccb286641e280adb2750da7813e95d5d"},"894510c4bac920c0ffbdc60e3743438be522c3f2bc029367aaae438b7ecee16b",{"version":"3c60343b48438de7de857209f3272804f325705e05945d0b5c6b77d8c0b91271","signature":"6bb7ea47ab2fdff568fb0958e303868ab4d62acc1c8de4d4633d0ee767de7d8d"},"dfd8fa0db9817c18d04f46d320051bf96638e0ef03b732c1abedf7b00337f0e6",{"version":"da90eb2d7d795885d978a33a0d37fc875f4749c30ddf1b6ef4642d767b572828","signature":"e770bf4d01b19862ab3dbef25eca5d2a5ea1df83c031f17952fcad94c39767bd"},{"version":"4efb0e55bdb87c1fc5ede5dceba6bbd330daee81c9acf55110f1d68fbea8e34c","signature":"4cfe33e746c7117c1343aff4b084d4416d300437fe1080e066a4ea961ba45f49"},{"version":"475a90aa5257544f4e204f265d03aaaab46f351f215a6973252307700a98ec3b","signature":"ed062bf7a44961474312776691fef0f3fb9c1b26a69ffff27c80073db0311353"},{"version":"229faf86cd68a721d11b73a0b398ee241a57172cb3eef98351fa6adc4ed96aec","signature":"6bfa5af024804ea22f15370d2feb92958199fd3827bc97bf0487d29fb488925f"},{"version":"634e303df54ddd9c2e20bce6784a7fef1ea06183d75161fbf57e3324d4d6f07e","signature":"de94446f7a45df1aa8cfbe6aba6041f18551e6cee0067f29ecbe8615baf45360"},{"version":"31e758d6640ef652be142972a0002fed5ff026c20a61c51266ac73463c34e4fb","signature":"8404e591edea1a6f802f4099ced1c87a143250519ae18e88be1d8bf0eaf6ace5"},"8b06ac3faeacb8484d84ddb44571d8f410697f98d7bfa86c0fda60373a9f5215","96d14f21b7652903852eef49379d04dbda28c16ed36468f8c9fa08f7c14c9538"],"root":[82,84,[86,91]],"options":{"allowJs":true,"checkJs":true,"composite":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":7,"outDir":"./","skipLibCheck":true,"strict":true,"target":9},"fileIdsList":[[79,80],[68,73],[64,65],[64],[66],[63],[63,69],[70],[65,68,69,70,71,72],[62,63,64,66,67],[62,63,66],[78,79],[78],[76],[75,76,77],[73,74,81],[73,82,83],[73,82],[73,74,81,85,90],[82,86],[82,87,88],[74,81,82,83,85]],"referencedMap":[[81,1],[85,2],[66,3],[65,4],[67,5],[69,6],[70,7],[74,8],[73,9],[68,10],[83,3],[64,11],[76,12],[79,13],[80,14],[78,15],[82,16],[84,17],[90,18],[91,19],[87,20],[88,20],[89,21],[86,22]],"exportedModulesMap":[[81,1],[85,2],[66,3],[65,4],[67,5],[69,6],[70,7],[74,8],[73,9],[68,10],[83,3],[64,11],[76,12],[79,13],[80,14],[78,15],[82,16],[90,18]],"semanticDiagnosticsPerFile":[81,62,85,66,72,65,67,69,70,63,74,73,68,83,64,71,75,76,79,80,77,78,59,60,10,11,15,14,2,16,17,18,19,20,21,22,23,3,4,24,28,25,26,27,29,30,31,5,32,33,34,35,6,39,36,37,38,40,7,41,46,47,42,43,44,45,8,51,48,49,50,52,9,53,61,54,55,58,56,57,1,13,12,92,93,82,84,90,91,87,88,89,86],"latestChangedDtsFile":"./src/shard.d.ts"},"version":"5.3.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web3-storage/pail",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.0",
|
|
4
4
|
"description": "DAG based key value store.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -122,6 +122,12 @@
|
|
|
122
122
|
"bin": {
|
|
123
123
|
"pail": "./cli.js"
|
|
124
124
|
},
|
|
125
|
+
"scripts": {
|
|
126
|
+
"build": "tsc --build",
|
|
127
|
+
"test": "mocha test/*.test.js",
|
|
128
|
+
"coverage": "c8 -r html -r text npm test",
|
|
129
|
+
"lint": "standard"
|
|
130
|
+
},
|
|
125
131
|
"keywords": [
|
|
126
132
|
"bucket",
|
|
127
133
|
"KV",
|
|
@@ -140,7 +146,6 @@
|
|
|
140
146
|
"@ipld/car": "^5.2.4",
|
|
141
147
|
"@ipld/dag-cbor": "^9.0.6",
|
|
142
148
|
"archy": "^1.0.0",
|
|
143
|
-
"cborg": "^4.0.7",
|
|
144
149
|
"cli-color": "^2.0.3",
|
|
145
150
|
"multiformats": "^12.1.3",
|
|
146
151
|
"sade": "^1.8.1"
|
|
@@ -164,11 +169,5 @@
|
|
|
164
169
|
"ignore": [
|
|
165
170
|
"*.ts"
|
|
166
171
|
]
|
|
167
|
-
},
|
|
168
|
-
"scripts": {
|
|
169
|
-
"build": "tsc --build",
|
|
170
|
-
"test": "mocha test/*.test.js",
|
|
171
|
-
"coverage": "c8 -r html -r text npm test",
|
|
172
|
-
"lint": "standard"
|
|
173
172
|
}
|
|
174
|
-
}
|
|
173
|
+
}
|
package/src/api.ts
CHANGED
|
@@ -23,9 +23,7 @@ export interface Shard extends ShardConfig {
|
|
|
23
23
|
|
|
24
24
|
export type ShardLink = Link<Shard, typeof dagCBOR.code, typeof sha256.code, 1>
|
|
25
25
|
|
|
26
|
-
export interface ShardBlockView extends BlockView<Shard, typeof dagCBOR.code, typeof sha256.code, 1> {
|
|
27
|
-
prefix: string
|
|
28
|
-
}
|
|
26
|
+
export interface ShardBlockView extends BlockView<Shard, typeof dagCBOR.code, typeof sha256.code, 1> {}
|
|
29
27
|
|
|
30
28
|
export interface ShardDiff {
|
|
31
29
|
additions: ShardBlockView[]
|
|
@@ -38,10 +36,17 @@ export interface BlockFetcher {
|
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
export interface ShardConfig {
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
|
|
39
|
+
/** Shard compatibility version. */
|
|
40
|
+
version: number
|
|
41
|
+
/**
|
|
42
|
+
* Characters allowed in keys, referring to a known character set.
|
|
43
|
+
* e.g. "ascii" refers to the printable ASCII characters in the code range 32-126.
|
|
44
|
+
*/
|
|
45
|
+
keyChars: string
|
|
46
|
+
/** Max key size in bytes - default 4096 bytes. */
|
|
47
|
+
maxKeySize: number
|
|
48
|
+
/** The key prefix from the root to this shard. */
|
|
49
|
+
prefix: string
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
export type ShardOptions = Partial<ShardConfig>
|
package/src/batch/api.ts
CHANGED
|
@@ -28,13 +28,11 @@ export {
|
|
|
28
28
|
|
|
29
29
|
export interface BatcherShard extends ShardConfig {
|
|
30
30
|
base?: ShardBlockView
|
|
31
|
-
prefix: string
|
|
32
31
|
entries: BatcherShardEntry[]
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
export interface BatcherShardInit extends ShardOptions {
|
|
36
35
|
base?: ShardBlockView
|
|
37
|
-
prefix?: string
|
|
38
36
|
entries?: BatcherShardEntry[]
|
|
39
37
|
}
|
|
40
38
|
|
package/src/batch/index.js
CHANGED
|
@@ -13,17 +13,19 @@ class Batcher {
|
|
|
13
13
|
* @param {API.BlockFetcher} init.blocks Block storage.
|
|
14
14
|
* @param {API.BatcherShardEntry[]} init.entries The entries in this shard.
|
|
15
15
|
* @param {string} init.prefix Key prefix.
|
|
16
|
-
* @param {number} init.
|
|
17
|
-
* @param {
|
|
16
|
+
* @param {number} init.version Shard compatibility version.
|
|
17
|
+
* @param {string} init.keyChars Characters allowed in keys, referring to a known character set.
|
|
18
|
+
* @param {number} init.maxKeySize Max key size in bytes.
|
|
18
19
|
* @param {API.ShardBlockView} init.base Original shard this batcher is based on.
|
|
19
20
|
*/
|
|
20
|
-
constructor ({ blocks, entries, prefix,
|
|
21
|
+
constructor ({ blocks, entries, prefix, version, keyChars, maxKeySize, base }) {
|
|
21
22
|
this.blocks = blocks
|
|
22
23
|
this.prefix = prefix
|
|
23
24
|
this.entries = [...entries]
|
|
24
25
|
this.base = base
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
26
|
+
this.version = version
|
|
27
|
+
this.keyChars = keyChars
|
|
28
|
+
this.maxKeySize = maxKeySize
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/**
|
|
@@ -46,12 +48,11 @@ class Batcher {
|
|
|
46
48
|
* @param {object} init
|
|
47
49
|
* @param {API.BlockFetcher} init.blocks Block storage.
|
|
48
50
|
* @param {API.ShardLink} init.link CID of the shard block.
|
|
49
|
-
* @param {string} init.prefix
|
|
50
51
|
*/
|
|
51
|
-
static async create ({ blocks, link
|
|
52
|
+
static async create ({ blocks, link }) {
|
|
52
53
|
const shards = new ShardFetcher(blocks)
|
|
53
54
|
const base = await shards.get(link)
|
|
54
|
-
return new Batcher({ blocks,
|
|
55
|
+
return new Batcher({ blocks, base, ...base.value })
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
@@ -169,8 +170,8 @@ export const traverse = async (shards, key, shard) => {
|
|
|
169
170
|
if (key <= k) break
|
|
170
171
|
if (key.startsWith(k) && Array.isArray(v)) {
|
|
171
172
|
if (Shard.isShardLink(v[0])) {
|
|
172
|
-
const blk = await shards.get(v[0]
|
|
173
|
-
const batcher = BatcherShard.create({ base: blk,
|
|
173
|
+
const blk = await shards.get(v[0])
|
|
174
|
+
const batcher = BatcherShard.create({ base: blk, ...blk.value })
|
|
174
175
|
shard.entries[i] = [k, v[1] == null ? [batcher] : [batcher, v[1]]]
|
|
175
176
|
return traverse(shards, key.slice(k.length), batcher)
|
|
176
177
|
}
|
|
@@ -208,7 +209,7 @@ export const commit = async shard => {
|
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
const block = await Shard.encodeBlock(Shard.withEntries(entries, shard)
|
|
212
|
+
const block = await Shard.encodeBlock(Shard.withEntries(entries, shard))
|
|
212
213
|
additions.push(block)
|
|
213
214
|
|
|
214
215
|
if (shard.base && shard.base.cid.toString() === block.cid.toString()) {
|
|
@@ -231,7 +232,7 @@ const asShardEntry = entry => /** @type {API.ShardEntry} */ (entry)
|
|
|
231
232
|
* @param {API.ShardLink} root CID of the root shard block.
|
|
232
233
|
* @returns {Promise<API.Batcher>}
|
|
233
234
|
*/
|
|
234
|
-
export const create = (blocks, root) => Batcher.create({ blocks, link: root
|
|
235
|
+
export const create = (blocks, root) => Batcher.create({ blocks, link: root })
|
|
235
236
|
|
|
236
237
|
export class BatchCommittedError extends Error {
|
|
237
238
|
/**
|
|
File without changes
|
package/src/batch/shard.js
CHANGED
|
@@ -1,65 +1,13 @@
|
|
|
1
1
|
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import * as Link from 'multiformats/link'
|
|
3
|
-
import { tokensToLength } from 'cborg/length'
|
|
4
|
-
import { Token, Type } from 'cborg'
|
|
5
2
|
import * as API from './api.js'
|
|
6
3
|
import { configure } from '../shard.js'
|
|
7
4
|
|
|
8
|
-
/** Byte length of a v1, dag-cbor, sha-256 CID */
|
|
9
|
-
const ShardLinkByteLength = 36
|
|
10
|
-
|
|
11
|
-
const CID_TAG = new Token(Type.tag, 42)
|
|
12
|
-
|
|
13
5
|
/**
|
|
14
6
|
* @param {API.BatcherShardInit} [init]
|
|
15
7
|
* @returns {API.BatcherShard}
|
|
16
8
|
*/
|
|
17
9
|
export const create = init => ({
|
|
18
10
|
base: init?.base,
|
|
19
|
-
prefix: init?.prefix ?? '',
|
|
20
11
|
entries: [...init?.entries ?? []],
|
|
21
12
|
...configure(init)
|
|
22
13
|
})
|
|
23
|
-
|
|
24
|
-
/** @param {API.BatcherShard} shard */
|
|
25
|
-
export const encodedLength = (shard) => {
|
|
26
|
-
let entriesLength = 0
|
|
27
|
-
for (const entry of shard.entries) {
|
|
28
|
-
entriesLength += entryEncodedLength(entry)
|
|
29
|
-
}
|
|
30
|
-
const tokens = [
|
|
31
|
-
new Token(Type.map, 3),
|
|
32
|
-
new Token(Type.string, 'entries'),
|
|
33
|
-
new Token(Type.array, shard.entries.length),
|
|
34
|
-
new Token(Type.string, 'maxKeyLength'),
|
|
35
|
-
new Token(Type.uint, shard.maxKeyLength),
|
|
36
|
-
new Token(Type.string, 'maxSize'),
|
|
37
|
-
new Token(Type.uint, shard.maxSize)
|
|
38
|
-
]
|
|
39
|
-
return tokensToLength(tokens) + entriesLength
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** @param {API.BatcherShardEntry} entry */
|
|
43
|
-
const entryEncodedLength = entry => {
|
|
44
|
-
const tokens = [
|
|
45
|
-
new Token(Type.array, entry.length),
|
|
46
|
-
new Token(Type.string, entry[0])
|
|
47
|
-
]
|
|
48
|
-
if (Array.isArray(entry[1])) {
|
|
49
|
-
tokens.push(new Token(Type.array, entry[1].length))
|
|
50
|
-
for (const item of entry[1]) {
|
|
51
|
-
tokens.push(CID_TAG)
|
|
52
|
-
if (Link.isLink(item)) {
|
|
53
|
-
tokens.push(new Token(Type.bytes, { length: item.byteLength + 1 }))
|
|
54
|
-
} else {
|
|
55
|
-
// `item is BatcherShard and does not have a CID yet, however, when it
|
|
56
|
-
// does, it will be this long.
|
|
57
|
-
tokens.push(new Token(Type.bytes, { length: ShardLinkByteLength + 1 }))
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
tokens.push(CID_TAG)
|
|
62
|
-
tokens.push(new Token(Type.bytes, { length: entry[1].byteLength + 1 }))
|
|
63
|
-
}
|
|
64
|
-
return tokensToLength(tokens)
|
|
65
|
-
}
|
package/src/crdt/batch/api.ts
CHANGED
package/src/diff.js
CHANGED
|
@@ -18,11 +18,11 @@ import { ShardFetcher } from './shard.js'
|
|
|
18
18
|
* @param {API.ShardLink} b Comparison DAG.
|
|
19
19
|
* @returns {Promise<CombinedDiff>}
|
|
20
20
|
*/
|
|
21
|
-
export const difference = async (blocks, a, b
|
|
21
|
+
export const difference = async (blocks, a, b) => {
|
|
22
22
|
if (isEqual(a, b)) return { keys: [], shards: { additions: [], removals: [] } }
|
|
23
23
|
|
|
24
24
|
const shards = new ShardFetcher(blocks)
|
|
25
|
-
const [ashard, bshard] = await Promise.all([shards.get(a
|
|
25
|
+
const [ashard, bshard] = await Promise.all([shards.get(a), shards.get(b)])
|
|
26
26
|
|
|
27
27
|
const aents = new Map(ashard.value.entries)
|
|
28
28
|
const bents = new Map(bshard.value.entries)
|
|
@@ -36,19 +36,19 @@ export const difference = async (blocks, a, b, prefix = '') => {
|
|
|
36
36
|
const bval = bents.get(akey)
|
|
37
37
|
if (bval) continue
|
|
38
38
|
if (!Array.isArray(aval)) {
|
|
39
|
-
keys.set(`${ashard.prefix}${akey}`, [aval, null])
|
|
39
|
+
keys.set(`${ashard.value.prefix}${akey}`, [aval, null])
|
|
40
40
|
continue
|
|
41
41
|
}
|
|
42
42
|
// if shard link _with_ value
|
|
43
43
|
if (aval[1] != null) {
|
|
44
|
-
keys.set(`${ashard.prefix}${akey}`, [aval[1], null])
|
|
44
|
+
keys.set(`${ashard.value.prefix}${akey}`, [aval[1], null])
|
|
45
45
|
}
|
|
46
|
-
for await (const s of collect(shards, aval[0]
|
|
46
|
+
for await (const s of collect(shards, aval[0])) {
|
|
47
47
|
for (const [k, v] of s.value.entries) {
|
|
48
48
|
if (!Array.isArray(v)) {
|
|
49
|
-
keys.set(`${s.prefix}${k}`, [v, null])
|
|
49
|
+
keys.set(`${s.value.prefix}${k}`, [v, null])
|
|
50
50
|
} else if (v[1] != null) {
|
|
51
|
-
keys.set(`${s.prefix}${k}`, [v[1], null])
|
|
51
|
+
keys.set(`${s.value.prefix}${k}`, [v[1], null])
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
removals.set(s.cid.toString(), s)
|
|
@@ -60,22 +60,22 @@ export const difference = async (blocks, a, b, prefix = '') => {
|
|
|
60
60
|
const aval = aents.get(bkey)
|
|
61
61
|
if (!Array.isArray(bval)) {
|
|
62
62
|
if (!aval) {
|
|
63
|
-
keys.set(`${bshard.prefix}${bkey}`, [null, bval])
|
|
63
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [null, bval])
|
|
64
64
|
} else if (Array.isArray(aval)) {
|
|
65
|
-
keys.set(`${bshard.prefix}${bkey}`, [aval[1] ?? null, bval])
|
|
65
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [aval[1] ?? null, bval])
|
|
66
66
|
} else if (!isEqual(aval, bval)) {
|
|
67
|
-
keys.set(`${bshard.prefix}${bkey}`, [aval, bval])
|
|
67
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [aval, bval])
|
|
68
68
|
}
|
|
69
69
|
continue
|
|
70
70
|
}
|
|
71
71
|
if (aval && Array.isArray(aval)) { // updated in B
|
|
72
72
|
if (isEqual(aval[0], bval[0])) {
|
|
73
73
|
if (bval[1] != null && (aval[1] == null || !isEqual(aval[1], bval[1]))) {
|
|
74
|
-
keys.set(`${bshard.prefix}${bkey}`, [aval[1] ?? null, bval[1]])
|
|
74
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [aval[1] ?? null, bval[1]])
|
|
75
75
|
}
|
|
76
76
|
continue // updated value?
|
|
77
77
|
}
|
|
78
|
-
const res = await difference(blocks, aval[0], bval[0]
|
|
78
|
+
const res = await difference(blocks, aval[0], bval[0])
|
|
79
79
|
for (const shard of res.shards.additions) {
|
|
80
80
|
additions.set(shard.cid.toString(), shard)
|
|
81
81
|
}
|
|
@@ -87,28 +87,28 @@ export const difference = async (blocks, a, b, prefix = '') => {
|
|
|
87
87
|
}
|
|
88
88
|
} else if (aval) { // updated in B value => link+value
|
|
89
89
|
if (bval[1] == null) {
|
|
90
|
-
keys.set(`${bshard.prefix}${bkey}`, [aval, null])
|
|
90
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [aval, null])
|
|
91
91
|
} else if (!isEqual(aval, bval[1])) {
|
|
92
|
-
keys.set(`${bshard.prefix}${bkey}`, [aval, bval[1]])
|
|
92
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [aval, bval[1]])
|
|
93
93
|
}
|
|
94
|
-
for await (const s of collect(shards, bval[0]
|
|
94
|
+
for await (const s of collect(shards, bval[0])) {
|
|
95
95
|
for (const [k, v] of s.value.entries) {
|
|
96
96
|
if (!Array.isArray(v)) {
|
|
97
|
-
keys.set(`${s.prefix}${k}`, [null, v])
|
|
97
|
+
keys.set(`${s.value.prefix}${k}`, [null, v])
|
|
98
98
|
} else if (v[1] != null) {
|
|
99
|
-
keys.set(`${s.prefix}${k}`, [null, v[1]])
|
|
99
|
+
keys.set(`${s.value.prefix}${k}`, [null, v[1]])
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
additions.set(s.cid.toString(), s)
|
|
103
103
|
}
|
|
104
104
|
} else { // added in B
|
|
105
|
-
keys.set(`${bshard.prefix}${bkey}`, [null, bval[0]])
|
|
106
|
-
for await (const s of collect(shards, bval[0]
|
|
105
|
+
keys.set(`${bshard.value.prefix}${bkey}`, [null, bval[0]])
|
|
106
|
+
for await (const s of collect(shards, bval[0])) {
|
|
107
107
|
for (const [k, v] of s.value.entries) {
|
|
108
108
|
if (!Array.isArray(v)) {
|
|
109
|
-
keys.set(`${s.prefix}${k}`, [null, v])
|
|
109
|
+
keys.set(`${s.value.prefix}${k}`, [null, v])
|
|
110
110
|
} else if (v[1] != null) {
|
|
111
|
-
keys.set(`${s.prefix}${k}`, [null, v[1]])
|
|
111
|
+
keys.set(`${s.value.prefix}${k}`, [null, v[1]])
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
additions.set(s.cid.toString(), s)
|
|
@@ -141,11 +141,11 @@ const isEqual = (a, b) => a.toString() === b.toString()
|
|
|
141
141
|
* @param {API.ShardLink} root
|
|
142
142
|
* @returns {AsyncIterableIterator<API.ShardBlockView>}
|
|
143
143
|
*/
|
|
144
|
-
async function * collect (shards, root
|
|
145
|
-
const shard = await shards.get(root
|
|
144
|
+
async function * collect (shards, root) {
|
|
145
|
+
const shard = await shards.get(root)
|
|
146
146
|
yield shard
|
|
147
|
-
for (const [
|
|
147
|
+
for (const [, v] of shard.value.entries) {
|
|
148
148
|
if (!Array.isArray(v)) continue
|
|
149
|
-
yield * collect(shards, v[0]
|
|
149
|
+
yield * collect(shards, v[0])
|
|
150
150
|
}
|
|
151
151
|
}
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line no-unused-vars
|
|
2
2
|
import * as API from './api.js'
|
|
3
|
-
import { ShardFetcher } from './shard.js'
|
|
3
|
+
import { ShardFetcher, isPrintableASCII } from './shard.js'
|
|
4
4
|
import * as Shard from './shard.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -16,81 +16,105 @@ import * as Shard from './shard.js'
|
|
|
16
16
|
export const put = async (blocks, root, key, value) => {
|
|
17
17
|
const shards = new ShardFetcher(blocks)
|
|
18
18
|
const rshard = await shards.get(root)
|
|
19
|
+
|
|
20
|
+
if (rshard.value.keyChars !== Shard.KeyCharsASCII) {
|
|
21
|
+
throw new Error(`unsupported key character set: ${rshard.value.keyChars}`)
|
|
22
|
+
}
|
|
23
|
+
if (!isPrintableASCII(key)) {
|
|
24
|
+
throw new Error('key contains non-ASCII characters')
|
|
25
|
+
}
|
|
26
|
+
// ensure utf8 encoded key is smaller than max
|
|
27
|
+
if (new TextEncoder().encode(key).length > rshard.value.maxKeySize) {
|
|
28
|
+
throw new Error(`UTF-8 encoded key exceeds max size of ${rshard.value.maxKeySize} bytes`)
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
const path = await traverse(shards, rshard, key)
|
|
20
32
|
const target = path[path.length - 1]
|
|
21
|
-
const skey = key.slice(target.prefix.length) // key within the shard
|
|
33
|
+
const skey = key.slice(target.value.prefix.length) // key within the shard
|
|
22
34
|
|
|
23
35
|
/** @type {API.ShardEntry} */
|
|
24
36
|
let entry = [skey, value]
|
|
37
|
+
let targetEntries = [...target.value.entries]
|
|
25
38
|
|
|
26
39
|
/** @type {API.ShardBlockView[]} */
|
|
27
40
|
const additions = []
|
|
28
41
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (skey.length > target.value.maxKeyLength) {
|
|
32
|
-
const pfxskeys = Array.from(Array(Math.ceil(skey.length / target.value.maxKeyLength)), (_, i) => {
|
|
33
|
-
const start = i * target.value.maxKeyLength
|
|
34
|
-
return {
|
|
35
|
-
prefix: target.prefix + skey.slice(0, start),
|
|
36
|
-
skey: skey.slice(start, start + target.value.maxKeyLength)
|
|
37
|
-
}
|
|
38
|
-
})
|
|
42
|
+
for (const [i, e] of targetEntries.entries()) {
|
|
43
|
+
const [k, v] = e
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
pfxskeys[pfxskeys.length - 1].prefix
|
|
43
|
-
)
|
|
44
|
-
additions.push(child)
|
|
45
|
+
// is this just a replace?
|
|
46
|
+
if (k === skey) break
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// do we need to shard this entry?
|
|
49
|
+
const shortest = k.length < skey.length ? k : skey
|
|
50
|
+
const other = shortest === k ? skey : k
|
|
51
|
+
let common = ''
|
|
52
|
+
for (const char of shortest) {
|
|
53
|
+
const next = common + char
|
|
54
|
+
if (!other.startsWith(next)) break
|
|
55
|
+
common = next
|
|
52
56
|
}
|
|
57
|
+
if (common.length) {
|
|
58
|
+
/** @type {API.ShardEntry[]} */
|
|
59
|
+
let entries = []
|
|
60
|
+
|
|
61
|
+
// if the existing entry key or new key is equal to the common prefix,
|
|
62
|
+
// then the existing value / new value needs to persist in the parent
|
|
63
|
+
// shard. Otherwise they persist in this new shard.
|
|
64
|
+
if (common !== skey) {
|
|
65
|
+
entries = Shard.putEntry(entries, [skey.slice(common.length), value])
|
|
66
|
+
}
|
|
67
|
+
if (common !== k) {
|
|
68
|
+
entries = Shard.putEntry(entries, [k.slice(common.length), v])
|
|
69
|
+
}
|
|
53
70
|
|
|
54
|
-
|
|
55
|
-
|
|
71
|
+
let child = await Shard.encodeBlock(
|
|
72
|
+
Shard.withEntries(entries, { ...target.value, prefix: target.value.prefix + common })
|
|
73
|
+
)
|
|
74
|
+
additions.push(child)
|
|
75
|
+
|
|
76
|
+
// need to spread as access by index does not consider utf-16 surrogates
|
|
77
|
+
const commonChars = [...common]
|
|
78
|
+
|
|
79
|
+
// create parent shards for each character of the common prefix
|
|
80
|
+
for (let i = commonChars.length - 1; i > 0; i--) {
|
|
81
|
+
const parentConfig = { ...target.value, prefix: target.value.prefix + commonChars.slice(0, i).join('') }
|
|
82
|
+
/** @type {API.ShardEntryLinkValue | API.ShardEntryValueValue | API.ShardEntryLinkAndValueValue} */
|
|
83
|
+
let parentValue
|
|
84
|
+
// if the first iteration and the existing entry key is equal to the
|
|
85
|
+
// common prefix, then existing value needs to persist in this parent
|
|
86
|
+
if (i === commonChars.length - 1 && common === k) {
|
|
87
|
+
if (Array.isArray(v)) throw new Error('found a shard link when expecting a value')
|
|
88
|
+
parentValue = [child.cid, v]
|
|
89
|
+
} else if (i === commonChars.length - 1 && common === skey) {
|
|
90
|
+
parentValue = [child.cid, value]
|
|
91
|
+
} else {
|
|
92
|
+
parentValue = [child.cid]
|
|
93
|
+
}
|
|
94
|
+
const parent = await Shard.encodeBlock(Shard.withEntries([[commonChars[i], parentValue]], parentConfig))
|
|
95
|
+
additions.push(parent)
|
|
96
|
+
child = parent
|
|
97
|
+
}
|
|
56
98
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
.map(([k, v]) => [k.slice(prefix.length), v]),
|
|
69
|
-
shard
|
|
70
|
-
),
|
|
71
|
-
target.prefix + prefix
|
|
72
|
-
)
|
|
73
|
-
additions.push(block)
|
|
74
|
-
|
|
75
|
-
/** @type {API.ShardEntryLinkValue | API.ShardEntryLinkAndValueValue} */
|
|
76
|
-
let value
|
|
77
|
-
const pfxmatch = matches.find(([k]) => k === prefix)
|
|
78
|
-
if (pfxmatch) {
|
|
79
|
-
if (Array.isArray(pfxmatch[1])) {
|
|
80
|
-
// should not happen! all entries with this prefix should have been
|
|
81
|
-
// placed within this shard already.
|
|
82
|
-
throw new Error(`expected "${prefix}" to be a shard value but found a shard link`)
|
|
99
|
+
// remove the sharded entry
|
|
100
|
+
targetEntries.splice(i, 1)
|
|
101
|
+
|
|
102
|
+
// create the entry that will be added to target
|
|
103
|
+
if (commonChars.length === 1 && common === k) {
|
|
104
|
+
if (Array.isArray(v)) throw new Error('found a shard link when expecting a value')
|
|
105
|
+
entry = [commonChars[0], [child.cid, v]]
|
|
106
|
+
} else if (commonChars.length === 1 && common === skey) {
|
|
107
|
+
entry = [commonChars[0], [child.cid, value]]
|
|
108
|
+
} else {
|
|
109
|
+
entry = [commonChars[0], [child.cid]]
|
|
83
110
|
}
|
|
84
|
-
|
|
85
|
-
} else {
|
|
86
|
-
value = [block.cid]
|
|
111
|
+
break
|
|
87
112
|
}
|
|
88
|
-
|
|
89
|
-
shard.entries = shard.entries.filter(e => matches.every(m => e[0] !== m[0]))
|
|
90
|
-
shard = Shard.withEntries(Shard.putEntry(shard.entries, [prefix, value]), shard)
|
|
91
|
-
child = await Shard.encodeBlock(shard, target.prefix)
|
|
92
113
|
}
|
|
93
114
|
|
|
115
|
+
const shard = Shard.withEntries(Shard.putEntry(targetEntries, entry), target.value)
|
|
116
|
+
let child = await Shard.encodeBlock(shard)
|
|
117
|
+
|
|
94
118
|
// if no change in the target then we're done
|
|
95
119
|
if (child.cid.toString() === target.cid.toString()) {
|
|
96
120
|
return { root, additions: [], removals: [] }
|
|
@@ -98,10 +122,10 @@ export const put = async (blocks, root, key, value) => {
|
|
|
98
122
|
|
|
99
123
|
additions.push(child)
|
|
100
124
|
|
|
101
|
-
// path is root ->
|
|
125
|
+
// path is root -> target, so work backwards, propagating the new shard CID
|
|
102
126
|
for (let i = path.length - 2; i >= 0; i--) {
|
|
103
127
|
const parent = path[i]
|
|
104
|
-
const key = child.prefix.slice(parent.prefix.length)
|
|
128
|
+
const key = child.value.prefix.slice(parent.value.prefix.length)
|
|
105
129
|
const value = Shard.withEntries(
|
|
106
130
|
parent.value.entries.map((entry) => {
|
|
107
131
|
const [k, v] = entry
|
|
@@ -112,7 +136,7 @@ export const put = async (blocks, root, key, value) => {
|
|
|
112
136
|
parent.value
|
|
113
137
|
)
|
|
114
138
|
|
|
115
|
-
child = await Shard.encodeBlock(value
|
|
139
|
+
child = await Shard.encodeBlock(value)
|
|
116
140
|
additions.push(child)
|
|
117
141
|
}
|
|
118
142
|
|
|
@@ -133,7 +157,7 @@ export const get = async (blocks, root, key) => {
|
|
|
133
157
|
const rshard = await shards.get(root)
|
|
134
158
|
const path = await traverse(shards, rshard, key)
|
|
135
159
|
const target = path[path.length - 1]
|
|
136
|
-
const skey = key.slice(target.prefix.length) // key within the shard
|
|
160
|
+
const skey = key.slice(target.value.prefix.length) // key within the shard
|
|
137
161
|
const entry = target.value.entries.find(([k]) => k === skey)
|
|
138
162
|
if (!entry) return
|
|
139
163
|
return Array.isArray(entry[1]) ? entry[1][1] : entry[1]
|
|
@@ -153,7 +177,7 @@ export const del = async (blocks, root, key) => {
|
|
|
153
177
|
const rshard = await shards.get(root)
|
|
154
178
|
const path = await traverse(shards, rshard, key)
|
|
155
179
|
const target = path[path.length - 1]
|
|
156
|
-
const skey = key.slice(target.prefix.length) // key within the shard
|
|
180
|
+
const skey = key.slice(target.value.prefix.length) // key within the shard
|
|
157
181
|
|
|
158
182
|
const entryidx = target.value.entries.findIndex(([k]) => k === skey)
|
|
159
183
|
if (entryidx === -1) return { root, additions: [], removals: [] }
|
|
@@ -192,13 +216,13 @@ export const del = async (blocks, root, key) => {
|
|
|
192
216
|
}
|
|
193
217
|
}
|
|
194
218
|
|
|
195
|
-
let child = await Shard.encodeBlock(shard
|
|
219
|
+
let child = await Shard.encodeBlock(shard)
|
|
196
220
|
additions.push(child)
|
|
197
221
|
|
|
198
222
|
// path is root -> shard, so work backwards, propagating the new shard CID
|
|
199
223
|
for (let i = path.length - 2; i >= 0; i--) {
|
|
200
224
|
const parent = path[i]
|
|
201
|
-
const key = child.prefix.slice(parent.prefix.length)
|
|
225
|
+
const key = child.value.prefix.slice(parent.value.prefix.length)
|
|
202
226
|
const value = Shard.withEntries(
|
|
203
227
|
parent.value.entries.map((entry) => {
|
|
204
228
|
const [k, v] = entry
|
|
@@ -209,7 +233,7 @@ export const del = async (blocks, root, key) => {
|
|
|
209
233
|
parent.value
|
|
210
234
|
)
|
|
211
235
|
|
|
212
|
-
child = await Shard.encodeBlock(value
|
|
236
|
+
child = await Shard.encodeBlock(value)
|
|
213
237
|
additions.push(child)
|
|
214
238
|
}
|
|
215
239
|
|
|
@@ -234,7 +258,7 @@ export const entries = async function * (blocks, root, options = {}) {
|
|
|
234
258
|
/** @returns {AsyncIterableIterator<API.ShardValueEntry>} */
|
|
235
259
|
async function * ents (shard) {
|
|
236
260
|
for (const entry of shard.value.entries) {
|
|
237
|
-
const key = shard.prefix + entry[0]
|
|
261
|
+
const key = shard.value.prefix + entry[0]
|
|
238
262
|
|
|
239
263
|
if (Array.isArray(entry[1])) {
|
|
240
264
|
if (entry[1][1]) {
|
|
@@ -251,7 +275,7 @@ export const entries = async function * (blocks, root, options = {}) {
|
|
|
251
275
|
continue
|
|
252
276
|
}
|
|
253
277
|
}
|
|
254
|
-
yield * ents(await shards.get(entry[1][0]
|
|
278
|
+
yield * ents(await shards.get(entry[1][0]))
|
|
255
279
|
} else {
|
|
256
280
|
if (prefix && !key.startsWith(prefix)) {
|
|
257
281
|
continue
|
|
@@ -277,7 +301,7 @@ const traverse = async (shards, shard, key) => {
|
|
|
277
301
|
for (const [k, v] of shard.value.entries) {
|
|
278
302
|
if (key === k) return [shard]
|
|
279
303
|
if (key.startsWith(k) && Array.isArray(v)) {
|
|
280
|
-
const path = await traverse(shards, await shards.get(v[0]
|
|
304
|
+
const path = await traverse(shards, await shards.get(v[0]), key.slice(k.length))
|
|
281
305
|
return [shard, ...path]
|
|
282
306
|
}
|
|
283
307
|
}
|
package/src/shard.js
CHANGED
|
@@ -2,15 +2,11 @@ import * as Link from 'multiformats/link'
|
|
|
2
2
|
import { Block, encode, decode } from 'multiformats/block'
|
|
3
3
|
import { sha256 } from 'multiformats/hashes/sha2'
|
|
4
4
|
import * as dagCBOR from '@ipld/dag-cbor'
|
|
5
|
-
import { tokensToLength } from 'cborg/length'
|
|
6
|
-
import { Token, Type } from 'cborg'
|
|
7
5
|
// eslint-disable-next-line no-unused-vars
|
|
8
6
|
import * as API from './api.js'
|
|
9
7
|
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
|
|
13
|
-
const CID_TAG = new Token(Type.tag, 42)
|
|
8
|
+
export const KeyCharsASCII = 'ascii'
|
|
9
|
+
export const MaxKeySize = 4096
|
|
14
10
|
|
|
15
11
|
/**
|
|
16
12
|
* @extends {Block<API.Shard, typeof dagCBOR.code, typeof sha256.code, 1>}
|
|
@@ -22,12 +18,10 @@ export class ShardBlock extends Block {
|
|
|
22
18
|
* @param {API.ShardLink} config.cid
|
|
23
19
|
* @param {API.Shard} config.value
|
|
24
20
|
* @param {Uint8Array} config.bytes
|
|
25
|
-
* @param {string} config.prefix
|
|
26
21
|
*/
|
|
27
|
-
constructor ({ cid, value, bytes
|
|
22
|
+
constructor ({ cid, value, bytes }) {
|
|
28
23
|
// @ts-expect-error
|
|
29
24
|
super({ cid, value, bytes })
|
|
30
|
-
this.prefix = prefix
|
|
31
25
|
}
|
|
32
26
|
|
|
33
27
|
/** @param {API.ShardOptions} [options] */
|
|
@@ -47,8 +41,10 @@ export const create = (options) => ({ entries: [], ...configure(options) })
|
|
|
47
41
|
* @returns {API.ShardConfig}
|
|
48
42
|
*/
|
|
49
43
|
export const configure = (options) => ({
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
version: 1,
|
|
45
|
+
keyChars: options?.keyChars ?? KeyCharsASCII,
|
|
46
|
+
maxKeySize: options?.maxKeySize ?? MaxKeySize,
|
|
47
|
+
prefix: options?.prefix ?? ''
|
|
52
48
|
})
|
|
53
49
|
|
|
54
50
|
/**
|
|
@@ -63,39 +59,39 @@ const decodeCache = new WeakMap()
|
|
|
63
59
|
|
|
64
60
|
/**
|
|
65
61
|
* @param {API.Shard} value
|
|
66
|
-
* @param {string} [prefix]
|
|
67
62
|
* @returns {Promise<API.ShardBlockView>}
|
|
68
63
|
*/
|
|
69
|
-
export const encodeBlock = async
|
|
64
|
+
export const encodeBlock = async value => {
|
|
70
65
|
const { cid, bytes } = await encode({ value, codec: dagCBOR, hasher: sha256 })
|
|
71
|
-
const block = new ShardBlock({ cid, value, bytes
|
|
66
|
+
const block = new ShardBlock({ cid, value, bytes })
|
|
72
67
|
decodeCache.set(block.bytes, block)
|
|
73
68
|
return block
|
|
74
69
|
}
|
|
75
70
|
|
|
76
71
|
/**
|
|
77
72
|
* @param {Uint8Array} bytes
|
|
78
|
-
* @param {string} [prefix]
|
|
79
73
|
* @returns {Promise<API.ShardBlockView>}
|
|
80
74
|
*/
|
|
81
|
-
export const decodeBlock = async
|
|
75
|
+
export const decodeBlock = async bytes => {
|
|
82
76
|
const block = decodeCache.get(bytes)
|
|
83
77
|
if (block) return block
|
|
84
78
|
const { cid, value } = await decode({ bytes, codec: dagCBOR, hasher: sha256 })
|
|
85
79
|
if (!isShard(value)) throw new Error(`invalid shard: ${cid}`)
|
|
86
|
-
return new ShardBlock({ cid, value, bytes
|
|
80
|
+
return new ShardBlock({ cid, value, bytes })
|
|
87
81
|
}
|
|
88
82
|
|
|
89
83
|
/**
|
|
90
84
|
* @param {any} value
|
|
91
85
|
* @returns {value is API.Shard}
|
|
92
86
|
*/
|
|
93
|
-
export const isShard =
|
|
87
|
+
export const isShard = value =>
|
|
94
88
|
value != null &&
|
|
95
89
|
typeof value === 'object' &&
|
|
96
90
|
Array.isArray(value.entries) &&
|
|
97
|
-
|
|
98
|
-
typeof value.
|
|
91
|
+
value.version === 1 &&
|
|
92
|
+
typeof value.maxKeySize === 'number' &&
|
|
93
|
+
typeof value.keyChars === 'string' &&
|
|
94
|
+
typeof value.prefix === 'string'
|
|
99
95
|
|
|
100
96
|
/**
|
|
101
97
|
* @param {any} value
|
|
@@ -113,13 +109,12 @@ export class ShardFetcher {
|
|
|
113
109
|
|
|
114
110
|
/**
|
|
115
111
|
* @param {API.ShardLink} link
|
|
116
|
-
* @param {string} [prefix]
|
|
117
112
|
* @returns {Promise<API.ShardBlockView>}
|
|
118
113
|
*/
|
|
119
|
-
async get (link
|
|
114
|
+
async get (link) {
|
|
120
115
|
const block = await this._blocks.get(link)
|
|
121
116
|
if (!block) throw new Error(`missing block: ${link}`)
|
|
122
|
-
return decodeBlock(block.bytes
|
|
117
|
+
return decodeBlock(block.bytes)
|
|
123
118
|
}
|
|
124
119
|
}
|
|
125
120
|
|
|
@@ -177,72 +172,9 @@ export const putEntry = (target, newEntry) => {
|
|
|
177
172
|
}
|
|
178
173
|
|
|
179
174
|
entries.push(newEntry)
|
|
180
|
-
return entries
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @param {API.ShardEntry[]} entries
|
|
185
|
-
* @param {string} skey Shard key to use as a base.
|
|
186
|
-
*/
|
|
187
|
-
export const findCommonPrefix = (entries, skey) => {
|
|
188
|
-
const startidx = entries.findIndex(([k]) => skey === k)
|
|
189
|
-
if (startidx === -1) throw new Error(`key not found in shard: ${skey}`)
|
|
190
|
-
let i = startidx
|
|
191
|
-
/** @type {string} */
|
|
192
|
-
let pfx
|
|
193
|
-
while (true) {
|
|
194
|
-
pfx = entries[i][0].slice(0, -1)
|
|
195
|
-
if (pfx.length) {
|
|
196
|
-
while (true) {
|
|
197
|
-
const matches = entries.filter(entry => entry[0].startsWith(pfx))
|
|
198
|
-
if (matches.length > 1) return { prefix: pfx, matches }
|
|
199
|
-
pfx = pfx.slice(0, -1)
|
|
200
|
-
if (!pfx.length) break
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
i++
|
|
204
|
-
if (i >= entries.length) {
|
|
205
|
-
i = 0
|
|
206
|
-
}
|
|
207
|
-
if (i === startidx) {
|
|
208
|
-
return
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
175
|
|
|
213
|
-
|
|
214
|
-
export const encodedLength = (shard) => {
|
|
215
|
-
let entriesLength = 0
|
|
216
|
-
for (const entry of shard.entries) {
|
|
217
|
-
entriesLength += entryEncodedLength(entry)
|
|
218
|
-
}
|
|
219
|
-
const tokens = [
|
|
220
|
-
new Token(Type.map, 3),
|
|
221
|
-
new Token(Type.string, 'entries'),
|
|
222
|
-
new Token(Type.array, shard.entries.length),
|
|
223
|
-
new Token(Type.string, 'maxKeyLength'),
|
|
224
|
-
new Token(Type.uint, shard.maxKeyLength),
|
|
225
|
-
new Token(Type.string, 'maxSize'),
|
|
226
|
-
new Token(Type.uint, shard.maxSize)
|
|
227
|
-
]
|
|
228
|
-
return tokensToLength(tokens) + entriesLength
|
|
176
|
+
return entries
|
|
229
177
|
}
|
|
230
178
|
|
|
231
|
-
/** @param {
|
|
232
|
-
const
|
|
233
|
-
const tokens = [
|
|
234
|
-
new Token(Type.array, entry.length),
|
|
235
|
-
new Token(Type.string, entry[0])
|
|
236
|
-
]
|
|
237
|
-
if (Array.isArray(entry[1])) {
|
|
238
|
-
tokens.push(new Token(Type.array, entry[1].length))
|
|
239
|
-
for (const link of entry[1]) {
|
|
240
|
-
tokens.push(CID_TAG)
|
|
241
|
-
tokens.push(new Token(Type.bytes, { length: link.byteLength + 1 }))
|
|
242
|
-
}
|
|
243
|
-
} else {
|
|
244
|
-
tokens.push(CID_TAG)
|
|
245
|
-
tokens.push(new Token(Type.bytes, { length: entry[1].byteLength + 1 }))
|
|
246
|
-
}
|
|
247
|
-
return tokensToLength(tokens)
|
|
248
|
-
}
|
|
179
|
+
/** @param {string} s */
|
|
180
|
+
export const isPrintableASCII = s => /^[\x20-\x7E]*$/.test(s)
|