diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 290ad02..0bc3b42 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,6 @@ updates: interval: daily time: "10:00" open-pull-requests-limit: 10 + commit-message: + prefix: "deps" + prefix-development: "deps(dev)" diff --git a/README.md b/README.md index 5296e98..d5b0295 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,29 @@ -# js-datastore-core +# datastore-core -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io) -[![](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) +[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) +[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) [![codecov](https://img.shields.io/codecov/c/github/ipfs/js-datastore-core.svg?style=flat-square)](https://codecov.io/gh/ipfs/js-datastore-core) -[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/ipfs/js-datastore-core/ci?label=ci&style=flat-square)](https://github.com/ipfs/js-datastore-core/actions?query=branch%3Amaster+workflow%3Aci+) +[![CI](https://img.shields.io/github/workflow/status/ipfs/js-datastore-core/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/js-datastore-core/actions/workflows/js-test-and-release.yml) -> Implementations for [interface-datastore](https://github.com/ipfs/js-ipfs-interfaces/packages/interface-datastore). +> Wrapper implementation for interface-datastore -## Lead Maintainer +## Table of contents -[Alex Potsides](https://github.com/achingbrain) - -## Table of Contents - -- [Implementations](#implementations) - [Install](#install) +- [Implementations](#implementations) - [Usage](#usage) - [BaseDatastore](#basedatastore) - [Wrapping Stores](#wrapping-stores) - [Contribute](#contribute) - [License](#license) +- [Contribute](#contribute-1) + +## Install + +```console +$ npm i datastore-core +``` ## Implementations @@ -31,21 +34,14 @@ - Tiered: [`src/tiered`](src/tirered.js) - Namespace: [`src/namespace`](src/namespace.js) -## Install - -``` -$ npm install datastore-core -``` - ## Usage - ### BaseDatastore An base store is made available to make implementing your own datastore easier: ```javascript -const { BaseDatastore } from 'datastore-core') +import { BaseDatastore } from 'datastore-core' class MyDatastore extends BaseDatastore { constructor () { @@ -88,5 +84,15 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c ## License -[MIT](LICENSE) +Licensed under either of + +- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / ) +- MIT ([LICENSE-MIT](LICENSE-MIT) / ) + +## Contribute +Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! + +This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/package.json b/package.json index 50b032a..8bcb3da 100644 --- a/package.json +++ b/package.json @@ -22,54 +22,69 @@ "node": ">=16.0.0", "npm": ">=7.0.0" }, - "main": "src/index.js", "type": "module", - "types": "types/src/index.d.ts", + "types": "./dist/src/index.d.ts", "typesVersions": { "*": { "*": [ - "types/*", - "types/src/*" + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" ], - "types/*": [ - "types/*", - "types/src/*" + "src/*": [ + "*", + "dist/*", + "dist/src/*", + "dist/src/*/index" ] } }, "files": [ - "*", + "src", + "dist", + "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./dist/src/index.d.ts", "import": "./src/index.js" }, "./base": { + "types": "./src/base.d.ts", "import": "./src/base.js" }, "./errors": { + "types": "./src/errors.d.ts", "import": "./src/errors.js" }, "./keytransform": { + "types": "./src/keytransform.d.ts", "import": "./src/keytransform.js" }, "./memory": { + "types": "./src/memory.d.ts", "import": "./src/memory.js" }, "./mount": { + "types": "./src/mount.d.ts", "import": "./src/mount.js" }, "./namespace": { + "types": "./src/namespace.d.ts", "import": "./src/namespace.js" }, "./shard": { + "types": "./src/shard.d.ts", "import": "./src/shard.js" }, "./sharding": { + "types": "./src/sharding.d.ts", "import": "./src/sharding.js" }, "./tiered": { + "types": "./src/tiered.d.ts", "import": "./src/tiered.js" } }, @@ -106,15 +121,15 @@ "release": "patch" }, { - "type": "chore", + "type": "docs", "release": "patch" }, { - "type": "docs", + "type": "test", "release": "patch" }, { - "type": "test", + "type": "deps", "release": "patch" }, { @@ -144,7 +159,11 @@ }, { "type": "docs", - "section": "Trivial Changes" + "section": "Documentation" + }, + { + "type": "deps", + "section": "Dependencies" }, { "type": "test", @@ -155,51 +174,41 @@ } ], "@semantic-release/changelog", - [ - "@semantic-release/npm", - { - "pkgRoot": "dist" - } - ], + "@semantic-release/npm", "@semantic-release/github", "@semantic-release/git" ] }, "scripts": { - "clean": "rimraf dist types", - "prepare": "aegir build --no-bundle && cp -R types dist", - "lint": "aegir ts -p check && aegir lint", - "build": "aegir build --esm-tests", - "release": "semantic-release", + "clean": "aegir clean", + "lint": "aegir lint", + "build": "aegir build", + "release": "aegir release", "test": "aegir test", - "test:node": "aegir test -t node", - "test:chrome": "aegir test -t browser", + "test:node": "aegir test -t node --cov", + "test:chrome": "aegir test -t browser --cov", "test:chrome-webworker": "aegir test -t webworker", "test:firefox": "aegir test -t browser -- --browser firefox", "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", - "test:electron-main": "aegir test -t electron-main -f dist/cjs/node-test/*js", - "test:electron-renderer": "aegir test -t electron-renderer -f dist/cjs/node-test/*js", - "dep-check": "aegir dep-check -i rimraf" + "test:electron-main": "aegir test -t electron-main", + "dep-check": "aegir dep-check" }, "dependencies": { - "debug": "^4.1.1", + "@libp2p/logger": "^2.0.0", "err-code": "^3.0.1", "interface-datastore": "^6.0.2", + "it-all": "^1.0.4", "it-drain": "^1.0.4", "it-filter": "^1.0.2", "it-map": "^1.0.5", "it-merge": "^1.0.1", - "it-pipe": "^1.1.0", - "it-pushable": "^1.4.2", + "it-pipe": "^2.0.3", + "it-pushable": "^3.0.0", "it-take": "^1.0.1", "uint8arrays": "^3.0.0" }, "devDependencies": { - "@types/debug": "^4.1.5", - "aegir": "^36.1.3", - "interface-datastore-tests": "^2.0.3", - "it-all": "^1.0.4", - "rimraf": "^3.0.2", - "util": "^0.12.4" + "aegir": "^37.4.5", + "interface-datastore-tests": "^2.0.3" } } diff --git a/src/tiered.js b/src/tiered.js index 0e38669..6422420 100644 --- a/src/tiered.js +++ b/src/tiered.js @@ -1,10 +1,10 @@ import { BaseDatastore } from './base.js' import * as Errors from './errors.js' -import debug from 'debug' -import pushable from 'it-pushable' +import { logger } from '@libp2p/logger' +import { pushable } from 'it-pushable' import drain from 'it-drain' -const log = debug('datastore:core:tiered') +const log = logger('datastore:core:tiered') /** * @typedef {import('interface-datastore').Datastore} Datastore @@ -69,7 +69,7 @@ export class TieredDatastore extends BaseDatastore { const res = await store.get(key, options) if (res) return res } catch (err) { - log(err) + log.error(err) } } throw Errors.notFoundError() @@ -109,7 +109,9 @@ export class TieredDatastore extends BaseDatastore { async * putMany (source, options = {}) { let error const pushables = this.stores.map(store => { - const source = pushable() + const source = pushable({ + objectMode: true + }) drain(store.putMany(source, options)) .catch(err => { @@ -143,7 +145,9 @@ export class TieredDatastore extends BaseDatastore { async * deleteMany (source, options = {}) { let error const pushables = this.stores.map(store => { - const source = pushable() + const source = pushable({ + objectMode: true + }) drain(store.deleteMany(source, options)) .catch(err => { diff --git a/test/keytransform.spec.js b/test/keytransform.spec.js index 178a661..961dfcd 100644 --- a/test/keytransform.spec.js +++ b/test/keytransform.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import all from 'it-all' import { Key } from 'interface-datastore/key' import { MemoryDatastore } from '../src/memory.js' diff --git a/test/mount.spec.js b/test/mount.spec.js index 921e64d..ee1f2ad 100644 --- a/test/mount.spec.js +++ b/test/mount.spec.js @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 8] */ -import { expect, assert } from 'aegir/utils/chai.js' +import { expect, assert } from 'aegir/chai' import all from 'it-all' import { Key } from 'interface-datastore/key' import { MemoryDatastore } from '../src/memory.js' diff --git a/test/namespace.spec.js b/test/namespace.spec.js index bc57aa2..25980bd 100644 --- a/test/namespace.spec.js +++ b/test/namespace.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import all from 'it-all' import { Key } from 'interface-datastore/key' import { MemoryDatastore } from '../src/memory.js' diff --git a/test/shard.spec.js b/test/shard.spec.js index 37880e7..f1a7b22 100644 --- a/test/shard.spec.js +++ b/test/shard.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import { Prefix, Suffix, diff --git a/test/sharding.spec.js b/test/sharding.spec.js index cc0657b..cdafd6c 100644 --- a/test/sharding.spec.js +++ b/test/sharding.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import { Key } from 'interface-datastore/key' import { MemoryDatastore } from '../src/memory.js' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' diff --git a/test/tiered.spec.js b/test/tiered.spec.js index 1ed30ef..47b492a 100644 --- a/test/tiered.spec.js +++ b/test/tiered.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import { Key } from 'interface-datastore/key' import { MemoryDatastore } from '../src/memory.js' import { TieredDatastore } from '../src/tiered.js' diff --git a/test/utils.spec.js b/test/utils.spec.js index b55b564..a2bceef 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { expect } from 'aegir/utils/chai.js' +import { expect } from 'aegir/chai' import * as utils from '../src/utils.js' import filter from 'it-filter' import take from 'it-take' diff --git a/tsconfig.json b/tsconfig.json index c743414..2742a08 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "aegir/src/config/tsconfig.aegir.json", "compilerOptions": { - "outDir": "types" + "outDir": "dist", + "emitDeclarationOnly": true }, "include": [ "test",