@autonomys/auto-drive 0.6.3 → 0.6.5
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 +21 -0
- package/dist/ipld/builders.d.ts +11 -0
- package/dist/ipld/builders.d.ts.map +1 -0
- package/dist/ipld/builders.js +13 -0
- package/dist/ipld/chunker.d.ts +5 -0
- package/dist/ipld/chunker.d.ts.map +1 -1
- package/dist/ipld/chunker.js +22 -7
- package/dist/ipld/nodes.d.ts +5 -1
- package/dist/ipld/nodes.d.ts.map +1 -1
- package/dist/ipld/nodes.js +32 -3
- package/dist/metadata/offchain/file.d.ts.map +1 -1
- package/dist/metadata/offchain/file.js +4 -3
- package/dist/metadata/onchain/protobuf/OnchainMetadata.d.ts +3 -1
- package/dist/metadata/onchain/protobuf/OnchainMetadata.d.ts.map +1 -1
- package/dist/metadata/onchain/protobuf/OnchainMetadata.js +4 -0
- package/package.json +2 -2
- package/src/ipld/builders.ts +38 -0
- package/src/ipld/chunker.ts +33 -14
- package/src/ipld/nodes.ts +68 -3
- package/src/metadata/onchain/protobuf/OnchainMetadata.proto +2 -0
- package/src/metadata/onchain/protobuf/OnchainMetadata.ts +6 -2
- package/tests/chunker.spec.ts +37 -2
- package/tests/nodes.spec.ts +7 -3
package/README.md
CHANGED
|
@@ -128,6 +128,27 @@ const cidString = cidToString(cid)
|
|
|
128
128
|
console.log(`CID of the file DAG: ${cidString}`)
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
+
### Example: Converting Metadata To DAG
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
import {
|
|
135
|
+
createMetadataIPLDDag,
|
|
136
|
+
cidOfNode,
|
|
137
|
+
cidToString,
|
|
138
|
+
type OffchainMetadata,
|
|
139
|
+
} from '@autonomys/auto-drive'
|
|
140
|
+
import fs from 'fs'
|
|
141
|
+
|
|
142
|
+
const metadata: OffchainMetadata = fs.readFileSync('path/to/your/metadata.json')
|
|
143
|
+
|
|
144
|
+
const dag = createMetadataIPLDDag(metadata)
|
|
145
|
+
|
|
146
|
+
const cid = cidOfNode(dag.headCID)
|
|
147
|
+
const cidString = cidToString(cid)
|
|
148
|
+
|
|
149
|
+
console.log(`CID of the metadata DAG: ${cidString}`)
|
|
150
|
+
```
|
|
151
|
+
|
|
131
152
|
## License
|
|
132
153
|
|
|
133
154
|
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PBNode } from '@ipld/dag-pb';
|
|
2
|
+
import { CID } from 'multiformats/cid';
|
|
3
|
+
export interface Builders {
|
|
4
|
+
inlink: (links: CID[], size: number, linkDepth: number, chunkSize: number) => PBNode;
|
|
5
|
+
chunk: (data: Buffer) => PBNode;
|
|
6
|
+
root: (links: CID[], size: number, linkDepth: number, name?: string, maxNodeSize?: number) => PBNode;
|
|
7
|
+
single: (data: Buffer, filename?: string) => PBNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const metadataBuilders: Builders;
|
|
10
|
+
export declare const fileBuilders: Builders;
|
|
11
|
+
//# sourceMappingURL=builders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builders.d.ts","sourceRoot":"","sources":["../../src/ipld/builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAYtC,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IACpF,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IAC/B,IAAI,EAAE,CACJ,KAAK,EAAE,GAAG,EAAE,EACZ,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM,KACjB,MAAM,CAAA;IACX,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CACpD;AACD,eAAO,MAAM,gBAAgB,EAAE,QAK9B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,QAK1B,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createChunkedFileIpldNode, createChunkedMetadataIpldNode, createFileChunkIpldNode, createFileInlinkIpldNode, createMetadataChunkIpldNode, createMetadataInlinkIpldNode, createSingleFileIpldNode, createSingleMetadataIpldNode, } from './nodes.js';
|
|
2
|
+
export const metadataBuilders = {
|
|
3
|
+
inlink: createMetadataInlinkIpldNode,
|
|
4
|
+
chunk: createMetadataChunkIpldNode,
|
|
5
|
+
root: createChunkedMetadataIpldNode,
|
|
6
|
+
single: createSingleMetadataIpldNode,
|
|
7
|
+
};
|
|
8
|
+
export const fileBuilders = {
|
|
9
|
+
inlink: createFileInlinkIpldNode,
|
|
10
|
+
chunk: createFileChunkIpldNode,
|
|
11
|
+
root: createChunkedFileIpldNode,
|
|
12
|
+
single: createSingleFileIpldNode,
|
|
13
|
+
};
|
package/dist/ipld/chunker.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PBNode } from '@ipld/dag-pb';
|
|
2
2
|
import { CID } from 'multiformats';
|
|
3
|
+
import { OffchainMetadata } from '../metadata/index.js';
|
|
3
4
|
export declare const DEFAULT_MAX_CHUNK_SIZE: number;
|
|
4
5
|
export declare const DEFAULT_MAX_LINK_PER_NODE: number;
|
|
5
6
|
export interface IPLDDag {
|
|
@@ -10,6 +11,10 @@ export declare const createFileIPLDDag: (file: Buffer, filename?: string, { chun
|
|
|
10
11
|
chunkSize: number;
|
|
11
12
|
maxLinkPerNode: number;
|
|
12
13
|
}) => IPLDDag;
|
|
14
|
+
export declare const createMetadataIPLDDag: (metadata: OffchainMetadata, limits?: {
|
|
15
|
+
chunkSize: number;
|
|
16
|
+
maxLinkPerNode: number;
|
|
17
|
+
}) => IPLDDag;
|
|
13
18
|
export declare const createFolderIPLDDag: (children: CID[], name: string, size: number, { maxLinkPerNode }?: {
|
|
14
19
|
maxLinkPerNode: number;
|
|
15
20
|
}) => IPLDDag;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../src/ipld/chunker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../src/ipld/chunker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAKvD,eAAO,MAAM,sBAAsB,QAAY,CAAA;AAC/C,eAAO,MAAM,yBAAyB,QAA8B,CAAA;AAEpE,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,GAAG,CAAA;IACZ,KAAK,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;CACxB;AAED,eAAO,MAAM,iBAAiB,SACtB,MAAM,aACD,MAAM,kCACc;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,KAI3E,OAEF,CAAA;AAED,eAAO,MAAM,qBAAqB,aACtB,gBAAgB,WAClB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,KAIpD,OAIF,CAAA;AAwDD,eAAO,MAAM,mBAAmB,aACpB,GAAG,EAAE,QACT,MAAM,QACN,MAAM,uBACQ;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,KAC7C,OAyBF,CAAA;AAED,eAAO,MAAM,iBAAiB,SACtB,MAAM,YACH,MAAM,KACd,MAOF,CAAA"}
|
package/dist/ipld/chunker.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cidOfNode } from '../cid/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { fileBuilders, metadataBuilders } from './builders.js';
|
|
3
|
+
import { createFolderInlinkIpldNode, createFolderIpldNode } from './nodes.js';
|
|
3
4
|
import { chunkBuffer, encodeNode } from './utils.js';
|
|
4
5
|
export const DEFAULT_MAX_CHUNK_SIZE = 1024 * 64;
|
|
5
6
|
export const DEFAULT_MAX_LINK_PER_NODE = DEFAULT_MAX_CHUNK_SIZE / 64;
|
|
@@ -7,18 +8,32 @@ export const createFileIPLDDag = (file, filename, { chunkSize, maxLinkPerNode }
|
|
|
7
8
|
chunkSize: DEFAULT_MAX_CHUNK_SIZE,
|
|
8
9
|
maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
|
|
9
10
|
}) => {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
return createBufferIPLDDag(file, filename, fileBuilders, { chunkSize, maxLinkPerNode });
|
|
12
|
+
};
|
|
13
|
+
export const createMetadataIPLDDag = (metadata, limits = {
|
|
14
|
+
chunkSize: DEFAULT_MAX_CHUNK_SIZE,
|
|
15
|
+
maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
|
|
16
|
+
}) => {
|
|
17
|
+
const buffer = Buffer.from(JSON.stringify(metadata));
|
|
18
|
+
const name = `${metadata.name}.metadata.json`;
|
|
19
|
+
return createBufferIPLDDag(buffer, name, metadataBuilders, limits);
|
|
20
|
+
};
|
|
21
|
+
const createBufferIPLDDag = (buffer, filename, builders, { chunkSize, maxLinkPerNode } = {
|
|
22
|
+
chunkSize: DEFAULT_MAX_CHUNK_SIZE,
|
|
23
|
+
maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
|
|
24
|
+
}) => {
|
|
25
|
+
if (buffer.length <= chunkSize) {
|
|
26
|
+
const head = builders.single(buffer, filename);
|
|
12
27
|
const headCID = cidOfNode(head);
|
|
13
28
|
return {
|
|
14
29
|
headCID,
|
|
15
30
|
nodes: new Map([[headCID, head]]),
|
|
16
31
|
};
|
|
17
32
|
}
|
|
18
|
-
const bufferChunks = chunkBuffer(
|
|
33
|
+
const bufferChunks = chunkBuffer(buffer, chunkSize);
|
|
19
34
|
const nodes = new Map();
|
|
20
35
|
let CIDs = bufferChunks.map((chunk) => {
|
|
21
|
-
const node =
|
|
36
|
+
const node = builders.chunk(chunk);
|
|
22
37
|
const cid = cidOfNode(node);
|
|
23
38
|
nodes.set(cid, node);
|
|
24
39
|
return cid;
|
|
@@ -28,7 +43,7 @@ export const createFileIPLDDag = (file, filename, { chunkSize, maxLinkPerNode }
|
|
|
28
43
|
const newCIDs = [];
|
|
29
44
|
for (let i = 0; i < CIDs.length; i += maxLinkPerNode) {
|
|
30
45
|
const chunk = CIDs.slice(i, i + maxLinkPerNode);
|
|
31
|
-
const node =
|
|
46
|
+
const node = builders.inlink(chunk, chunk.length, depth, chunkSize);
|
|
32
47
|
const cid = cidOfNode(node);
|
|
33
48
|
nodes.set(cid, node);
|
|
34
49
|
newCIDs.push(cid);
|
|
@@ -36,7 +51,7 @@ export const createFileIPLDDag = (file, filename, { chunkSize, maxLinkPerNode }
|
|
|
36
51
|
depth++;
|
|
37
52
|
CIDs = newCIDs;
|
|
38
53
|
}
|
|
39
|
-
const head =
|
|
54
|
+
const head = builders.root(CIDs, buffer.length, depth, filename, chunkSize);
|
|
40
55
|
const headCID = cidOfNode(head);
|
|
41
56
|
nodes.set(headCID, head);
|
|
42
57
|
return {
|
package/dist/ipld/nodes.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { PBNode } from '@ipld/dag-pb';
|
|
2
2
|
import { CID } from 'multiformats/cid';
|
|
3
3
|
import { OffchainMetadata } from '../metadata/index.js';
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const createFileChunkIpldNode: (data: Buffer) => PBNode;
|
|
5
5
|
export declare const createChunkedFileIpldNode: (links: CID[], size: number, linkDepth: number, name?: string, maxNodeSize?: number) => PBNode;
|
|
6
6
|
export declare const createFileInlinkIpldNode: (links: CID[], size: number, linkDepth: number, maxNodeSize?: number) => PBNode;
|
|
7
7
|
export declare const createSingleFileIpldNode: (data: Buffer, name?: string) => PBNode;
|
|
8
|
+
export declare const createMetadataInlinkIpldNode: (links: CID[], size: number, linkDepth: number, maxNodeSize?: number) => PBNode;
|
|
9
|
+
export declare const createSingleMetadataIpldNode: (data: Buffer, name?: string) => PBNode;
|
|
10
|
+
export declare const createMetadataChunkIpldNode: (data: Buffer) => PBNode;
|
|
11
|
+
export declare const createChunkedMetadataIpldNode: (links: CID[], size: number, linkDepth: number, name?: string, maxNodeSize?: number) => PBNode;
|
|
8
12
|
export declare const createFolderIpldNode: (links: CID[], name: string, linkDepth: number, size: number, maxNodeSize?: number) => PBNode;
|
|
9
13
|
export declare const createFolderInlinkIpldNode: (links: CID[], linkDepth: number, maxNodeSize?: number) => PBNode;
|
|
10
14
|
export declare const createMetadataNode: (metadata: OffchainMetadata, maxNodeSize?: number) => PBNode;
|
package/dist/ipld/nodes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ipld/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAKvD,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/ipld/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,MAAM,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAKvD,eAAO,MAAM,uBAAuB,SAAU,MAAM,KAAG,MASpD,CAAA;AAKH,eAAO,MAAM,yBAAyB,UAC7B,GAAG,EAAE,QACN,MAAM,aACD,MAAM,SACV,MAAM,gBACA,MAAM,KAClB,MAYA,CAAA;AAGH,eAAO,MAAM,wBAAwB,UAC5B,GAAG,EAAE,QACN,MAAM,aACD,MAAM,gBACJ,MAAM,KAClB,MAWA,CAAA;AAKH,eAAO,MAAM,wBAAwB,SAAU,MAAM,SAAS,MAAM,KAAG,MAUpE,CAAA;AAKH,eAAO,MAAM,4BAA4B,UAChC,GAAG,EAAE,QACN,MAAM,aACD,MAAM,gBACJ,MAAM,KAClB,MAWA,CAAA;AAKH,eAAO,MAAM,4BAA4B,SAAU,MAAM,SAAS,MAAM,KAAG,MAUxE,CAAA;AAEH,eAAO,MAAM,2BAA2B,SAAU,MAAM,KAAG,MAQxD,CAAA;AAEH,eAAO,MAAM,6BAA6B,UACjC,GAAG,EAAE,QACN,MAAM,aACD,MAAM,SACV,MAAM,gBACA,MAAM,KAClB,MAYA,CAAA;AAKH,eAAO,MAAM,oBAAoB,UACxB,GAAG,EAAE,QACN,MAAM,aACD,MAAM,QACX,MAAM,gBACC,MAAM,KAClB,MAYA,CAAA;AAEH,eAAO,MAAM,0BAA0B,UAC9B,GAAG,EAAE,aACD,MAAM,gBACJ,MAAM,KAClB,MAUA,CAAA;AAGH,eAAO,MAAM,kBAAkB,aACnB,gBAAgB,gBACb,MAAM,KAClB,MAcF,CAAA"}
|
package/dist/ipld/nodes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createNode } from '@ipld/dag-pb';
|
|
2
2
|
import { encodeIPLDNodeData, MetadataType } from '../metadata/onchain/index.js';
|
|
3
3
|
import { DEFAULT_MAX_CHUNK_SIZE, ensureNodeMaxSize } from './chunker.js';
|
|
4
|
-
/// Creates a chunk ipld node
|
|
5
|
-
export const
|
|
4
|
+
/// Creates a file chunk ipld node
|
|
5
|
+
export const createFileChunkIpldNode = (data) => createNode(encodeIPLDNodeData({
|
|
6
6
|
type: MetadataType.FileChunk,
|
|
7
7
|
size: data.length,
|
|
8
8
|
linkDepth: 0,
|
|
@@ -19,7 +19,6 @@ export const createChunkedFileIpldNode = (links, size, linkDepth, name, maxNodeS
|
|
|
19
19
|
}), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
|
|
20
20
|
// Creates a file ipld node
|
|
21
21
|
// links: the CIDs of the file's contents
|
|
22
|
-
// @todo: add the file's metadata
|
|
23
22
|
export const createFileInlinkIpldNode = (links, size, linkDepth, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
|
|
24
23
|
type: MetadataType.FileInlink,
|
|
25
24
|
size,
|
|
@@ -35,6 +34,36 @@ export const createSingleFileIpldNode = (data, name) => createNode(encodeIPLDNod
|
|
|
35
34
|
linkDepth: 0,
|
|
36
35
|
data,
|
|
37
36
|
}), []);
|
|
37
|
+
// Creates a file ipld node
|
|
38
|
+
// links: the CIDs of the file's contents
|
|
39
|
+
// @todo: add the file's metadata
|
|
40
|
+
export const createMetadataInlinkIpldNode = (links, size, linkDepth, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
|
|
41
|
+
type: MetadataType.FileInlink,
|
|
42
|
+
size,
|
|
43
|
+
linkDepth,
|
|
44
|
+
}), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
|
|
45
|
+
// Creates a file ipld node
|
|
46
|
+
// links: the CIDs of the file's contents
|
|
47
|
+
// @todo: add the file's metadata
|
|
48
|
+
export const createSingleMetadataIpldNode = (data, name) => createNode(encodeIPLDNodeData({
|
|
49
|
+
type: MetadataType.Metadata,
|
|
50
|
+
name,
|
|
51
|
+
size: data.length,
|
|
52
|
+
linkDepth: 0,
|
|
53
|
+
data,
|
|
54
|
+
}), []);
|
|
55
|
+
export const createMetadataChunkIpldNode = (data) => createNode(encodeIPLDNodeData({
|
|
56
|
+
type: MetadataType.MetadataChunk,
|
|
57
|
+
size: data.length,
|
|
58
|
+
linkDepth: 0,
|
|
59
|
+
data,
|
|
60
|
+
}));
|
|
61
|
+
export const createChunkedMetadataIpldNode = (links, size, linkDepth, name, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
|
|
62
|
+
type: MetadataType.Metadata,
|
|
63
|
+
name,
|
|
64
|
+
size,
|
|
65
|
+
linkDepth,
|
|
66
|
+
}), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
|
|
38
67
|
// Creates a folder ipld node
|
|
39
68
|
// links: the CIDs of the folder's contents
|
|
40
69
|
// @todo: add the folder's metadata
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/metadata/offchain/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,OAAO,
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/metadata/offchain/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,OAAO,EAA8B,MAAM,gBAAgB,CAAA;AAE5F,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,SAAS,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,eAAO,MAAM,YAAY,QAClB,OAAO,aACD,MAAM,SACV,MAAM,aACF,MAAM,KAChB,oBAiBF,CAAA"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { cidOfNode, cidToString } from '../../index.js';
|
|
1
|
+
import { cidOfNode, cidToString, IPLDNodeData } from '../../index.js';
|
|
2
2
|
export const fileMetadata = (dag, totalSize, name, mimeType) => {
|
|
3
|
+
const chunks = Array.from(dag.nodes.values()).filter((n) => n.Data && IPLDNodeData.decode(n.Data).data);
|
|
3
4
|
return {
|
|
4
5
|
type: 'file',
|
|
5
6
|
dataCid: cidToString(dag.headCID),
|
|
6
7
|
name,
|
|
7
8
|
mimeType,
|
|
8
9
|
totalSize,
|
|
9
|
-
totalChunks:
|
|
10
|
-
chunks:
|
|
10
|
+
totalChunks: chunks.length,
|
|
11
|
+
chunks: chunks.map((chunk) => {
|
|
11
12
|
var _a, _b;
|
|
12
13
|
return ({
|
|
13
14
|
cid: cidToString(cidOfNode(chunk)),
|
|
@@ -18,7 +18,9 @@ export declare enum MetadataType {
|
|
|
18
18
|
FileChunk = "FileChunk",
|
|
19
19
|
Folder = "Folder",
|
|
20
20
|
FolderInlink = "FolderInlink",
|
|
21
|
-
Metadata = "Metadata"
|
|
21
|
+
Metadata = "Metadata",
|
|
22
|
+
MetadataInlink = "MetadataInlink",
|
|
23
|
+
MetadataChunk = "MetadataChunk"
|
|
22
24
|
}
|
|
23
25
|
export declare namespace MetadataType {
|
|
24
26
|
const codec: () => Codec<MetadataType>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnchainMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/onchain/protobuf/OnchainMetadata.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,aAAa,EAAuC,MAAM,iBAAiB,CAAA;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,yBAAiB,YAAY,CAAC;IAGrB,MAAM,KAAK,QAAO,KAAK,CAAC,YAAY,CA+E1C,CAAA;IAEM,MAAM,MAAM,QAAS,OAAO,CAAC,YAAY,CAAC,KAAG,UAEnD,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,SAAS,aAAa,CAAC,YAAY,CAAC,KAAG,YAE7F,CAAA;CACF;AAED,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"file":"OnchainMetadata.d.ts","sourceRoot":"","sources":["../../../../src/metadata/onchain/protobuf/OnchainMetadata.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,aAAa,EAAuC,MAAM,iBAAiB,CAAA;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,YAAY,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,UAAU,CAAA;CAClB;AAED,yBAAiB,YAAY,CAAC;IAGrB,MAAM,KAAK,QAAO,KAAK,CAAC,YAAY,CA+E1C,CAAA;IAEM,MAAM,MAAM,QAAS,OAAO,CAAC,YAAY,CAAC,KAAG,UAEnD,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,SAAS,aAAa,CAAC,YAAY,CAAC,KAAG,YAE7F,CAAA;CACF;AAED,oBAAY,YAAY;IACtB,IAAI,SAAS;IACb,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,aAAa,kBAAkB;CAChC;AAaD,yBAAiB,YAAY,CAAC;IACrB,MAAM,KAAK,QAAO,KAAK,CAAC,YAAY,CAE1C,CAAA;CACF"}
|
|
@@ -91,6 +91,8 @@ export var MetadataType;
|
|
|
91
91
|
MetadataType["Folder"] = "Folder";
|
|
92
92
|
MetadataType["FolderInlink"] = "FolderInlink";
|
|
93
93
|
MetadataType["Metadata"] = "Metadata";
|
|
94
|
+
MetadataType["MetadataInlink"] = "MetadataInlink";
|
|
95
|
+
MetadataType["MetadataChunk"] = "MetadataChunk";
|
|
94
96
|
})(MetadataType || (MetadataType = {}));
|
|
95
97
|
var __MetadataTypeValues;
|
|
96
98
|
(function (__MetadataTypeValues) {
|
|
@@ -100,6 +102,8 @@ var __MetadataTypeValues;
|
|
|
100
102
|
__MetadataTypeValues[__MetadataTypeValues["Folder"] = 3] = "Folder";
|
|
101
103
|
__MetadataTypeValues[__MetadataTypeValues["FolderInlink"] = 4] = "FolderInlink";
|
|
102
104
|
__MetadataTypeValues[__MetadataTypeValues["Metadata"] = 5] = "Metadata";
|
|
105
|
+
__MetadataTypeValues[__MetadataTypeValues["MetadataInlink"] = 6] = "MetadataInlink";
|
|
106
|
+
__MetadataTypeValues[__MetadataTypeValues["MetadataChunk"] = 7] = "MetadataChunk";
|
|
103
107
|
})(__MetadataTypeValues || (__MetadataTypeValues = {}));
|
|
104
108
|
(function (MetadataType) {
|
|
105
109
|
MetadataType.codec = () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autonomys/auto-drive",
|
|
3
3
|
"packageManager": "yarn@4.1.1",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"repository": {
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"protons": "^7.6.0",
|
|
40
40
|
"protons-runtime": "^5.5.0"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7beb58a2156bfc8c5bfa62c51c39e83cab48aeef"
|
|
43
43
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { PBNode } from '@ipld/dag-pb'
|
|
2
|
+
import { CID } from 'multiformats/cid'
|
|
3
|
+
import {
|
|
4
|
+
createChunkedFileIpldNode,
|
|
5
|
+
createChunkedMetadataIpldNode,
|
|
6
|
+
createFileChunkIpldNode,
|
|
7
|
+
createFileInlinkIpldNode,
|
|
8
|
+
createMetadataChunkIpldNode,
|
|
9
|
+
createMetadataInlinkIpldNode,
|
|
10
|
+
createSingleFileIpldNode,
|
|
11
|
+
createSingleMetadataIpldNode,
|
|
12
|
+
} from './nodes.js'
|
|
13
|
+
|
|
14
|
+
export interface Builders {
|
|
15
|
+
inlink: (links: CID[], size: number, linkDepth: number, chunkSize: number) => PBNode
|
|
16
|
+
chunk: (data: Buffer) => PBNode
|
|
17
|
+
root: (
|
|
18
|
+
links: CID[],
|
|
19
|
+
size: number,
|
|
20
|
+
linkDepth: number,
|
|
21
|
+
name?: string,
|
|
22
|
+
maxNodeSize?: number,
|
|
23
|
+
) => PBNode
|
|
24
|
+
single: (data: Buffer, filename?: string) => PBNode
|
|
25
|
+
}
|
|
26
|
+
export const metadataBuilders: Builders = {
|
|
27
|
+
inlink: createMetadataInlinkIpldNode,
|
|
28
|
+
chunk: createMetadataChunkIpldNode,
|
|
29
|
+
root: createChunkedMetadataIpldNode,
|
|
30
|
+
single: createSingleMetadataIpldNode,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const fileBuilders: Builders = {
|
|
34
|
+
inlink: createFileInlinkIpldNode,
|
|
35
|
+
chunk: createFileChunkIpldNode,
|
|
36
|
+
root: createChunkedFileIpldNode,
|
|
37
|
+
single: createSingleFileIpldNode,
|
|
38
|
+
}
|
package/src/ipld/chunker.ts
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { PBNode } from '@ipld/dag-pb'
|
|
2
2
|
import { CID } from 'multiformats'
|
|
3
3
|
import { cidOfNode } from '../cid/index.js'
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
createFileInlinkIpldNode,
|
|
8
|
-
createFolderInlinkIpldNode,
|
|
9
|
-
createFolderIpldNode,
|
|
10
|
-
createSingleFileIpldNode,
|
|
11
|
-
} from './nodes.js'
|
|
4
|
+
import { OffchainMetadata } from '../metadata/index.js'
|
|
5
|
+
import { Builders, fileBuilders, metadataBuilders } from './builders.js'
|
|
6
|
+
import { createFolderInlinkIpldNode, createFolderIpldNode } from './nodes.js'
|
|
12
7
|
import { chunkBuffer, encodeNode } from './utils.js'
|
|
13
8
|
|
|
14
9
|
export const DEFAULT_MAX_CHUNK_SIZE = 1024 * 64
|
|
@@ -27,8 +22,32 @@ export const createFileIPLDDag = (
|
|
|
27
22
|
maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
|
|
28
23
|
},
|
|
29
24
|
): IPLDDag => {
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
return createBufferIPLDDag(file, filename, fileBuilders, { chunkSize, maxLinkPerNode })
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const createMetadataIPLDDag = (
|
|
29
|
+
metadata: OffchainMetadata,
|
|
30
|
+
limits: { chunkSize: number; maxLinkPerNode: number } = {
|
|
31
|
+
chunkSize: DEFAULT_MAX_CHUNK_SIZE,
|
|
32
|
+
maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
|
|
33
|
+
},
|
|
34
|
+
): IPLDDag => {
|
|
35
|
+
const buffer = Buffer.from(JSON.stringify(metadata))
|
|
36
|
+
const name = `${metadata.name}.metadata.json`
|
|
37
|
+
return createBufferIPLDDag(buffer, name, metadataBuilders, limits)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const createBufferIPLDDag = (
|
|
41
|
+
buffer: Buffer,
|
|
42
|
+
filename: string | undefined,
|
|
43
|
+
builders: Builders,
|
|
44
|
+
{ chunkSize, maxLinkPerNode }: { chunkSize: number; maxLinkPerNode: number } = {
|
|
45
|
+
chunkSize: DEFAULT_MAX_CHUNK_SIZE,
|
|
46
|
+
maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
|
|
47
|
+
},
|
|
48
|
+
): IPLDDag => {
|
|
49
|
+
if (buffer.length <= chunkSize) {
|
|
50
|
+
const head = builders.single(buffer, filename)
|
|
32
51
|
const headCID = cidOfNode(head)
|
|
33
52
|
return {
|
|
34
53
|
headCID,
|
|
@@ -36,12 +55,12 @@ export const createFileIPLDDag = (
|
|
|
36
55
|
}
|
|
37
56
|
}
|
|
38
57
|
|
|
39
|
-
const bufferChunks = chunkBuffer(
|
|
58
|
+
const bufferChunks = chunkBuffer(buffer, chunkSize)
|
|
40
59
|
|
|
41
60
|
const nodes = new Map<CID, PBNode>()
|
|
42
61
|
|
|
43
62
|
let CIDs: CID[] = bufferChunks.map((chunk) => {
|
|
44
|
-
const node =
|
|
63
|
+
const node = builders.chunk(chunk)
|
|
45
64
|
const cid = cidOfNode(node)
|
|
46
65
|
nodes.set(cid, node)
|
|
47
66
|
|
|
@@ -54,7 +73,7 @@ export const createFileIPLDDag = (
|
|
|
54
73
|
for (let i = 0; i < CIDs.length; i += maxLinkPerNode) {
|
|
55
74
|
const chunk = CIDs.slice(i, i + maxLinkPerNode)
|
|
56
75
|
|
|
57
|
-
const node =
|
|
76
|
+
const node = builders.inlink(chunk, chunk.length, depth, chunkSize)
|
|
58
77
|
const cid = cidOfNode(node)
|
|
59
78
|
nodes.set(cid, node)
|
|
60
79
|
newCIDs.push(cid)
|
|
@@ -62,7 +81,7 @@ export const createFileIPLDDag = (
|
|
|
62
81
|
depth++
|
|
63
82
|
CIDs = newCIDs
|
|
64
83
|
}
|
|
65
|
-
const head =
|
|
84
|
+
const head = builders.root(CIDs, buffer.length, depth, filename, chunkSize)
|
|
66
85
|
const headCID = cidOfNode(head)
|
|
67
86
|
nodes.set(headCID, head)
|
|
68
87
|
|
package/src/ipld/nodes.ts
CHANGED
|
@@ -4,8 +4,8 @@ import { OffchainMetadata } from '../metadata/index.js'
|
|
|
4
4
|
import { encodeIPLDNodeData, MetadataType } from '../metadata/onchain/index.js'
|
|
5
5
|
import { DEFAULT_MAX_CHUNK_SIZE, ensureNodeMaxSize } from './chunker.js'
|
|
6
6
|
|
|
7
|
-
/// Creates a chunk ipld node
|
|
8
|
-
export const
|
|
7
|
+
/// Creates a file chunk ipld node
|
|
8
|
+
export const createFileChunkIpldNode = (data: Buffer): PBNode =>
|
|
9
9
|
createNode(
|
|
10
10
|
encodeIPLDNodeData({
|
|
11
11
|
type: MetadataType.FileChunk,
|
|
@@ -40,7 +40,6 @@ export const createChunkedFileIpldNode = (
|
|
|
40
40
|
)
|
|
41
41
|
// Creates a file ipld node
|
|
42
42
|
// links: the CIDs of the file's contents
|
|
43
|
-
// @todo: add the file's metadata
|
|
44
43
|
export const createFileInlinkIpldNode = (
|
|
45
44
|
links: CID[],
|
|
46
45
|
size: number,
|
|
@@ -74,6 +73,72 @@ export const createSingleFileIpldNode = (data: Buffer, name?: string): PBNode =>
|
|
|
74
73
|
[],
|
|
75
74
|
)
|
|
76
75
|
|
|
76
|
+
// Creates a file ipld node
|
|
77
|
+
// links: the CIDs of the file's contents
|
|
78
|
+
// @todo: add the file's metadata
|
|
79
|
+
export const createMetadataInlinkIpldNode = (
|
|
80
|
+
links: CID[],
|
|
81
|
+
size: number,
|
|
82
|
+
linkDepth: number,
|
|
83
|
+
maxNodeSize: number = DEFAULT_MAX_CHUNK_SIZE,
|
|
84
|
+
): PBNode =>
|
|
85
|
+
ensureNodeMaxSize(
|
|
86
|
+
createNode(
|
|
87
|
+
encodeIPLDNodeData({
|
|
88
|
+
type: MetadataType.FileInlink,
|
|
89
|
+
size,
|
|
90
|
+
linkDepth,
|
|
91
|
+
}),
|
|
92
|
+
links.map((cid) => ({ Hash: cid })),
|
|
93
|
+
),
|
|
94
|
+
maxNodeSize,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
// Creates a file ipld node
|
|
98
|
+
// links: the CIDs of the file's contents
|
|
99
|
+
// @todo: add the file's metadata
|
|
100
|
+
export const createSingleMetadataIpldNode = (data: Buffer, name?: string): PBNode =>
|
|
101
|
+
createNode(
|
|
102
|
+
encodeIPLDNodeData({
|
|
103
|
+
type: MetadataType.Metadata,
|
|
104
|
+
name,
|
|
105
|
+
size: data.length,
|
|
106
|
+
linkDepth: 0,
|
|
107
|
+
data,
|
|
108
|
+
}),
|
|
109
|
+
[],
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
export const createMetadataChunkIpldNode = (data: Buffer): PBNode =>
|
|
113
|
+
createNode(
|
|
114
|
+
encodeIPLDNodeData({
|
|
115
|
+
type: MetadataType.MetadataChunk,
|
|
116
|
+
size: data.length,
|
|
117
|
+
linkDepth: 0,
|
|
118
|
+
data,
|
|
119
|
+
}),
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
export const createChunkedMetadataIpldNode = (
|
|
123
|
+
links: CID[],
|
|
124
|
+
size: number,
|
|
125
|
+
linkDepth: number,
|
|
126
|
+
name?: string,
|
|
127
|
+
maxNodeSize: number = DEFAULT_MAX_CHUNK_SIZE,
|
|
128
|
+
): PBNode =>
|
|
129
|
+
ensureNodeMaxSize(
|
|
130
|
+
createNode(
|
|
131
|
+
encodeIPLDNodeData({
|
|
132
|
+
type: MetadataType.Metadata,
|
|
133
|
+
name,
|
|
134
|
+
size,
|
|
135
|
+
linkDepth,
|
|
136
|
+
}),
|
|
137
|
+
links.map((cid) => ({ Hash: cid })),
|
|
138
|
+
),
|
|
139
|
+
maxNodeSize,
|
|
140
|
+
)
|
|
141
|
+
|
|
77
142
|
// Creates a folder ipld node
|
|
78
143
|
// links: the CIDs of the folder's contents
|
|
79
144
|
// @todo: add the folder's metadata
|
|
@@ -114,7 +114,9 @@ export enum MetadataType {
|
|
|
114
114
|
FileChunk = 'FileChunk',
|
|
115
115
|
Folder = 'Folder',
|
|
116
116
|
FolderInlink = 'FolderInlink',
|
|
117
|
-
Metadata = 'Metadata'
|
|
117
|
+
Metadata = 'Metadata',
|
|
118
|
+
MetadataInlink = 'MetadataInlink',
|
|
119
|
+
MetadataChunk = 'MetadataChunk'
|
|
118
120
|
}
|
|
119
121
|
|
|
120
122
|
enum __MetadataTypeValues {
|
|
@@ -123,7 +125,9 @@ enum __MetadataTypeValues {
|
|
|
123
125
|
FileChunk = 2,
|
|
124
126
|
Folder = 3,
|
|
125
127
|
FolderInlink = 4,
|
|
126
|
-
Metadata = 5
|
|
128
|
+
Metadata = 5,
|
|
129
|
+
MetadataInlink = 6,
|
|
130
|
+
MetadataChunk = 7
|
|
127
131
|
}
|
|
128
132
|
|
|
129
133
|
export namespace MetadataType {
|
package/tests/chunker.spec.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createNode } from '@ipld/dag-pb'
|
|
2
2
|
import { cidOfNode } from '../src'
|
|
3
|
-
import { createFileIPLDDag, createFolderIPLDDag } from '../src/ipld/chunker'
|
|
4
|
-
import { IPLDNodeData, MetadataType } from '../src/metadata'
|
|
3
|
+
import { createFileIPLDDag, createFolderIPLDDag, createMetadataIPLDDag } from '../src/ipld/chunker'
|
|
4
|
+
import { IPLDNodeData, MetadataType, OffchainMetadata } from '../src/metadata'
|
|
5
5
|
|
|
6
6
|
describe('chunker', () => {
|
|
7
7
|
describe('file creation', () => {
|
|
@@ -154,4 +154,39 @@ describe('chunker', () => {
|
|
|
154
154
|
expect(inlinkCount).toBe(3)
|
|
155
155
|
})
|
|
156
156
|
})
|
|
157
|
+
|
|
158
|
+
describe('metadata creation', () => {
|
|
159
|
+
it('create a metadata dag from a small buffer', () => {
|
|
160
|
+
const metadata: OffchainMetadata = {
|
|
161
|
+
type: 'file',
|
|
162
|
+
dataCid: 'test',
|
|
163
|
+
name: 'test',
|
|
164
|
+
mimeType: 'text/plain',
|
|
165
|
+
totalSize: 1000,
|
|
166
|
+
totalChunks: 10,
|
|
167
|
+
chunks: [],
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const dag = createMetadataIPLDDag(metadata)
|
|
171
|
+
expect(dag.nodes.size).toBe(1)
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
it('large metadata dag represented into multiple nodes', () => {
|
|
175
|
+
const metadata: OffchainMetadata = {
|
|
176
|
+
type: 'file',
|
|
177
|
+
dataCid: 'test',
|
|
178
|
+
name: 'test',
|
|
179
|
+
mimeType: 'text/plain'.repeat(100),
|
|
180
|
+
totalSize: 1000,
|
|
181
|
+
totalChunks: 10,
|
|
182
|
+
chunks: [],
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const dag = createMetadataIPLDDag(metadata, {
|
|
186
|
+
chunkSize: 200,
|
|
187
|
+
maxLinkPerNode: 2,
|
|
188
|
+
})
|
|
189
|
+
expect(dag.nodes.size).toBeGreaterThan(1)
|
|
190
|
+
})
|
|
191
|
+
})
|
|
157
192
|
})
|
package/tests/nodes.spec.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createNode } from '@ipld/dag-pb'
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
cidOfNode,
|
|
4
|
+
createChunkedFileIpldNode,
|
|
5
|
+
createFileChunkIpldNode,
|
|
6
|
+
createSingleFileIpldNode,
|
|
7
|
+
} from '../src/index.js'
|
|
4
8
|
import { IPLDNodeData, MetadataType } from '../src/metadata/onchain/protobuf/OnchainMetadata.js'
|
|
5
9
|
|
|
6
10
|
describe('node creation', () => {
|
|
@@ -58,7 +62,7 @@ describe('node creation', () => {
|
|
|
58
62
|
|
|
59
63
|
it('file chunk node | correctly params setup', () => {
|
|
60
64
|
const buffer = Buffer.from('hello world')
|
|
61
|
-
const node =
|
|
65
|
+
const node = createFileChunkIpldNode(buffer)
|
|
62
66
|
|
|
63
67
|
const decoded = IPLDNodeData.decode(node.Data ?? new Uint8Array())
|
|
64
68
|
expect(decoded.type).toBe(MetadataType.FileChunk)
|