@helia/unixfs 3.0.0-ca8d5eb → 3.0.0-dc2e7a6

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 (74) hide show
  1. package/dist/index.min.js +1 -1
  2. package/dist/src/commands/add.d.ts +6 -6
  3. package/dist/src/commands/add.d.ts.map +1 -1
  4. package/dist/src/commands/add.js.map +1 -1
  5. package/dist/src/commands/cat.d.ts +2 -2
  6. package/dist/src/commands/cat.d.ts.map +1 -1
  7. package/dist/src/commands/cat.js.map +1 -1
  8. package/dist/src/commands/chmod.d.ts +2 -2
  9. package/dist/src/commands/chmod.d.ts.map +1 -1
  10. package/dist/src/commands/chmod.js.map +1 -1
  11. package/dist/src/commands/cp.d.ts +2 -2
  12. package/dist/src/commands/cp.d.ts.map +1 -1
  13. package/dist/src/commands/cp.js.map +1 -1
  14. package/dist/src/commands/ls.d.ts +2 -2
  15. package/dist/src/commands/ls.d.ts.map +1 -1
  16. package/dist/src/commands/ls.js.map +1 -1
  17. package/dist/src/commands/mkdir.d.ts +2 -2
  18. package/dist/src/commands/mkdir.d.ts.map +1 -1
  19. package/dist/src/commands/mkdir.js.map +1 -1
  20. package/dist/src/commands/rm.d.ts +2 -2
  21. package/dist/src/commands/rm.d.ts.map +1 -1
  22. package/dist/src/commands/rm.js.map +1 -1
  23. package/dist/src/commands/stat.d.ts +2 -2
  24. package/dist/src/commands/stat.d.ts.map +1 -1
  25. package/dist/src/commands/stat.js.map +1 -1
  26. package/dist/src/commands/touch.d.ts +2 -2
  27. package/dist/src/commands/touch.d.ts.map +1 -1
  28. package/dist/src/commands/touch.js.map +1 -1
  29. package/dist/src/commands/utils/add-link.d.ts +2 -2
  30. package/dist/src/commands/utils/add-link.d.ts.map +1 -1
  31. package/dist/src/commands/utils/add-link.js.map +1 -1
  32. package/dist/src/commands/utils/cid-to-directory.d.ts +2 -2
  33. package/dist/src/commands/utils/cid-to-directory.d.ts.map +1 -1
  34. package/dist/src/commands/utils/cid-to-directory.js.map +1 -1
  35. package/dist/src/commands/utils/cid-to-pblink.d.ts +2 -2
  36. package/dist/src/commands/utils/cid-to-pblink.d.ts.map +1 -1
  37. package/dist/src/commands/utils/cid-to-pblink.js.map +1 -1
  38. package/dist/src/commands/utils/dir-sharded.d.ts +3 -3
  39. package/dist/src/commands/utils/dir-sharded.d.ts.map +1 -1
  40. package/dist/src/commands/utils/dir-sharded.js.map +1 -1
  41. package/dist/src/commands/utils/hamt-utils.d.ts +4 -4
  42. package/dist/src/commands/utils/hamt-utils.d.ts.map +1 -1
  43. package/dist/src/commands/utils/hamt-utils.js.map +1 -1
  44. package/dist/src/commands/utils/is-over-shard-threshold.d.ts +2 -2
  45. package/dist/src/commands/utils/is-over-shard-threshold.d.ts.map +1 -1
  46. package/dist/src/commands/utils/is-over-shard-threshold.js.map +1 -1
  47. package/dist/src/commands/utils/remove-link.d.ts +2 -2
  48. package/dist/src/commands/utils/remove-link.d.ts.map +1 -1
  49. package/dist/src/commands/utils/remove-link.js.map +1 -1
  50. package/dist/src/commands/utils/resolve.d.ts +3 -3
  51. package/dist/src/commands/utils/resolve.d.ts.map +1 -1
  52. package/dist/src/commands/utils/resolve.js.map +1 -1
  53. package/dist/src/index.d.ts +4 -3
  54. package/dist/src/index.d.ts.map +1 -1
  55. package/dist/src/index.js.map +1 -1
  56. package/package.json +16 -16
  57. package/src/commands/add.ts +6 -6
  58. package/src/commands/cat.ts +2 -2
  59. package/src/commands/chmod.ts +2 -2
  60. package/src/commands/cp.ts +2 -2
  61. package/src/commands/ls.ts +2 -2
  62. package/src/commands/mkdir.ts +2 -2
  63. package/src/commands/rm.ts +2 -2
  64. package/src/commands/stat.ts +3 -3
  65. package/src/commands/touch.ts +2 -2
  66. package/src/commands/utils/add-link.ts +5 -5
  67. package/src/commands/utils/cid-to-directory.ts +2 -2
  68. package/src/commands/utils/cid-to-pblink.ts +2 -2
  69. package/src/commands/utils/dir-sharded.ts +4 -4
  70. package/src/commands/utils/hamt-utils.ts +4 -4
  71. package/src/commands/utils/is-over-shard-threshold.ts +3 -3
  72. package/src/commands/utils/remove-link.ts +5 -5
  73. package/src/commands/utils/resolve.ts +3 -3
  74. package/src/index.ts +4 -3
@@ -1,9 +1,9 @@
1
1
  import * as dagPb from '@ipld/dag-pb'
2
2
  import { UnixFS } from 'ipfs-unixfs'
3
3
  import { CID_V0, CID_V1 } from './dir-sharded.js'
4
- import type { Blocks } from '@helia/interface/blocks'
5
4
  import type { PBNode } from '@ipld/dag-pb'
6
5
  import type { AbortOptions } from '@libp2p/interface'
6
+ import type { Blockstore } from 'interface-blockstore'
7
7
 
8
8
  /**
9
9
  * Estimate node size only based on DAGLink name and CID byte lengths
@@ -11,7 +11,7 @@ import type { AbortOptions } from '@libp2p/interface'
11
11
  *
12
12
  * If the node is a hamt sharded directory the calculation is based on if it was a regular directory.
13
13
  */
14
- export async function isOverShardThreshold (node: PBNode, blockstore: Blocks, threshold: number, options: AbortOptions): Promise<boolean> {
14
+ export async function isOverShardThreshold (node: PBNode, blockstore: Blockstore, threshold: number, options: AbortOptions): Promise<boolean> {
15
15
  if (node.Data == null) {
16
16
  throw new Error('DagPB node had no data')
17
17
  }
@@ -43,7 +43,7 @@ function estimateNodeSize (node: PBNode): number {
43
43
  return size
44
44
  }
45
45
 
46
- async function estimateShardSize (node: PBNode, current: number, max: number, blockstore: Blocks, options: AbortOptions): Promise<number> {
46
+ async function estimateShardSize (node: PBNode, current: number, max: number, blockstore: Blockstore, options: AbortOptions): Promise<number> {
47
47
  if (current > max) {
48
48
  return max
49
49
  }
@@ -11,9 +11,9 @@ import {
11
11
  import { isOverShardThreshold } from './is-over-shard-threshold.js'
12
12
  import { persist } from './persist.js'
13
13
  import type { Directory } from './cid-to-directory.js'
14
- import type { Blocks } from '@helia/interface/blocks'
15
14
  import type { PBNode } from '@ipld/dag-pb'
16
15
  import type { AbortOptions } from '@libp2p/interface'
16
+ import type { Blockstore } from 'interface-blockstore'
17
17
  import type { CID, Version } from 'multiformats/cid'
18
18
 
19
19
  const log = logger('helia:unixfs:utils:remove-link')
@@ -28,7 +28,7 @@ export interface RemoveLinkResult {
28
28
  cid: CID
29
29
  }
30
30
 
31
- export async function removeLink (parent: Directory, name: string, blockstore: Blocks, options: RmLinkOptions): Promise<RemoveLinkResult> {
31
+ export async function removeLink (parent: Directory, name: string, blockstore: Blockstore, options: RmLinkOptions): Promise<RemoveLinkResult> {
32
32
  if (parent.node.Data == null) {
33
33
  throw new InvalidPBNodeError('Parent node had no data')
34
34
  }
@@ -54,7 +54,7 @@ export async function removeLink (parent: Directory, name: string, blockstore: B
54
54
  return removeFromDirectory(parent, name, blockstore, options)
55
55
  }
56
56
 
57
- const removeFromDirectory = async (parent: Directory, name: string, blockstore: Blocks, options: AbortOptions): Promise<RemoveLinkResult> => {
57
+ const removeFromDirectory = async (parent: Directory, name: string, blockstore: Blockstore, options: AbortOptions): Promise<RemoveLinkResult> => {
58
58
  // Remove existing link if it exists
59
59
  parent.node.Links = parent.node.Links.filter((link) => {
60
60
  return link.Name !== name
@@ -74,7 +74,7 @@ const removeFromDirectory = async (parent: Directory, name: string, blockstore:
74
74
  }
75
75
  }
76
76
 
77
- const removeFromShardedDirectory = async (parent: Directory, name: string, blockstore: Blocks, options: UpdateHamtDirectoryOptions): Promise<{ cid: CID, node: PBNode }> => {
77
+ const removeFromShardedDirectory = async (parent: Directory, name: string, blockstore: Blockstore, options: UpdateHamtDirectoryOptions): Promise<{ cid: CID, node: PBNode }> => {
78
78
  const { path } = await recreateShardedDirectory(parent.cid, name, blockstore, options)
79
79
  const finalSegment = path[path.length - 1]
80
80
 
@@ -131,7 +131,7 @@ const removeFromShardedDirectory = async (parent: Directory, name: string, block
131
131
  return updateShardedDirectory(path, blockstore, options)
132
132
  }
133
133
 
134
- const convertToFlatDirectory = async (parent: Directory, blockstore: Blocks, options: RmLinkOptions): Promise<RemoveLinkResult> => {
134
+ const convertToFlatDirectory = async (parent: Directory, blockstore: Blockstore, options: RmLinkOptions): Promise<RemoveLinkResult> => {
135
135
  if (parent.node.Data == null) {
136
136
  throw new InvalidParametersError('Invalid parent passed to convertToFlatDirectory')
137
137
  }
@@ -4,8 +4,8 @@ import { DoesNotExistError, InvalidParametersError } from '../../errors.js'
4
4
  import { addLink } from './add-link.js'
5
5
  import { cidToDirectory } from './cid-to-directory.js'
6
6
  import { cidToPBLink } from './cid-to-pblink.js'
7
- import type { Blocks } from '@helia/interface/blocks'
8
7
  import type { AbortOptions } from '@libp2p/interface'
8
+ import type { Blockstore } from 'interface-blockstore'
9
9
  import type { CID } from 'multiformats/cid'
10
10
 
11
11
  const log = logger('helia:unixfs:components:utils:resolve')
@@ -32,7 +32,7 @@ export interface ResolveResult {
32
32
  segments?: Segment[]
33
33
  }
34
34
 
35
- export async function resolve (cid: CID, path: string | undefined, blockstore: Blocks, options: AbortOptions): Promise<ResolveResult> {
35
+ export async function resolve (cid: CID, path: string | undefined, blockstore: Blockstore, options: AbortOptions): Promise<ResolveResult> {
36
36
  if (path == null || path === '') {
37
37
  return { cid }
38
38
  }
@@ -101,7 +101,7 @@ export interface UpdatePathCidsOptions extends AbortOptions {
101
101
  * Where we have descended into a DAG to update a child node, ascend up the DAG creating
102
102
  * new hashes and blocks for the changed content
103
103
  */
104
- export async function updatePathCids (cid: CID, result: ResolveResult, blockstore: Blocks, options: UpdatePathCidsOptions): Promise<CID> {
104
+ export async function updatePathCids (cid: CID, result: ResolveResult, blockstore: Blockstore, options: UpdatePathCidsOptions): Promise<CID> {
105
105
  if (result.segments == null || result.segments.length === 0) {
106
106
  return cid
107
107
  }
package/src/index.ts CHANGED
@@ -52,8 +52,9 @@ import { mkdir } from './commands/mkdir.js'
52
52
  import { rm } from './commands/rm.js'
53
53
  import { stat } from './commands/stat.js'
54
54
  import { touch } from './commands/touch.js'
55
- import type { Blocks, GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
55
+ import type { GetBlockProgressEvents, PutBlockProgressEvents } from '@helia/interface/blocks'
56
56
  import type { AbortOptions } from '@libp2p/interface'
57
+ import type { Blockstore } from 'interface-blockstore'
57
58
  import type { Mtime, UnixFS as IPFSUnixFS } from 'ipfs-unixfs'
58
59
  import type { ExporterProgressEvents, UnixFSEntry } from 'ipfs-unixfs-exporter'
59
60
  import type { ByteStream, DirectoryCandidate, FileCandidate, ImportCandidateStream, ImporterOptions, ImporterProgressEvents, ImportResult } from 'ipfs-unixfs-importer'
@@ -61,7 +62,7 @@ import type { CID, Version } from 'multiformats/cid'
61
62
  import type { ProgressOptions } from 'progress-events'
62
63
 
63
64
  export interface UnixFSComponents {
64
- blockstore: Blocks
65
+ blockstore: Blockstore
65
66
  }
66
67
 
67
68
  export type AddEvents = PutBlockProgressEvents
@@ -616,7 +617,7 @@ class DefaultUnixFS implements UnixFS {
616
617
  /**
617
618
  * Create a {@link UnixFS} instance for use with {@link https://github.com/ipfs/helia Helia}
618
619
  */
619
- export function unixfs (helia: { blockstore: Blocks }): UnixFS {
620
+ export function unixfs (helia: { blockstore: Blockstore }): UnixFS {
620
621
  return new DefaultUnixFS(helia)
621
622
  }
622
623