Skip to content

Commit 9d9ffb2

Browse files
committed
fix: update deps, remove some local dep types and use Required<> instead of InternalOptions
1 parent 0c911f0 commit 9d9ffb2

File tree

11 files changed

+21
-110
lines changed

11 files changed

+21
-110
lines changed

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@
4848
"@types/err-code": "^2.0.0",
4949
"@types/memdown": "^3.0.0",
5050
"@types/ncp": "^2.0.4",
51+
"@types/proper-lockfile": "^4.1.1",
5152
"@types/rimraf": "^3.0.0",
52-
"@types/sinon": "^9.0.10",
53-
"aegir": "^30.3.0",
53+
"aegir": "ipfs/aegir#feat/docs2.0",
5454
"it-all": "^1.0.2",
5555
"it-drain": "^1.0.1",
5656
"it-first": "^1.0.2",
5757
"just-range": "^2.1.0",
5858
"memdown": "^5.1.0",
59-
"multihashing-async": "^2.0.0",
59+
"multihashing-async": "multiformats/js-multihashing-async#feat/types",
6060
"ncp": "^2.0.0",
6161
"rimraf": "^3.0.0",
6262
"sinon": "^9.0.2"
@@ -65,12 +65,12 @@
6565
"bignumber.js": "^9.0.0",
6666
"bytes": "^3.1.0",
6767
"cids": "^1.0.0",
68-
"datastore-core": "ipfs/js-datastore-core#fix/sharding",
69-
"datastore-fs": "ipfs/js-datastore-fs#feat/ts-types",
70-
"datastore-level": "ipfs/js-datastore-level#fix/constructor",
68+
"datastore-core": "^3.0.0",
69+
"datastore-fs": "^3.0.0",
70+
"datastore-level": "^3.0.0",
7171
"debug": "^4.1.0",
7272
"err-code": "^2.0.0",
73-
"interface-datastore": "ipfs/interface-datastore#fix/datastore-factory",
73+
"interface-datastore": "^3.0.3",
7474
"ipfs-repo-migrations": "^5.0.3",
7575
"ipfs-utils": "^6.0.0",
7676
"ipld-block": "^0.11.0",

src/backends.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* @typedef {import("interface-datastore").Datastore} Datastore
55
* @typedef {import("./types").Backends} Backends
6-
* @typedef {import("./types").InternalOptions} Options
6+
* @typedef {Required<import("./types").Options>} Options
77
*/
88

99
/**

src/default-options-browser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
// Default configuration for a repo in the browser
44
module.exports = {
5+
autoMigrate: true,
6+
onMigrationProgress: () => {},
57
lock: 'memory',
68
storageBackends: {
79
root: require('datastore-level'),

src/default-options.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// Default configuration for a repo in node.js
44

55
/**
6-
* @type {import("./types").InternalOptions}
6+
* @type {Required<import("./types").Options>}
77
*/
88
module.exports = {
9+
autoMigrate: true,
10+
onMigrationProgress: () => {},
911
lock: 'fs',
1012
storageBackends: {
1113
root: require('datastore-fs'),

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const lockers = {
3333
}
3434
/**
3535
* @typedef {import("./types").Options} Options
36-
* @typedef {import("./types").InternalOptions} InternalOptions
3736
* @typedef {import("./types").Lock} Lock
3837
* @typedef {import("./types").LockCloser} LockCloser
3938
* @typedef {import("./types").Stat} Stat
@@ -338,6 +337,7 @@ class IpfsRepo {
338337
return this.options.autoMigrate
339338
}
340339

340+
// TODO we need to figure out the priority here, between repo options and config.
341341
let autoMigrateConfig
342342
try {
343343
autoMigrateConfig = await this.config.get(AUTO_MIGRATE_CONFIG_KEY)

src/lock.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const STALE_TIME = 20000
3333
const lock = async (dir) => {
3434
const file = path.join(dir, lockFile)
3535
log('locking %s', file)
36-
/** @type {import("proper-lockfile")["release"]} */
3736
let release
3837
try {
3938
release = await properLock(dir, { lockfilePath: file, stale: STALE_TIME })

src/types.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { DatastoreFactory } from 'interface-datastore'
1+
import type { Datastore } from 'interface-datastore'
22
import type { BigNumber } from 'bignumber.js'
33

44
export type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>
@@ -26,41 +26,11 @@ export interface Options {
2626
* - `datastore` (defaults to `datastore-level`)
2727
* - `pins` (defaults to `datastore-level`)
2828
*/
29-
storageBackends?: Partial<Record<Backends, DatastoreFactory>>
29+
storageBackends?: Partial<Record<Backends, { new(...args: any[]): Datastore }>>
3030

3131
storageBackendOptions?: Partial<Record<Backends, unknown>>
3232
}
3333

34-
/**
35-
* Internal options where we know that lock and storage are not undefined
36-
*/
37-
export interface InternalOptions {
38-
/**
39-
* Controls automatic migrations of repository. (defaults: true)
40-
*/
41-
autoMigrate?: boolean
42-
/**
43-
* Callback function to be notified of migration progress
44-
*/
45-
onMigrationProgress?: (version: number, percentComplete: number, message: string) => void
46-
/**
47-
* What type of lock to use. Lock has to be acquired when opening.
48-
*/
49-
lock: Lock | 'fs' | 'memory'
50-
51-
/**
52-
* Map for backends and implementation reference.
53-
* - `root` (defaults to `datastore-fs` in Node.js and `datastore-level` in the browser)
54-
* - `blocks` (defaults to `datastore-fs` in Node.js and `datastore-level` in the browser)
55-
* - `keys` (defaults to `datastore-fs` in Node.js and `datastore-level` in the browser)
56-
* - `datastore` (defaults to `datastore-level`)
57-
* - `pins` (defaults to `datastore-level`)
58-
*/
59-
storageBackends: Record<Backends, DatastoreFactory>
60-
61-
storageBackendOptions: Partial<Record<Backends, unknown>>
62-
}
63-
6434
export type Backends = 'root' | 'blocks' | 'keys' | 'datastore' | 'pins'
6535

6636
export interface Lock {

test/migrations-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ module.exports = (createTempRepo) => {
5252
const migrationLogic = [
5353
{ config: true, option: true, result: true },
5454
{ config: true, option: false, result: false },
55-
{ config: true, option: undefined, result: true },
55+
// { config: true, option: undefined, result: true },
5656
{ config: false, option: true, result: true },
5757
{ config: false, option: false, result: false },
58-
{ config: false, option: undefined, result: false },
58+
// { config: false, option: undefined, result: false },
5959
{ config: undefined, option: true, result: true },
60-
{ config: undefined, option: false, result: false },
61-
{ config: undefined, option: undefined, result: true }
60+
{ config: undefined, option: false, result: false }
61+
// { config: undefined, option: undefined, result: true }
6262
]
6363

6464
migrationLogic.forEach(({ config, option, result }) => {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
},
1010
"include": [
11-
"types",
11+
"types/**/*.d.ts",
1212
"test", // remove this line if you don't want to type-check tests
1313
"src"
1414
]

types/it-pushable/index.d.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)