@autonomys/auto-drive 0.7.2 → 0.7.3

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.
Files changed (55) hide show
  1. package/package.json +2 -2
  2. package/dist/ipld/blockstore/base.d.ts +0 -9
  3. package/dist/ipld/blockstore/base.d.ts.map +0 -1
  4. package/dist/ipld/blockstore/base.js +0 -1
  5. package/dist/ipld/blockstore/index.d.ts +0 -3
  6. package/dist/ipld/blockstore/index.d.ts.map +0 -1
  7. package/dist/ipld/blockstore/index.js +0 -2
  8. package/dist/ipld/blockstore/memory.d.ts +0 -13
  9. package/dist/ipld/blockstore/memory.d.ts.map +0 -1
  10. package/dist/ipld/blockstore/memory.js +0 -57
  11. package/dist/src/cid/index.d.ts +0 -9
  12. package/dist/src/cid/index.d.ts.map +0 -1
  13. package/dist/src/cid/index.js +0 -20
  14. package/dist/src/index.d.ts +0 -4
  15. package/dist/src/index.d.ts.map +0 -1
  16. package/dist/src/index.js +0 -3
  17. package/dist/src/ipld/builders.d.ts +0 -11
  18. package/dist/src/ipld/builders.d.ts.map +0 -1
  19. package/dist/src/ipld/builders.js +0 -13
  20. package/dist/src/ipld/chunker.d.ts +0 -22
  21. package/dist/src/ipld/chunker.d.ts.map +0 -1
  22. package/dist/src/ipld/chunker.js +0 -144
  23. package/dist/src/ipld/index.d.ts +0 -4
  24. package/dist/src/ipld/index.d.ts.map +0 -1
  25. package/dist/src/ipld/index.js +0 -3
  26. package/dist/src/ipld/nodes.d.ts +0 -15
  27. package/dist/src/ipld/nodes.d.ts.map +0 -1
  28. package/dist/src/ipld/nodes.js +0 -89
  29. package/dist/src/ipld/utils.d.ts +0 -5
  30. package/dist/src/ipld/utils.d.ts.map +0 -1
  31. package/dist/src/ipld/utils.js +0 -51
  32. package/dist/src/metadata/index.d.ts +0 -3
  33. package/dist/src/metadata/index.d.ts.map +0 -1
  34. package/dist/src/metadata/index.js +0 -2
  35. package/dist/src/metadata/offchain/base.d.ts +0 -4
  36. package/dist/src/metadata/offchain/base.d.ts.map +0 -1
  37. package/dist/src/metadata/offchain/base.js +0 -1
  38. package/dist/src/metadata/offchain/file.d.ts +0 -16
  39. package/dist/src/metadata/offchain/file.d.ts.map +0 -1
  40. package/dist/src/metadata/offchain/file.js +0 -19
  41. package/dist/src/metadata/offchain/folder.d.ts +0 -17
  42. package/dist/src/metadata/offchain/folder.d.ts.map +0 -1
  43. package/dist/src/metadata/offchain/folder.js +0 -10
  44. package/dist/src/metadata/offchain/index.d.ts +0 -4
  45. package/dist/src/metadata/offchain/index.d.ts.map +0 -1
  46. package/dist/src/metadata/offchain/index.js +0 -3
  47. package/dist/src/metadata/onchain/index.d.ts +0 -3
  48. package/dist/src/metadata/onchain/index.d.ts.map +0 -1
  49. package/dist/src/metadata/onchain/index.js +0 -2
  50. package/dist/src/metadata/onchain/protobuf/OnchainMetadata.d.ts +0 -28
  51. package/dist/src/metadata/onchain/protobuf/OnchainMetadata.d.ts.map +0 -1
  52. package/dist/src/metadata/onchain/protobuf/OnchainMetadata.js +0 -112
  53. package/dist/src/metadata/onchain/utils.d.ts +0 -4
  54. package/dist/src/metadata/onchain/utils.d.ts.map +0 -1
  55. package/dist/src/metadata/onchain/utils.js +0 -12
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.7.2",
4
+ "version": "0.7.3",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "repository": {
@@ -41,5 +41,5 @@
41
41
  "protons": "^7.6.0",
42
42
  "protons-runtime": "^5.5.0"
43
43
  },
44
- "gitHead": "2c7b1be8b6c2f8fbbfc5bcc6aa6cb9b1f363ce83"
44
+ "gitHead": "dde96ad7b5d7f2bf023da23cbd1de89b0e22f1c6"
45
45
  }
@@ -1,9 +0,0 @@
1
- import { BaseBlockstore } from 'blockstore-core';
2
- import type { Pair } from 'interface-blockstore';
3
- import { AbortOptions, AwaitIterable } from 'interface-store';
4
- import { MetadataType } from '../../metadata/index.js';
5
- export interface IPLDBlockstore extends BaseBlockstore {
6
- getFilteredMany(nodeType: MetadataType, options?: AbortOptions): AwaitIterable<Pair['cid']>;
7
- getSize(cid: Pair['cid']): Promise<number>;
8
- }
9
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/ipld/blockstore/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEtD,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,eAAe,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3F,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAC3C"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export * from './base.js';
2
- export * from './memory.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ipld/blockstore/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './base.js';
2
- export * from './memory.js';
@@ -1,13 +0,0 @@
1
- import { MemoryBlockstore } from 'blockstore-core';
2
- import { Pair } from 'interface-blockstore';
3
- import { AbortOptions, AwaitIterable } from 'interface-store';
4
- import { CID, Version } from 'multiformats';
5
- import { MetadataType } from '../../metadata/index.js';
6
- import { IPLDBlockstore } from './base.js';
7
- export declare class MemoryIPLDBlockstore extends MemoryBlockstore implements IPLDBlockstore {
8
- private readonly nodeByType;
9
- getFilteredMany(nodeType: MetadataType, options?: AbortOptions): AwaitIterable<Pair['cid']>;
10
- put(key: CID<unknown, number, number, Version>, val: Uint8Array): Promise<CID<unknown, number, number, Version>>;
11
- getSize(cid: CID): Promise<number>;
12
- }
13
- //# sourceMappingURL=memory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/ipld/blockstore/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAoC,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,qBAAa,oBAAqB,SAAQ,gBAAiB,YAAW,cAAc;IAClF,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;IACrD,eAAe,CACpB,QAAQ,EAAE,YAAY,EACtB,OAAO,CAAC,EAAE,YAAY,GACrB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAMvB,GAAG,CACP,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAC1C,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAM3C,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC;CAKzC"}
@@ -1,57 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
11
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
14
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
15
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
16
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
17
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
18
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
19
- function fulfill(value) { resume("next", value); }
20
- function reject(value) { resume("throw", value); }
21
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
22
- };
23
- import { MemoryBlockstore } from 'blockstore-core';
24
- import { decodeIPLDNodeData } from '../../metadata/index.js';
25
- export class MemoryIPLDBlockstore extends MemoryBlockstore {
26
- constructor() {
27
- super(...arguments);
28
- this.nodeByType = new Map();
29
- }
30
- getFilteredMany(nodeType, options) {
31
- return __asyncGenerator(this, arguments, function* getFilteredMany_1() {
32
- var _a;
33
- for (const cid of (_a = this.nodeByType.get(nodeType)) !== null && _a !== void 0 ? _a : []) {
34
- yield yield __await(cid);
35
- }
36
- });
37
- }
38
- put(key, val) {
39
- const _super = Object.create(null, {
40
- put: { get: () => super.put }
41
- });
42
- return __awaiter(this, void 0, void 0, function* () {
43
- var _a;
44
- const data = decodeIPLDNodeData(val);
45
- this.nodeByType.set(data.type, [...((_a = this.nodeByType.get(data.type)) !== null && _a !== void 0 ? _a : []), key]);
46
- return _super.put.call(this, key, val);
47
- });
48
- }
49
- getSize(cid) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- var _a;
52
- const bytes = yield this.get(cid);
53
- const data = decodeIPLDNodeData(bytes);
54
- return (_a = data.size) !== null && _a !== void 0 ? _a : 0;
55
- });
56
- }
57
- }
@@ -1,9 +0,0 @@
1
- import { PBNode } from '@ipld/dag-pb';
2
- import { CID } from 'multiformats/cid';
3
- export declare const BLAKE3_CODE = 31;
4
- export declare const cidOfNode: (node: PBNode) => CID<unknown, 85, 31, 1>;
5
- export declare const cidToString: (cid: CID) => string;
6
- export declare const stringToCid: (str: string) => CID<unknown, number, number, import("multiformats/cid").Version>;
7
- export declare const cidFromBlakeHash: (hash: Buffer) => CID<unknown, 85, 31, 1>;
8
- export declare const blake3HashFromCid: (cid: CID) => Uint8Array;
9
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cid/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAKtC,eAAO,MAAM,WAAW,KAAO,CAAA;AAE/B,eAAO,MAAM,SAAS,SAAU,MAAM,4BAErC,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,GAAG,WAEnC,CAAA;AAED,eAAO,MAAM,WAAW,QAAS,MAAM,qEAEtC,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,MAAM,4BAE5C,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAS,GAAG,eAAyB,CAAA"}
@@ -1,20 +0,0 @@
1
- import { encode } from '@ipld/dag-pb';
2
- import { hash } from 'blake3';
3
- import { CID } from 'multiformats/cid';
4
- import * as base32 from 'multiformats/bases/base32';
5
- import * as raw from 'multiformats/codecs/raw';
6
- import { create } from 'multiformats/hashes/digest';
7
- export const BLAKE3_CODE = 0x1f;
8
- export const cidOfNode = (node) => {
9
- return cidFromBlakeHash(hash(encode(node)));
10
- };
11
- export const cidToString = (cid) => {
12
- return cid.toString(base32.base32);
13
- };
14
- export const stringToCid = (str) => {
15
- return CID.parse(str, base32.base32);
16
- };
17
- export const cidFromBlakeHash = (hash) => {
18
- return CID.create(1, raw.code, create(BLAKE3_CODE, hash));
19
- };
20
- export const blake3HashFromCid = (cid) => cid.multihash.digest;
@@ -1,4 +0,0 @@
1
- export * from './cid/index.js';
2
- export * from './ipld/index.js';
3
- export * from './metadata/index.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA"}
package/dist/src/index.js DELETED
@@ -1,3 +0,0 @@
1
- export * from './cid/index.js';
2
- export * from './ipld/index.js';
3
- export * from './metadata/index.js';
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,13 +0,0 @@
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
- };
@@ -1,22 +0,0 @@
1
- import { PBNode } from '@ipld/dag-pb';
2
- import { CID } from 'multiformats';
3
- import { OffchainMetadata } from '../metadata/index.js';
4
- export declare const DEFAULT_MAX_CHUNK_SIZE: number;
5
- export declare const DEFAULT_MAX_LINK_PER_NODE: number;
6
- export interface IPLDDag {
7
- headCID: CID;
8
- nodes: Map<CID, PBNode>;
9
- }
10
- export declare const createFileIPLDDag: (file: AsyncIterable<Buffer>, filename?: string, { chunkSize, maxLinkPerNode }?: {
11
- chunkSize: number;
12
- maxLinkPerNode: number;
13
- }) => Promise<IPLDDag>;
14
- export declare const createMetadataIPLDDag: (metadata: OffchainMetadata, limits?: {
15
- chunkSize: number;
16
- maxLinkPerNode: number;
17
- }) => Promise<IPLDDag>;
18
- export declare const createFolderIPLDDag: (children: CID[], name: string, size: number, { maxLinkPerNode }?: {
19
- maxLinkPerNode: number;
20
- }) => IPLDDag;
21
- export declare const ensureNodeMaxSize: (node: PBNode, maxSize?: number) => PBNode;
22
- //# sourceMappingURL=chunker.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chunker.d.ts","sourceRoot":"","sources":["../../../src/ipld/chunker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAElC,OAAO,EAAgB,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAKrE,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,aAAa,CAAC,MAAM,CAAC,aAChB,MAAM,kCACc;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,KAI3E,OAAO,CAAC,OAAO,CAEjB,CAAA;AAED,eAAO,MAAM,qBAAqB,aACtB,gBAAgB,WAClB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,KAIpD,OAAO,CAAC,OAAO,CAWjB,CAAA;AA6DD,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"}
@@ -1,144 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
11
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
12
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
14
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
15
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
16
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
17
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
18
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
19
- function fulfill(value) { resume("next", value); }
20
- function reject(value) { resume("throw", value); }
21
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
22
- };
23
- var __asyncValues = (this && this.__asyncValues) || function (o) {
24
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
25
- var m = o[Symbol.asyncIterator], i;
26
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
27
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
28
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
29
- };
30
- import { cidOfNode } from '../cid/index.js';
31
- import { IPLDNodeData } from '../metadata/index.js';
32
- import { fileBuilders, metadataBuilders } from './builders.js';
33
- import { createFolderInlinkIpldNode, createFolderIpldNode } from './nodes.js';
34
- import { chunkBuffer, encodeNode } from './utils.js';
35
- export const DEFAULT_MAX_CHUNK_SIZE = 1024 * 64;
36
- export const DEFAULT_MAX_LINK_PER_NODE = DEFAULT_MAX_CHUNK_SIZE / 64;
37
- export const createFileIPLDDag = (file, filename, { chunkSize, maxLinkPerNode } = {
38
- chunkSize: DEFAULT_MAX_CHUNK_SIZE,
39
- maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
40
- }) => {
41
- return createBufferIPLDDag(file, filename, fileBuilders, { chunkSize, maxLinkPerNode });
42
- };
43
- export const createMetadataIPLDDag = (metadata_1, ...args_1) => __awaiter(void 0, [metadata_1, ...args_1], void 0, function* (metadata, limits = {
44
- chunkSize: DEFAULT_MAX_CHUNK_SIZE,
45
- maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
46
- }) {
47
- const buffer = Buffer.from(JSON.stringify(metadata));
48
- const name = `${metadata.name}.metadata.json`;
49
- return createBufferIPLDDag((function () {
50
- return __asyncGenerator(this, arguments, function* () {
51
- yield yield __await(buffer);
52
- });
53
- })(), name, metadataBuilders, limits);
54
- });
55
- const createBufferIPLDDag = (buffer_1, filename_1, builders_1, ...args_1) => __awaiter(void 0, [buffer_1, filename_1, builders_1, ...args_1], void 0, function* (buffer, filename, builders, { chunkSize, maxLinkPerNode } = {
56
- chunkSize: DEFAULT_MAX_CHUNK_SIZE,
57
- maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE,
58
- }) {
59
- var _a, e_1, _b, _c;
60
- const bufferChunks = chunkBuffer(buffer, chunkSize);
61
- let totalSize = 0;
62
- const nodes = new Map();
63
- let CIDs = [];
64
- try {
65
- for (var _d = true, bufferChunks_1 = __asyncValues(bufferChunks), bufferChunks_1_1; bufferChunks_1_1 = yield bufferChunks_1.next(), _a = bufferChunks_1_1.done, !_a; _d = true) {
66
- _c = bufferChunks_1_1.value;
67
- _d = false;
68
- const chunk = _c;
69
- const node = builders.chunk(chunk);
70
- const cid = cidOfNode(node);
71
- nodes.set(cid, node);
72
- totalSize += chunk.byteLength;
73
- CIDs.push(cid);
74
- }
75
- }
76
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
77
- finally {
78
- try {
79
- if (!_d && !_a && (_b = bufferChunks_1.return)) yield _b.call(bufferChunks_1);
80
- }
81
- finally { if (e_1) throw e_1.error; }
82
- }
83
- if (CIDs.length === 1) {
84
- const node = nodes.get(CIDs[0]);
85
- const data = IPLDNodeData.decode(Buffer.from(node.Data));
86
- const singleNode = builders.single(Buffer.from(data.data), filename);
87
- const headCID = cidOfNode(singleNode);
88
- return {
89
- headCID,
90
- nodes: new Map([[headCID, singleNode]]),
91
- };
92
- }
93
- let depth = 1;
94
- while (CIDs.length > maxLinkPerNode) {
95
- const newCIDs = [];
96
- for (let i = 0; i < CIDs.length; i += maxLinkPerNode) {
97
- const chunk = CIDs.slice(i, i + maxLinkPerNode);
98
- const node = builders.inlink(chunk, chunk.length, depth, chunkSize);
99
- const cid = cidOfNode(node);
100
- nodes.set(cid, node);
101
- newCIDs.push(cid);
102
- }
103
- depth++;
104
- CIDs = newCIDs;
105
- }
106
- const head = builders.root(CIDs, totalSize, depth, filename, chunkSize);
107
- const headCID = cidOfNode(head);
108
- nodes.set(headCID, head);
109
- return {
110
- headCID,
111
- nodes,
112
- };
113
- });
114
- export const createFolderIPLDDag = (children, name, size, { maxLinkPerNode } = { maxLinkPerNode: DEFAULT_MAX_LINK_PER_NODE }) => {
115
- const nodes = new Map();
116
- let cids = children;
117
- let depth = 0;
118
- while (cids.length > maxLinkPerNode) {
119
- const newCIDs = [];
120
- for (let i = 0; i < cids.length; i += maxLinkPerNode) {
121
- const chunk = cids.slice(i, i + maxLinkPerNode);
122
- const node = createFolderInlinkIpldNode(chunk, depth);
123
- const cid = cidOfNode(node);
124
- nodes.set(cid, node);
125
- newCIDs.push(cid);
126
- }
127
- cids = newCIDs;
128
- depth++;
129
- }
130
- const node = createFolderIpldNode(cids, name, depth, size);
131
- const cid = cidOfNode(node);
132
- nodes.set(cid, node);
133
- return {
134
- headCID: cid,
135
- nodes,
136
- };
137
- };
138
- export const ensureNodeMaxSize = (node, maxSize = DEFAULT_MAX_CHUNK_SIZE) => {
139
- const nodeSize = encodeNode(node).byteLength;
140
- if (nodeSize > maxSize) {
141
- throw new Error(`Node is too large to fit in a single chunk: ${nodeSize} > ${maxSize}`);
142
- }
143
- return node;
144
- };
@@ -1,4 +0,0 @@
1
- export * from './chunker.js';
2
- export * from './nodes.js';
3
- export { encodeNode } from './utils.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/ipld/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './chunker.js';
2
- export * from './nodes.js';
3
- export { encodeNode } from './utils.js';
@@ -1,15 +0,0 @@
1
- import { PBNode } from '@ipld/dag-pb';
2
- import { CID } from 'multiformats/cid';
3
- import { OffchainMetadata } from '../metadata/index.js';
4
- export declare const createFileChunkIpldNode: (data: Buffer) => PBNode;
5
- export declare const createChunkedFileIpldNode: (links: CID[], size: number, linkDepth: number, name?: string, maxNodeSize?: number) => PBNode;
6
- export declare const createFileInlinkIpldNode: (links: CID[], size: number, linkDepth: number, maxNodeSize?: number) => PBNode;
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;
12
- export declare const createFolderIpldNode: (links: CID[], name: string, linkDepth: number, size: number, maxNodeSize?: number) => PBNode;
13
- export declare const createFolderInlinkIpldNode: (links: CID[], linkDepth: number, maxNodeSize?: number) => PBNode;
14
- export declare const createMetadataNode: (metadata: OffchainMetadata, maxNodeSize?: number) => PBNode;
15
- //# sourceMappingURL=nodes.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,89 +0,0 @@
1
- import { createNode } from '@ipld/dag-pb';
2
- import { encodeIPLDNodeData, MetadataType } from '../metadata/onchain/index.js';
3
- import { DEFAULT_MAX_CHUNK_SIZE, ensureNodeMaxSize } from './chunker.js';
4
- /// Creates a file chunk ipld node
5
- export const createFileChunkIpldNode = (data) => createNode(encodeIPLDNodeData({
6
- type: MetadataType.FileChunk,
7
- size: data.length,
8
- linkDepth: 0,
9
- data,
10
- }), []);
11
- // Creates a file ipld node
12
- // links: the CIDs of the file's contents
13
- // @todo: add the file's metadata
14
- export const createChunkedFileIpldNode = (links, size, linkDepth, name, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
15
- type: MetadataType.File,
16
- name,
17
- size,
18
- linkDepth,
19
- }), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
20
- // Creates a file ipld node
21
- // links: the CIDs of the file's contents
22
- export const createFileInlinkIpldNode = (links, size, linkDepth, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
23
- type: MetadataType.FileInlink,
24
- size,
25
- linkDepth,
26
- }), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
27
- // Creates a file ipld node
28
- // links: the CIDs of the file's contents
29
- // @todo: add the file's metadata
30
- export const createSingleFileIpldNode = (data, name) => createNode(encodeIPLDNodeData({
31
- type: MetadataType.File,
32
- name,
33
- size: data.length,
34
- linkDepth: 0,
35
- data,
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);
67
- // Creates a folder ipld node
68
- // links: the CIDs of the folder's contents
69
- // @todo: add the folder's metadata
70
- export const createFolderIpldNode = (links, name, linkDepth, size, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
71
- type: MetadataType.Folder,
72
- name,
73
- size,
74
- linkDepth,
75
- }), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
76
- export const createFolderInlinkIpldNode = (links, linkDepth, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => ensureNodeMaxSize(createNode(encodeIPLDNodeData({
77
- type: MetadataType.FolderInlink,
78
- linkDepth,
79
- }), links.map((cid) => ({ Hash: cid }))), maxNodeSize);
80
- /// Creates a metadata ipld node
81
- export const createMetadataNode = (metadata, maxNodeSize = DEFAULT_MAX_CHUNK_SIZE) => {
82
- const data = Buffer.from(JSON.stringify(metadata));
83
- return ensureNodeMaxSize(createNode(encodeIPLDNodeData({
84
- type: MetadataType.Metadata,
85
- name: metadata.name,
86
- linkDepth: 0,
87
- data,
88
- })), maxNodeSize);
89
- };
@@ -1,5 +0,0 @@
1
- import { PBNode } from '@ipld/dag-pb';
2
- export declare const chunkBuffer: (buffer: AsyncIterable<Buffer>, chunkSize: number) => AsyncIterable<Buffer>;
3
- export declare const encodeNode: (node: PBNode) => Buffer;
4
- export declare const decodeNode: (data: Uint8Array) => PBNode;
5
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/ipld/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,cAAc,CAAA;AAErD,eAAO,MAAM,WAAW,WACd,aAAa,CAAC,MAAM,CAAC,aAClB,MAAM,KAChB,aAAa,CAAC,MAAM,CAYtB,CAAA;AAED,eAAO,MAAM,UAAU,SAAU,MAAM,KAAG,MAAmC,CAAA;AAE7E,eAAO,MAAM,UAAU,SAAU,UAAU,KAAG,MAAsB,CAAA"}
@@ -1,51 +0,0 @@
1
- var __asyncValues = (this && this.__asyncValues) || function (o) {
2
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
3
- var m = o[Symbol.asyncIterator], i;
4
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
5
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
6
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7
- };
8
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
9
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
10
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
11
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
12
- return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
13
- function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
14
- function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
15
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
16
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
17
- function fulfill(value) { resume("next", value); }
18
- function reject(value) { resume("throw", value); }
19
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
20
- };
21
- import { decode, encode } from '@ipld/dag-pb';
22
- export const chunkBuffer = function (buffer, chunkSize) {
23
- return __asyncGenerator(this, arguments, function* () {
24
- var _a, e_1, _b, _c;
25
- let target = Buffer.alloc(0);
26
- try {
27
- for (var _d = true, buffer_1 = __asyncValues(buffer), buffer_1_1; buffer_1_1 = yield __await(buffer_1.next()), _a = buffer_1_1.done, !_a; _d = true) {
28
- _c = buffer_1_1.value;
29
- _d = false;
30
- let chunk = _c;
31
- target = Buffer.concat([target, chunk]);
32
- while (target.length >= chunkSize) {
33
- yield yield __await(target.subarray(0, chunkSize));
34
- target = target.subarray(chunkSize);
35
- }
36
- }
37
- }
38
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
39
- finally {
40
- try {
41
- if (!_d && !_a && (_b = buffer_1.return)) yield __await(_b.call(buffer_1));
42
- }
43
- finally { if (e_1) throw e_1.error; }
44
- }
45
- if (target.length > 0) {
46
- yield yield __await(target);
47
- }
48
- });
49
- };
50
- export const encodeNode = (node) => Buffer.from(encode(node));
51
- export const decodeNode = (data) => decode(data);
@@ -1,3 +0,0 @@
1
- export * from './offchain/index.js';
2
- export * from './onchain/index.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/metadata/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './offchain/index.js';
2
- export * from './onchain/index.js';
@@ -1,4 +0,0 @@
1
- import { OffchainFileMetadata } from './file.js';
2
- import { OffchainFolderMetadata } from './folder.js';
3
- export type OffchainMetadata = OffchainFolderMetadata | OffchainFileMetadata;
4
- //# sourceMappingURL=base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/metadata/offchain/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEpD,MAAM,MAAM,gBAAgB,GAAG,sBAAsB,GAAG,oBAAoB,CAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- import { IPLDDag } from '../../index.js';
2
- export type OffchainFileMetadata = {
3
- type: 'file';
4
- dataCid: string;
5
- name?: string;
6
- mimeType?: string;
7
- totalSize: number;
8
- totalChunks: number;
9
- chunks: ChunkInfo[];
10
- };
11
- export interface ChunkInfo {
12
- size: number;
13
- cid: string;
14
- }
15
- export declare const fileMetadata: (dag: IPLDDag, totalSize: number, name?: string, mimeType?: string) => OffchainFileMetadata;
16
- //# sourceMappingURL=file.d.ts.map
@@ -1 +0,0 @@
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,19 +0,0 @@
1
- import { cidOfNode, cidToString, IPLDNodeData } from '../../index.js';
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);
4
- return {
5
- type: 'file',
6
- dataCid: cidToString(dag.headCID),
7
- name,
8
- mimeType,
9
- totalSize,
10
- totalChunks: chunks.length,
11
- chunks: chunks.map((chunk) => {
12
- var _a, _b;
13
- return ({
14
- cid: cidToString(cidOfNode(chunk)),
15
- size: (_b = (_a = chunk.Data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
16
- });
17
- }),
18
- };
19
- };
@@ -1,17 +0,0 @@
1
- interface ChildrenMetadata {
2
- type: 'folder' | 'file';
3
- name?: string;
4
- cid: string;
5
- totalSize: number;
6
- }
7
- export type OffchainFolderMetadata = {
8
- type: 'folder';
9
- dataCid: string;
10
- name?: string;
11
- totalSize: number;
12
- totalFiles: number;
13
- children: ChildrenMetadata[];
14
- };
15
- export declare const folderMetadata: (cid: string, children: ChildrenMetadata[], name?: string) => OffchainFolderMetadata;
16
- export {};
17
- //# sourceMappingURL=folder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../../../src/metadata/offchain/folder.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAA;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,QAAQ,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,gBAAgB,EAAE,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,cAAc,QACpB,MAAM,YACD,gBAAgB,EAAE,SACrB,MAAM,KACZ,sBASF,CAAA"}
@@ -1,10 +0,0 @@
1
- export const folderMetadata = (cid, children, name) => {
2
- return {
3
- dataCid: cid,
4
- totalSize: children.reduce((acc, child) => acc + child.totalSize, 0),
5
- totalFiles: children.length,
6
- children,
7
- type: 'folder',
8
- name,
9
- };
10
- };
@@ -1,4 +0,0 @@
1
- export * from './base.js';
2
- export * from './file.js';
3
- export * from './folder.js';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/metadata/offchain/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './base.js';
2
- export * from './file.js';
3
- export * from './folder.js';
@@ -1,3 +0,0 @@
1
- export * from './protobuf/OnchainMetadata.js';
2
- export * from './utils.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/metadata/onchain/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,YAAY,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './protobuf/OnchainMetadata.js';
2
- export * from './utils.js';
@@ -1,28 +0,0 @@
1
- import { type Codec, type DecodeOptions } from 'protons-runtime';
2
- import type { Uint8ArrayList } from 'uint8arraylist';
3
- export interface IPLDNodeData {
4
- type: MetadataType;
5
- linkDepth: number;
6
- size?: number;
7
- name?: string;
8
- data?: Uint8Array;
9
- }
10
- export declare namespace IPLDNodeData {
11
- const codec: () => Codec<IPLDNodeData>;
12
- const encode: (obj: Partial<IPLDNodeData>) => Uint8Array;
13
- const decode: (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<IPLDNodeData>) => IPLDNodeData;
14
- }
15
- export declare enum MetadataType {
16
- File = "File",
17
- FileInlink = "FileInlink",
18
- FileChunk = "FileChunk",
19
- Folder = "Folder",
20
- FolderInlink = "FolderInlink",
21
- Metadata = "Metadata",
22
- MetadataInlink = "MetadataInlink",
23
- MetadataChunk = "MetadataChunk"
24
- }
25
- export declare namespace MetadataType {
26
- const codec: () => Codec<MetadataType>;
27
- }
28
- //# sourceMappingURL=OnchainMetadata.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,112 +0,0 @@
1
- /* eslint-disable import/export */
2
- /* eslint-disable complexity */
3
- /* eslint-disable @typescript-eslint/no-namespace */
4
- /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
5
- /* eslint-disable @typescript-eslint/no-empty-interface */
6
- import { decodeMessage, encodeMessage, enumeration, message } from 'protons-runtime';
7
- export var IPLDNodeData;
8
- (function (IPLDNodeData) {
9
- let _codec;
10
- IPLDNodeData.codec = () => {
11
- if (_codec == null) {
12
- _codec = message((obj, w, opts = {}) => {
13
- if (opts.lengthDelimited !== false) {
14
- w.fork();
15
- }
16
- if (obj.type != null && __MetadataTypeValues[obj.type] !== 0) {
17
- w.uint32(8);
18
- MetadataType.codec().encode(obj.type, w);
19
- }
20
- if ((obj.linkDepth != null && obj.linkDepth !== 0)) {
21
- w.uint32(16);
22
- w.int32(obj.linkDepth);
23
- }
24
- if (obj.size != null) {
25
- w.uint32(24);
26
- w.int32(obj.size);
27
- }
28
- if (obj.name != null) {
29
- w.uint32(34);
30
- w.string(obj.name);
31
- }
32
- if (obj.data != null) {
33
- w.uint32(42);
34
- w.bytes(obj.data);
35
- }
36
- if (opts.lengthDelimited !== false) {
37
- w.ldelim();
38
- }
39
- }, (reader, length, opts = {}) => {
40
- const obj = {
41
- type: MetadataType.File,
42
- linkDepth: 0
43
- };
44
- const end = length == null ? reader.len : reader.pos + length;
45
- while (reader.pos < end) {
46
- const tag = reader.uint32();
47
- switch (tag >>> 3) {
48
- case 1: {
49
- obj.type = MetadataType.codec().decode(reader);
50
- break;
51
- }
52
- case 2: {
53
- obj.linkDepth = reader.int32();
54
- break;
55
- }
56
- case 3: {
57
- obj.size = reader.int32();
58
- break;
59
- }
60
- case 4: {
61
- obj.name = reader.string();
62
- break;
63
- }
64
- case 5: {
65
- obj.data = reader.bytes();
66
- break;
67
- }
68
- default: {
69
- reader.skipType(tag & 7);
70
- break;
71
- }
72
- }
73
- }
74
- return obj;
75
- });
76
- }
77
- return _codec;
78
- };
79
- IPLDNodeData.encode = (obj) => {
80
- return encodeMessage(obj, IPLDNodeData.codec());
81
- };
82
- IPLDNodeData.decode = (buf, opts) => {
83
- return decodeMessage(buf, IPLDNodeData.codec(), opts);
84
- };
85
- })(IPLDNodeData || (IPLDNodeData = {}));
86
- export var MetadataType;
87
- (function (MetadataType) {
88
- MetadataType["File"] = "File";
89
- MetadataType["FileInlink"] = "FileInlink";
90
- MetadataType["FileChunk"] = "FileChunk";
91
- MetadataType["Folder"] = "Folder";
92
- MetadataType["FolderInlink"] = "FolderInlink";
93
- MetadataType["Metadata"] = "Metadata";
94
- MetadataType["MetadataInlink"] = "MetadataInlink";
95
- MetadataType["MetadataChunk"] = "MetadataChunk";
96
- })(MetadataType || (MetadataType = {}));
97
- var __MetadataTypeValues;
98
- (function (__MetadataTypeValues) {
99
- __MetadataTypeValues[__MetadataTypeValues["File"] = 0] = "File";
100
- __MetadataTypeValues[__MetadataTypeValues["FileInlink"] = 1] = "FileInlink";
101
- __MetadataTypeValues[__MetadataTypeValues["FileChunk"] = 2] = "FileChunk";
102
- __MetadataTypeValues[__MetadataTypeValues["Folder"] = 3] = "Folder";
103
- __MetadataTypeValues[__MetadataTypeValues["FolderInlink"] = 4] = "FolderInlink";
104
- __MetadataTypeValues[__MetadataTypeValues["Metadata"] = 5] = "Metadata";
105
- __MetadataTypeValues[__MetadataTypeValues["MetadataInlink"] = 6] = "MetadataInlink";
106
- __MetadataTypeValues[__MetadataTypeValues["MetadataChunk"] = 7] = "MetadataChunk";
107
- })(__MetadataTypeValues || (__MetadataTypeValues = {}));
108
- (function (MetadataType) {
109
- MetadataType.codec = () => {
110
- return enumeration(__MetadataTypeValues);
111
- };
112
- })(MetadataType || (MetadataType = {}));
@@ -1,4 +0,0 @@
1
- import { IPLDNodeData } from '../onchain/index.js';
2
- export declare const encodeIPLDNodeData: (metadata: IPLDNodeData) => Uint8Array;
3
- export declare const decodeIPLDNodeData: (data: Uint8Array) => IPLDNodeData;
4
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/metadata/onchain/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAElD,eAAO,MAAM,kBAAkB,aAAc,YAAY,KAAG,UAE3D,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,UAAU,KAAG,YAOrD,CAAA"}
@@ -1,12 +0,0 @@
1
- import { decode } from '@ipld/dag-pb';
2
- import { IPLDNodeData } from '../onchain/index.js';
3
- export const encodeIPLDNodeData = (metadata) => {
4
- return IPLDNodeData.encode(metadata);
5
- };
6
- export const decodeIPLDNodeData = (data) => {
7
- const decoded = decode(data);
8
- if (!decoded.Data) {
9
- throw new Error('Invalid data');
10
- }
11
- return IPLDNodeData.decode(decoded.Data);
12
- };