@helia/unixfs 1.2.3 → 1.3.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.
Files changed (58) hide show
  1. package/dist/index.min.js +1 -1
  2. package/dist/src/commands/cat.js +1 -1
  3. package/dist/src/commands/cat.js.map +1 -1
  4. package/dist/src/commands/chmod.js +2 -2
  5. package/dist/src/commands/chmod.js.map +1 -1
  6. package/dist/src/commands/cp.js +1 -1
  7. package/dist/src/commands/cp.js.map +1 -1
  8. package/dist/src/commands/ls.js +1 -1
  9. package/dist/src/commands/ls.js.map +1 -1
  10. package/dist/src/commands/mkdir.js +1 -1
  11. package/dist/src/commands/mkdir.js.map +1 -1
  12. package/dist/src/commands/rm.js +1 -1
  13. package/dist/src/commands/rm.js.map +1 -1
  14. package/dist/src/commands/stat.js +1 -1
  15. package/dist/src/commands/stat.js.map +1 -1
  16. package/dist/src/commands/touch.js +2 -2
  17. package/dist/src/commands/touch.js.map +1 -1
  18. package/dist/src/commands/utils/add-link.js +3 -3
  19. package/dist/src/commands/utils/add-link.js.map +1 -1
  20. package/dist/src/commands/utils/cid-to-directory.js +1 -1
  21. package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
  22. package/dist/src/commands/utils/cid-to-pblink.js +1 -1
  23. package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
  24. package/dist/src/commands/utils/is-over-shard-threshold.d.ts +2 -1
  25. package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -1
  26. package/dist/src/commands/utils/is-over-shard-threshold.js +5 -5
  27. package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
  28. package/dist/src/commands/utils/remove-link.js +2 -2
  29. package/dist/src/commands/utils/remove-link.js.map +1 -1
  30. package/dist/src/commands/utils/resolve.js +1 -1
  31. package/dist/src/commands/utils/resolve.js.map +1 -1
  32. package/dist/src/errors.d.ts.map +1 -0
  33. package/dist/src/errors.js.map +1 -0
  34. package/dist/src/index.d.ts +40 -0
  35. package/dist/src/index.d.ts.map +1 -1
  36. package/dist/src/index.js.map +1 -1
  37. package/dist/typedoc-urls.json +25 -15
  38. package/package.json +21 -5
  39. package/src/commands/cat.ts +1 -1
  40. package/src/commands/chmod.ts +2 -2
  41. package/src/commands/cp.ts +1 -1
  42. package/src/commands/ls.ts +1 -1
  43. package/src/commands/mkdir.ts +1 -1
  44. package/src/commands/rm.ts +1 -1
  45. package/src/commands/stat.ts +1 -1
  46. package/src/commands/touch.ts +2 -2
  47. package/src/commands/utils/add-link.ts +3 -3
  48. package/src/commands/utils/cid-to-directory.ts +1 -1
  49. package/src/commands/utils/cid-to-pblink.ts +1 -1
  50. package/src/commands/utils/is-over-shard-threshold.ts +6 -5
  51. package/src/commands/utils/remove-link.ts +2 -2
  52. package/src/commands/utils/resolve.ts +1 -1
  53. package/src/index.ts +48 -0
  54. package/dist/src/commands/utils/errors.d.ts.map +0 -1
  55. package/dist/src/commands/utils/errors.js.map +0 -1
  56. /package/dist/src/{commands/utils/errors.d.ts → errors.d.ts} +0 -0
  57. /package/dist/src/{commands/utils/errors.js → errors.js} +0 -0
  58. /package/src/{commands/utils/errors.ts → errors.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC1F,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAA;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,EAA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,EAAE,OAAe,EAAE,UAAiC,EAAE;QACzE,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACjE,CAAC;IAED,KAAK,CAAC,EAAE,CAAE,GAAQ,EAAE,IAAY,EAAE,UAA8B,EAAE;QAChE,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,IAAI,CAAE,GAAQ,EAAE,UAAgC,EAAE;QACtD,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACvD,CAAC;IAED,KAAK,CAAC,KAAK,CAAE,GAAQ,EAAE,UAAiC,EAAE;QACxD,OAAO,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAE,KAA6B;IACnD,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,CAAA;AACjC,CAAC"}
@@ -1,17 +1,27 @@
1
1
  {
2
- "AddOptions": "https://ipfs.github.io/helia-unixfs/interfaces/AddOptions.html",
3
- "CatOptions": "https://ipfs.github.io/helia-unixfs/interfaces/CatOptions.html",
4
- "ChmodOptions": "https://ipfs.github.io/helia-unixfs/interfaces/ChmodOptions.html",
5
- "CpOptions": "https://ipfs.github.io/helia-unixfs/interfaces/CpOptions.html",
6
- "LsOptions": "https://ipfs.github.io/helia-unixfs/interfaces/LsOptions.html",
7
- "MkdirOptions": "https://ipfs.github.io/helia-unixfs/interfaces/MkdirOptions.html",
8
- "RmOptions": "https://ipfs.github.io/helia-unixfs/interfaces/RmOptions.html",
9
- "StatOptions": "https://ipfs.github.io/helia-unixfs/interfaces/StatOptions.html",
10
- "TouchOptions": "https://ipfs.github.io/helia-unixfs/interfaces/TouchOptions.html",
11
- "UnixFS": "https://ipfs.github.io/helia-unixfs/interfaces/UnixFS.html",
12
- "UnixFSComponents": "https://ipfs.github.io/helia-unixfs/interfaces/UnixFSComponents.html",
13
- "UnixFSStats": "https://ipfs.github.io/helia-unixfs/interfaces/UnixFSStats.html",
14
- "AddEvents": "https://ipfs.github.io/helia-unixfs/types/AddEvents.html",
15
- "GetEvents": "https://ipfs.github.io/helia-unixfs/types/GetEvents.html",
16
- "unixfs": "https://ipfs.github.io/helia-unixfs/functions/unixfs-1.html"
2
+ "AlreadyExistsError": "https://ipfs.github.io/helia-unixfs/classes/errors.AlreadyExistsError.html",
3
+ "DoesNotExistError": "https://ipfs.github.io/helia-unixfs/classes/errors.DoesNotExistError.html",
4
+ "InvalidPBNodeError": "https://ipfs.github.io/helia-unixfs/classes/errors.InvalidPBNodeError.html",
5
+ "InvalidParametersError": "https://ipfs.github.io/helia-unixfs/classes/errors.InvalidParametersError.html",
6
+ "NoContentError": "https://ipfs.github.io/helia-unixfs/classes/errors.NoContentError.html",
7
+ "NotADirectoryError": "https://ipfs.github.io/helia-unixfs/classes/errors.NotADirectoryError.html",
8
+ "NotAFileError": "https://ipfs.github.io/helia-unixfs/classes/errors.NotAFileError.html",
9
+ "NotUnixFSError": "https://ipfs.github.io/helia-unixfs/classes/errors.NotUnixFSError.html",
10
+ "UnixFSError": "https://ipfs.github.io/helia-unixfs/classes/errors.UnixFSError.html",
11
+ "UnknownError": "https://ipfs.github.io/helia-unixfs/classes/errors.UnknownError.html",
12
+ "AddOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.AddOptions.html",
13
+ "CatOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.CatOptions.html",
14
+ "ChmodOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.ChmodOptions.html",
15
+ "CpOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.CpOptions.html",
16
+ "LsOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.LsOptions.html",
17
+ "MkdirOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.MkdirOptions.html",
18
+ "RmOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.RmOptions.html",
19
+ "StatOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.StatOptions.html",
20
+ "TouchOptions": "https://ipfs.github.io/helia-unixfs/interfaces/index.TouchOptions.html",
21
+ "UnixFS": "https://ipfs.github.io/helia-unixfs/interfaces/index.UnixFS.html",
22
+ "UnixFSComponents": "https://ipfs.github.io/helia-unixfs/interfaces/index.UnixFSComponents.html",
23
+ "UnixFSStats": "https://ipfs.github.io/helia-unixfs/interfaces/index.UnixFSStats.html",
24
+ "AddEvents": "https://ipfs.github.io/helia-unixfs/types/index.AddEvents.html",
25
+ "GetEvents": "https://ipfs.github.io/helia-unixfs/types/index.GetEvents.html",
26
+ "unixfs": "https://ipfs.github.io/helia-unixfs/functions/index.unixfs-1.html"
17
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/unixfs",
3
- "version": "1.2.3",
3
+ "version": "1.3.0",
4
4
  "description": "A Helia-compatible wrapper for UnixFS",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia-unixfs/tree/master/packages/unixfs#readme",
@@ -14,12 +14,24 @@
14
14
  "keywords": [
15
15
  "IPFS"
16
16
  ],
17
- "engines": {
18
- "node": ">=16.0.0",
19
- "npm": ">=7.0.0"
20
- },
21
17
  "type": "module",
22
18
  "types": "./dist/src/index.d.ts",
19
+ "typesVersions": {
20
+ "*": {
21
+ "*": [
22
+ "*",
23
+ "dist/*",
24
+ "dist/src/*",
25
+ "dist/src/*/index"
26
+ ],
27
+ "src/*": [
28
+ "*",
29
+ "dist/*",
30
+ "dist/src/*",
31
+ "dist/src/*/index"
32
+ ]
33
+ }
34
+ },
23
35
  "files": [
24
36
  "src",
25
37
  "dist",
@@ -30,6 +42,10 @@
30
42
  ".": {
31
43
  "types": "./dist/src/index.d.ts",
32
44
  "import": "./dist/src/index.js"
45
+ },
46
+ "./errors": {
47
+ "types": "./dist/src/errors.d.ts",
48
+ "import": "./dist/src/errors.js"
33
49
  }
34
50
  },
35
51
  "eslintConfig": {
@@ -1,6 +1,6 @@
1
1
  import { exporter } from 'ipfs-unixfs-exporter'
2
2
  import mergeOpts from 'merge-options'
3
- import { NoContentError, NotAFileError } from './utils/errors.js'
3
+ import { NoContentError, NotAFileError } from '../errors.js'
4
4
  import { resolve } from './utils/resolve.js'
5
5
  import type { CatOptions } from '../index.js'
6
6
  import type { Blocks } from '@helia/interface/blocks'
@@ -9,8 +9,8 @@ import mergeOpts from 'merge-options'
9
9
  import { CID } from 'multiformats/cid'
10
10
  import * as raw from 'multiformats/codecs/raw'
11
11
  import { sha256 } from 'multiformats/hashes/sha2'
12
+ import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.js'
12
13
  import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
13
- import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
14
14
  import { persist } from './utils/persist.js'
15
15
  import { resolve, updatePathCids } from './utils/resolve.js'
16
16
  import type { ChmodOptions } from '../index.js'
@@ -104,7 +104,7 @@ export async function chmod (cid: CID, mode: number, blockstore: Blocks, options
104
104
  return updatePathCids(root.cid, resolved, blockstore, opts)
105
105
  }
106
106
 
107
- const block = await blockstore.get(resolved.cid)
107
+ const block = await blockstore.get(resolved.cid, options)
108
108
  let metadata: UnixFS
109
109
  let links: PBLink[] = []
110
110
 
@@ -1,10 +1,10 @@
1
1
  import { logger } from '@libp2p/logger'
2
2
  import mergeOpts from 'merge-options'
3
+ import { InvalidParametersError } from '../errors.js'
3
4
  import { addLink } from './utils/add-link.js'
4
5
  import { cidToDirectory } from './utils/cid-to-directory.js'
5
6
  import { cidToPBLink } from './utils/cid-to-pblink.js'
6
7
  import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
7
- import { InvalidParametersError } from './utils/errors.js'
8
8
  import type { CpOptions } from '../index.js'
9
9
  import type { Blocks } from '@helia/interface/blocks'
10
10
  import type { CID } from 'multiformats/cid'
@@ -1,6 +1,6 @@
1
1
  import { exporter, type UnixFSEntry } from 'ipfs-unixfs-exporter'
2
2
  import mergeOpts from 'merge-options'
3
- import { NoContentError, NotADirectoryError } from './utils/errors.js'
3
+ import { NoContentError, NotADirectoryError } from '../errors.js'
4
4
  import { resolve } from './utils/resolve.js'
5
5
  import type { LsOptions } from '../index.js'
6
6
  import type { Blocks } from '@helia/interface/blocks'
@@ -5,11 +5,11 @@ import { exporter } from 'ipfs-unixfs-exporter'
5
5
  import mergeOpts from 'merge-options'
6
6
  import { CID } from 'multiformats/cid'
7
7
  import { sha256 } from 'multiformats/hashes/sha2'
8
+ import { InvalidParametersError, NotADirectoryError } from '../errors.js'
8
9
  import { addLink } from './utils/add-link.js'
9
10
  import { cidToDirectory } from './utils/cid-to-directory.js'
10
11
  import { cidToPBLink } from './utils/cid-to-pblink.js'
11
12
  import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
12
- import { InvalidParametersError, NotADirectoryError } from './utils/errors.js'
13
13
  import type { MkdirOptions } from '../index.js'
14
14
  import type { Blocks } from '@helia/interface/blocks'
15
15
 
@@ -1,8 +1,8 @@
1
1
  import { logger } from '@libp2p/logger'
2
2
  import mergeOpts from 'merge-options'
3
+ import { InvalidParametersError } from '../errors.js'
3
4
  import { cidToDirectory } from './utils/cid-to-directory.js'
4
5
  import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
5
- import { InvalidParametersError } from './utils/errors.js'
6
6
  import { removeLink } from './utils/remove-link.js'
7
7
  import type { RmOptions } from '../index.js'
8
8
  import type { Blocks } from '@helia/interface/blocks'
@@ -4,7 +4,7 @@ import { UnixFS } from 'ipfs-unixfs'
4
4
  import { exporter } from 'ipfs-unixfs-exporter'
5
5
  import mergeOpts from 'merge-options'
6
6
  import * as raw from 'multiformats/codecs/raw'
7
- import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
7
+ import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.js'
8
8
  import { resolve } from './utils/resolve.js'
9
9
  import type { StatOptions, UnixFSStats } from '../index.js'
10
10
  import type { Blocks } from '@helia/interface/blocks'
@@ -9,8 +9,8 @@ import mergeOpts from 'merge-options'
9
9
  import { CID } from 'multiformats/cid'
10
10
  import * as raw from 'multiformats/codecs/raw'
11
11
  import { sha256 } from 'multiformats/hashes/sha2'
12
+ import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.js'
12
13
  import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
13
- import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
14
14
  import { persist } from './utils/persist.js'
15
15
  import { resolve, updatePathCids } from './utils/resolve.js'
16
16
  import type { TouchOptions } from '../index.js'
@@ -108,7 +108,7 @@ export async function touch (cid: CID, blockstore: Blocks, options: Partial<Touc
108
108
  return updatePathCids(root.cid, resolved, blockstore, opts)
109
109
  }
110
110
 
111
- const block = await blockstore.get(resolved.cid)
111
+ const block = await blockstore.get(resolved.cid, options)
112
112
  let metadata: UnixFS
113
113
  let links: PBLink[] = []
114
114
 
@@ -6,8 +6,8 @@ import { sha256 } from 'multiformats/hashes/sha2'
6
6
  // @ts-expect-error no types
7
7
  import SparseArray from 'sparse-array'
8
8
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
9
+ import { AlreadyExistsError, InvalidParametersError, InvalidPBNodeError } from '../../errors.js'
9
10
  import { wrapHash } from './consumable-hash.js'
10
- import { AlreadyExistsError, InvalidParametersError, InvalidPBNodeError } from './errors.js'
11
11
  import { hamtBucketBits, hamtHashFn } from './hamt-constants.js'
12
12
  import {
13
13
  createShard,
@@ -52,12 +52,12 @@ export async function addLink (parent: Directory, child: Required<PBLink>, block
52
52
 
53
53
  const result = await addToDirectory(parent, child, blockstore, options)
54
54
 
55
- if (await isOverShardThreshold(result.node, blockstore, options.shardSplitThresholdBytes)) {
55
+ if (await isOverShardThreshold(result.node, blockstore, options.shardSplitThresholdBytes, options)) {
56
56
  log('converting directory to sharded directory')
57
57
 
58
58
  const converted = await convertToShardedDirectory(result, blockstore)
59
59
  result.cid = converted.cid
60
- result.node = dagPB.decode(await blockstore.get(converted.cid))
60
+ result.node = dagPB.decode(await blockstore.get(converted.cid, options))
61
61
  }
62
62
 
63
63
  return result
@@ -1,5 +1,5 @@
1
1
  import { exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
2
- import { NotADirectoryError } from './errors.js'
2
+ import { NotADirectoryError } from '../../errors.js'
3
3
  import type { Blocks } from '@helia/interface/blocks'
4
4
  import type { PBNode } from '@ipld/dag-pb'
5
5
  import type { CID } from 'multiformats/cid'
@@ -1,6 +1,6 @@
1
1
  import * as dagPb from '@ipld/dag-pb'
2
2
  import { exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
3
- import { NotUnixFSError } from './errors.js'
3
+ import { NotUnixFSError } from '../../errors.js'
4
4
  import type { Blocks } from '@helia/interface/blocks'
5
5
  import type { PBNode, PBLink } from '@ipld/dag-pb'
6
6
  import type { CID } from 'multiformats/cid'
@@ -3,6 +3,7 @@ import { UnixFS } from 'ipfs-unixfs'
3
3
  import { CID_V0, CID_V1 } from './dir-sharded.js'
4
4
  import type { Blocks } from '@helia/interface/blocks'
5
5
  import type { PBNode } from '@ipld/dag-pb'
6
+ import type { AbortOptions } from '@libp2p/interfaces'
6
7
 
7
8
  /**
8
9
  * Estimate node size only based on DAGLink name and CID byte lengths
@@ -10,7 +11,7 @@ import type { PBNode } from '@ipld/dag-pb'
10
11
  *
11
12
  * If the node is a hamt sharded directory the calculation is based on if it was a regular directory.
12
13
  */
13
- export async function isOverShardThreshold (node: PBNode, blockstore: Blocks, threshold: number): Promise<boolean> {
14
+ export async function isOverShardThreshold (node: PBNode, blockstore: Blocks, threshold: number, options: AbortOptions): Promise<boolean> {
14
15
  if (node.Data == null) {
15
16
  throw new Error('DagPB node had no data')
16
17
  }
@@ -21,7 +22,7 @@ export async function isOverShardThreshold (node: PBNode, blockstore: Blocks, th
21
22
  if (unixfs.type === 'directory') {
22
23
  size = estimateNodeSize(node)
23
24
  } else if (unixfs.type === 'hamt-sharded-directory') {
24
- size = await estimateShardSize(node, 0, threshold, blockstore)
25
+ size = await estimateShardSize(node, 0, threshold, blockstore, options)
25
26
  } else {
26
27
  throw new Error('Can only estimate the size of directories or shards')
27
28
  }
@@ -42,7 +43,7 @@ function estimateNodeSize (node: PBNode): number {
42
43
  return size
43
44
  }
44
45
 
45
- async function estimateShardSize (node: PBNode, current: number, max: number, blockstore: Blocks): Promise<number> {
46
+ async function estimateShardSize (node: PBNode, current: number, max: number, blockstore: Blocks, options: AbortOptions): Promise<number> {
46
47
  if (current > max) {
47
48
  return max
48
49
  }
@@ -67,10 +68,10 @@ async function estimateShardSize (node: PBNode, current: number, max: number, bl
67
68
  current += link.Hash.bytes.byteLength
68
69
 
69
70
  if (link.Hash.code === dagPb.code) {
70
- const block = await blockstore.get(link.Hash)
71
+ const block = await blockstore.get(link.Hash, options)
71
72
  const node = dagPb.decode(block)
72
73
 
73
- current += await estimateShardSize(node, current, max, blockstore)
74
+ current += await estimateShardSize(node, current, max, blockstore, options)
74
75
  }
75
76
  }
76
77
 
@@ -3,7 +3,7 @@ import * as dagPB from '@ipld/dag-pb'
3
3
  import { logger } from '@libp2p/logger'
4
4
  import { UnixFS } from 'ipfs-unixfs'
5
5
  import { exporter } from 'ipfs-unixfs-exporter'
6
- import { InvalidParametersError, InvalidPBNodeError } from './errors.js'
6
+ import { InvalidParametersError, InvalidPBNodeError } from '../../errors.js'
7
7
  import {
8
8
  recreateShardedDirectory,
9
9
  type UpdateHamtDirectoryOptions,
@@ -41,7 +41,7 @@ export async function removeLink (parent: Directory, name: string, blockstore: B
41
41
 
42
42
  const result = await removeFromShardedDirectory(parent, name, blockstore, options)
43
43
 
44
- if (!(await isOverShardThreshold(result.node, blockstore, options.shardSplitThresholdBytes))) {
44
+ if (!(await isOverShardThreshold(result.node, blockstore, options.shardSplitThresholdBytes, options))) {
45
45
  log('converting shard to flat directory %c', parent.cid)
46
46
 
47
47
  return convertToFlatDirectory(result, blockstore, options)
@@ -1,9 +1,9 @@
1
1
  import { logger } from '@libp2p/logger'
2
2
  import { exporter } from 'ipfs-unixfs-exporter'
3
+ import { DoesNotExistError, InvalidParametersError } from '../../errors.js'
3
4
  import { addLink } from './add-link.js'
4
5
  import { cidToDirectory } from './cid-to-directory.js'
5
6
  import { cidToPBLink } from './cid-to-pblink.js'
6
- import { DoesNotExistError, InvalidParametersError } from './errors.js'
7
7
  import type { Blocks } from '@helia/interface/blocks'
8
8
  import type { AbortOptions } from '@libp2p/interfaces'
9
9
  import type { CID } from 'multiformats/cid'
package/src/index.ts CHANGED
@@ -80,6 +80,12 @@ export interface CatOptions extends AbortOptions, ProgressOptions<GetEvents> {
80
80
  * An optional path to allow reading files inside directories
81
81
  */
82
82
  path?: string
83
+
84
+ /**
85
+ * If true, do not perform any network operations and throw if blocks are
86
+ * missing from the local store. (default: false)
87
+ */
88
+ offline?: boolean
83
89
  }
84
90
 
85
91
  /**
@@ -102,6 +108,12 @@ export interface ChmodOptions extends AbortOptions, ProgressOptions<GetEvents |
102
108
  * smaller than this value will be regular UnixFS directories.
103
109
  */
104
110
  shardSplitThresholdBytes: number
111
+
112
+ /**
113
+ * If true, do not perform any network operations and throw if blocks are
114
+ * missing from the local store. (default: false)
115
+ */
116
+ offline?: boolean
105
117
  }
106
118
 
107
119
  /**
@@ -118,6 +130,12 @@ export interface CpOptions extends AbortOptions, ProgressOptions<GetEvents | Put
118
130
  * smaller than this value will be regular UnixFS directories.
119
131
  */
120
132
  shardSplitThresholdBytes: number
133
+
134
+ /**
135
+ * If true, do not perform any network operations and throw if blocks are
136
+ * missing from the local store. (default: false)
137
+ */
138
+ offline?: boolean
121
139
  }
122
140
 
123
141
  /**
@@ -139,6 +157,12 @@ export interface LsOptions extends AbortOptions, ProgressOptions<GetEvents> {
139
157
  * Stop reading the directory contents after this many directory entries
140
158
  */
141
159
  length?: number
160
+
161
+ /**
162
+ * If true, do not perform any network operations and throw if blocks are
163
+ * missing from the local store. (default: false)
164
+ */
165
+ offline?: boolean
142
166
  }
143
167
 
144
168
  /**
@@ -171,6 +195,12 @@ export interface MkdirOptions extends AbortOptions, ProgressOptions<GetEvents |
171
195
  * smaller than this value will be regular UnixFS directories.
172
196
  */
173
197
  shardSplitThresholdBytes: number
198
+
199
+ /**
200
+ * If true, do not perform any network operations and throw if blocks are
201
+ * missing from the local store. (default: false)
202
+ */
203
+ offline?: boolean
174
204
  }
175
205
 
176
206
  /**
@@ -182,6 +212,12 @@ export interface RmOptions extends AbortOptions, ProgressOptions<GetEvents | Put
182
212
  * smaller than this value will be regular UnixFS directories.
183
213
  */
184
214
  shardSplitThresholdBytes: number
215
+
216
+ /**
217
+ * If true, do not perform any network operations and throw if blocks are
218
+ * missing from the local store. (default: false)
219
+ */
220
+ offline?: boolean
185
221
  }
186
222
 
187
223
  /**
@@ -192,6 +228,12 @@ export interface StatOptions extends AbortOptions, ProgressOptions<GetEvents> {
192
228
  * An optional path to allow statting paths inside directories
193
229
  */
194
230
  path?: string
231
+
232
+ /**
233
+ * If true, do not perform any network operations and throw if blocks are
234
+ * missing from the local store. (default: false)
235
+ */
236
+ offline?: boolean
195
237
  }
196
238
 
197
239
  /**
@@ -275,6 +317,12 @@ export interface TouchOptions extends AbortOptions, ProgressOptions<GetEvents |
275
317
  * smaller than this value will be regular UnixFS directories.
276
318
  */
277
319
  shardSplitThresholdBytes: number
320
+
321
+ /**
322
+ * If true, do not perform any network operations and throw if blocks are
323
+ * missing from the local store. (default: false)
324
+ */
325
+ offline?: boolean
278
326
  }
279
327
 
280
328
  /**
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/commands/utils/errors.ts"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