Skip to content

Commit

Permalink
fix: export unixfs errors (#50)
Browse files Browse the repository at this point in the history
Export error defs for reuse in other unixfs related modules
  • Loading branch information
achingbrain authored Jun 7, 2023
1 parent 189d7e5 commit 8426d65
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 25 deletions.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"keywords": [
"ipfs"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"private": true,
"scripts": {
"reset": "aegir run clean && aegir clean **/node_modules **/package-lock.json",
Expand Down
4 changes: 0 additions & 4 deletions packages/interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
"keywords": [
"IPFS"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"files": [
Expand Down
24 changes: 20 additions & 4 deletions packages/unixfs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,24 @@
"keywords": [
"IPFS"
],
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
},
"type": "module",
"types": "./dist/src/index.d.ts",
"typesVersions": {
"*": {
"*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
],
"src/*": [
"*",
"dist/*",
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"src",
"dist",
Expand All @@ -30,6 +42,10 @@
".": {
"types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
},
"./errors": {
"types": "./dist/src/errors.d.ts",
"import": "./dist/src/errors.js"
}
},
"eslintConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/cat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exporter } from 'ipfs-unixfs-exporter'
import mergeOpts from 'merge-options'
import { NoContentError, NotAFileError } from './utils/errors.js'
import { NoContentError, NotAFileError } from '../errors.js'
import { resolve } from './utils/resolve.js'
import type { CatOptions } from '../index.js'
import type { Blocks } from '@helia/interface/blocks'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/chmod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import mergeOpts from 'merge-options'
import { CID } from 'multiformats/cid'
import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.js'
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
import { persist } from './utils/persist.js'
import { resolve, updatePathCids } from './utils/resolve.js'
import type { ChmodOptions } from '../index.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/cp.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { logger } from '@libp2p/logger'
import mergeOpts from 'merge-options'
import { InvalidParametersError } from '../errors.js'
import { addLink } from './utils/add-link.js'
import { cidToDirectory } from './utils/cid-to-directory.js'
import { cidToPBLink } from './utils/cid-to-pblink.js'
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
import { InvalidParametersError } from './utils/errors.js'
import type { CpOptions } from '../index.js'
import type { Blocks } from '@helia/interface/blocks'
import type { CID } from 'multiformats/cid'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/ls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { exporter, type UnixFSEntry } from 'ipfs-unixfs-exporter'
import mergeOpts from 'merge-options'
import { NoContentError, NotADirectoryError } from './utils/errors.js'
import { NoContentError, NotADirectoryError } from '../errors.js'
import { resolve } from './utils/resolve.js'
import type { LsOptions } from '../index.js'
import type { Blocks } from '@helia/interface/blocks'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/mkdir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { exporter } from 'ipfs-unixfs-exporter'
import mergeOpts from 'merge-options'
import { CID } from 'multiformats/cid'
import { sha256 } from 'multiformats/hashes/sha2'
import { InvalidParametersError, NotADirectoryError } from '../errors.js'
import { addLink } from './utils/add-link.js'
import { cidToDirectory } from './utils/cid-to-directory.js'
import { cidToPBLink } from './utils/cid-to-pblink.js'
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
import { InvalidParametersError, NotADirectoryError } from './utils/errors.js'
import type { MkdirOptions } from '../index.js'
import type { Blocks } from '@helia/interface/blocks'

Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/rm.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { logger } from '@libp2p/logger'
import mergeOpts from 'merge-options'
import { InvalidParametersError } from '../errors.js'
import { cidToDirectory } from './utils/cid-to-directory.js'
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
import { InvalidParametersError } from './utils/errors.js'
import { removeLink } from './utils/remove-link.js'
import type { RmOptions } from '../index.js'
import type { Blocks } from '@helia/interface/blocks'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/stat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { UnixFS } from 'ipfs-unixfs'
import { exporter } from 'ipfs-unixfs-exporter'
import mergeOpts from 'merge-options'
import * as raw from 'multiformats/codecs/raw'
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.js'
import { resolve } from './utils/resolve.js'
import type { StatOptions, UnixFSStats } from '../index.js'
import type { Blocks } from '@helia/interface/blocks'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/touch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import mergeOpts from 'merge-options'
import { CID } from 'multiformats/cid'
import * as raw from 'multiformats/codecs/raw'
import { sha256 } from 'multiformats/hashes/sha2'
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from '../errors.js'
import { SHARD_SPLIT_THRESHOLD_BYTES } from './utils/constants.js'
import { InvalidPBNodeError, NotUnixFSError, UnknownError } from './utils/errors.js'
import { persist } from './utils/persist.js'
import { resolve, updatePathCids } from './utils/resolve.js'
import type { TouchOptions } from '../index.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/utils/add-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { sha256 } from 'multiformats/hashes/sha2'
// @ts-expect-error no types
import SparseArray from 'sparse-array'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { AlreadyExistsError, InvalidParametersError, InvalidPBNodeError } from '../../errors.js'
import { wrapHash } from './consumable-hash.js'
import { AlreadyExistsError, InvalidParametersError, InvalidPBNodeError } from './errors.js'
import { hamtBucketBits, hamtHashFn } from './hamt-constants.js'
import {
createShard,
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/utils/cid-to-directory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
import { NotADirectoryError } from './errors.js'
import { NotADirectoryError } from '../../errors.js'
import type { Blocks } from '@helia/interface/blocks'
import type { PBNode } from '@ipld/dag-pb'
import type { CID } from 'multiformats/cid'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/utils/cid-to-pblink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as dagPb from '@ipld/dag-pb'
import { exporter, type ExporterOptions } from 'ipfs-unixfs-exporter'
import { NotUnixFSError } from './errors.js'
import { NotUnixFSError } from '../../errors.js'
import type { Blocks } from '@helia/interface/blocks'
import type { PBNode, PBLink } from '@ipld/dag-pb'
import type { CID } from 'multiformats/cid'
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/utils/remove-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as dagPB from '@ipld/dag-pb'
import { logger } from '@libp2p/logger'
import { UnixFS } from 'ipfs-unixfs'
import { exporter } from 'ipfs-unixfs-exporter'
import { InvalidParametersError, InvalidPBNodeError } from './errors.js'
import { InvalidParametersError, InvalidPBNodeError } from '../../errors.js'
import {
recreateShardedDirectory,
type UpdateHamtDirectoryOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/unixfs/src/commands/utils/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { logger } from '@libp2p/logger'
import { exporter } from 'ipfs-unixfs-exporter'
import { DoesNotExistError, InvalidParametersError } from '../../errors.js'
import { addLink } from './add-link.js'
import { cidToDirectory } from './cid-to-directory.js'
import { cidToPBLink } from './cid-to-pblink.js'
import { DoesNotExistError, InvalidParametersError } from './errors.js'
import type { Blocks } from '@helia/interface/blocks'
import type { AbortOptions } from '@libp2p/interfaces'
import type { CID } from 'multiformats/cid'
Expand Down
File renamed without changes.

0 comments on commit 8426d65

Please sign in to comment.