Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

feat: ts types, github ci and clean up #39

Merged
merged 37 commits into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6826711
feat: ts types, github ci and clean up
hugomrdias Nov 30, 2020
709e115
fix more types and ci
hugomrdias Dec 3, 2020
e31f992
Update src/keytransform.js
hugomrdias Dec 9, 2020
f0e324f
Update src/keytransform.js
hugomrdias Dec 9, 2020
67a8162
Update src/keytransform.js
hugomrdias Dec 9, 2020
a6b241a
Update src/mount.js
hugomrdias Dec 9, 2020
bb89d0e
Update src/mount.js
hugomrdias Dec 9, 2020
0096eaf
Update src/namespace.js
hugomrdias Dec 9, 2020
d710e97
Update src/namespace.js
hugomrdias Dec 9, 2020
c59d259
Update src/shard.js
hugomrdias Dec 9, 2020
d95855e
Update .github/workflows/main.yml
hugomrdias Dec 9, 2020
ecd45d9
Update src/keytransform.js
hugomrdias Dec 9, 2020
d5312e6
Update src/keytransform.js
hugomrdias Dec 9, 2020
973c587
Update src/keytransform.js
hugomrdias Dec 9, 2020
93065f5
Update src/keytransform.js
hugomrdias Dec 9, 2020
dd6328b
Update src/tiered.js
hugomrdias Dec 9, 2020
c1787e1
Update src/tiered.js
hugomrdias Dec 9, 2020
674c4de
Update src/tiered.js
hugomrdias Dec 9, 2020
0e389f4
Update src/sharding.js
hugomrdias Dec 9, 2020
78f9a9a
Update src/sharding.js
hugomrdias Dec 9, 2020
754de48
Update src/sharding.js
hugomrdias Dec 9, 2020
85b0019
Update src/sharding.js
hugomrdias Dec 9, 2020
b203ccf
Update src/sharding.js
hugomrdias Dec 9, 2020
068759b
Update src/sharding.js
hugomrdias Dec 9, 2020
fd85631
Update src/sharding.js
hugomrdias Dec 9, 2020
ea63f1d
Update src/tiered.js
hugomrdias Dec 9, 2020
d239031
fix: feedback
hugomrdias Dec 9, 2020
81233e0
Merge branch 'feat/ts-types' of https://github.com/ipfs/js-datastore-…
hugomrdias Dec 9, 2020
5c53bc8
chore: change ci to npm
hugomrdias Dec 9, 2020
d4fbde5
chore:ci
hugomrdias Dec 11, 2020
e7b39e1
add prepare
hugomrdias Dec 11, 2020
edbaa19
ci
hugomrdias Dec 11, 2020
10ae98e
fix: ci
hugomrdias Dec 11, 2020
f5a3d56
fix: new aegir config and remove typesVersion
hugomrdias Jan 12, 2021
b727005
chore: remove gh dep url
achingbrain Jan 15, 2021
cabcdea
fix: update interface-datastore
hugomrdias Jan 16, 2021
2aab333
chore: remove gh url
achingbrain Jan 17, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir lint
- uses: gozala/[email protected]
- run: npx aegir build
- run: npx aegir dep-check
- uses: ipfs/aegir/actions/bundle-size@master
name: size
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [12, 14]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
- uses: codecov/codecov-action@v1
test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser -t webworker --bail
test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-main --bail
test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm install
- run: npx xvfb-maybe aegir test -t electron-renderer --bail
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
# js-datastore-core
# js-datastore-core <!-- omit in toc -->

[![](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)
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
[![Build Status](https://flat.badgen.net/travis/ipfs/js-datastore-core)](https://travis-ci.com/ipfs/js-datastore-core)
[![Codecov](https://codecov.io/gh/ipfs/js-datastore-core/branch/master/graph/badge.svg)](https://codecov.io/gh/ipfs/js-datastore-core)
[![Dependency Status](https://david-dm.org/ipfs/js-datastore-core.svg?style=flat-square)](https://david-dm.org/ipfs/js-datastore-core)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)
![](https://img.shields.io/badge/npm-%3E%3D3.0.0-orange.svg?style=flat-square)
![](https://img.shields.io/badge/Node.js-%3E%3D8.0.0-orange.svg?style=flat-square)
[![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+)

> Wrapping implementations for [interface-datastore](https://github.com/ipfs/interface-datastore).

## Lead Maintainer
## Lead Maintainer <!-- omit in toc -->

[Alex Potsides](https://github.com/achingbrain)

## Table of Contents

- [js-datastore-core](#js-datastore-core)
- [Lead Maintainer](#lead-maintainer)
- [Table of Contents](#table-of-contents)
- [Implementations](#implementations)
- [Install](#install)
- [Usage](#usage)
- [Wrapping Stores](#wrapping-stores)
- [Contribute](#contribute)
- [License](#license)
## Table of Contents <!-- omit in toc -->

- [Implementations](#implementations)
- [Install](#install)
- [Usage](#usage)
- [Wrapping Stores](#wrapping-stores)
- [Contribute](#contribute)
- [License](#license)

## Implementations

Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "datastore-core",
"version": "2.0.1",
"description": "Wrapper implmentation for interface-datastore",
"leadMaintainer": "Pedro Teixeira <pedro@protocol.ai>",
"description": "Wrapper implementation for interface-datastore",
"leadMaintainer": "Alex Potsides <alex.potsides@protocol.ai>",
"main": "src/index.js",
"types": "dist/src/index.d.ts",
"scripts": {
"prepare": "aegir build --no-bundle",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"test:webworker": "aegir test -t webworker",
"build": "aegir build",
"lint": "aegir lint",
"release": "aegir release",
"release-minor": "aegir release --type minor",
Expand Down Expand Up @@ -38,19 +39,19 @@
},
"homepage": "https://github.com/ipfs/js-datastore-core#readme",
"devDependencies": {
"aegir": "^28.1.0",
"async-iterator-all": "^1.0.0",
"chai": "^4.2.0",
"dirty-chai": "^2.0.1"
"@types/debug": "^4.1.5",
"aegir": "^30.3.0",
"it-all": "^1.0.4"
},
"dependencies": {
"debug": "^4.1.1",
"interface-datastore": "^2.0.0",
"ipfs-utils": "^4.0.1"
"interface-datastore": "github:ipfs/interface-datastore#feat/ts-types"
},
"engines": {
"node": ">=6.0.0",
"npm": ">=3.0.0"
"node": ">=12.0.0"
},
"eslintConfig": {
"extends": "ipfs"
},
"contributors": [
"achingbrain <[email protected]>",
Expand Down
14 changes: 8 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ const TieredDatastore = require('./tiered')
const NamespaceDatastore = require('./namespace')
const shard = require('./shard')

exports.KeytransformDatastore = KeytransformDatastore
exports.ShardingDatastore = ShardingDatastore
exports.MountDatastore = MountDatastore
exports.TieredDatastore = TieredDatastore
exports.NamespaceDatastore = NamespaceDatastore
exports.shard = shard
module.exports = {
KeytransformDatastore,
ShardingDatastore,
MountDatastore,
TieredDatastore,
NamespaceDatastore,
shard
}
38 changes: 38 additions & 0 deletions src/keytransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,27 @@

const { Adapter, utils } = require('interface-datastore')
hugomrdias marked this conversation as resolved.
Show resolved Hide resolved
const map = utils.map
/**
* @typedef {import('interface-datastore/dist/src/types').Datastore} Datastore
* @typedef {import('interface-datastore/dist/src/types').Options} Options
* @typedef {import('interface-datastore/dist/src/types').Batch} Batch
* @typedef {import('interface-datastore/dist/src/types')} Query
* @typedef {InstanceType<import('interface-datastore')["Key"]>} Key
* @typedef {import('./types').KeyTransform} KeyTransform
*/

/**
* A datastore shim, that wraps around a given datastore, changing
* the way keys look to the user, for example namespacing
* keys, reversing them, etc.
*
* @implements {Datastore}
*/
class KeyTransformDatastore extends Adapter {
/**
* @param {Datastore} child
* @param {KeyTransform} transform
*/
constructor (child, transform) {
super()

Expand All @@ -20,22 +34,42 @@ class KeyTransformDatastore extends Adapter {
return this.child.open()
}

/**
* @param {Key} key
* @param {Uint8Array} val
* @param {Options} [options]
*/
put (key, val, options) {
return this.child.put(this.transform.convert(key), val, options)
}

/**
* @param {Key} key
* @param {Options} [options]
*/
get (key, options) {
return this.child.get(this.transform.convert(key), options)
}

/**
* @param {Key} key
* @param {Options} [options]
*/
has (key, options) {
return this.child.has(this.transform.convert(key), options)
}

/**
* @param {Key} key
* @param {Options} [options]
*/
delete (key, options) {
return this.child.delete(this.transform.convert(key), options)
}

/**
* @returns {Batch}
*/
batch () {
const b = this.child.batch()
return {
Expand All @@ -51,6 +85,10 @@ class KeyTransformDatastore extends Adapter {
}
}

/**
* @param {Query} q
* @param {Options} [options]
*/
query (q, options) {
return map(this.child.query(q, options), e => {
e.key = this.transform.invert(e.key)
Expand Down
Loading