@fireproof/core 0.10.0-dev → 0.10.1-dev
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.
- package/package.json +5 -1
- package/.eslintrc.cjs +0 -37
- package/.vscode/launch.json +0 -12
- package/dist/crdt-helpers.browser.js +0 -4961
- package/dist/crdt-helpers.browser.js.map +0 -7
- package/dist/crdt-helpers.cjs.js +0 -4823
- package/dist/crdt-helpers.cjs.js.map +0 -7
- package/dist/crdt-helpers.esm.js +0 -4788
- package/dist/crdt-helpers.esm.js.map +0 -7
- package/dist/crdt.browser.js +0 -18214
- package/dist/crdt.browser.js.map +0 -7
- package/dist/crdt.cjs.js +0 -8692
- package/dist/crdt.cjs.js.map +0 -7
- package/dist/crdt.esm.js +0 -8682
- package/dist/crdt.esm.js.map +0 -7
- package/dist/database.browser.js +0 -18867
- package/dist/database.browser.js.map +0 -7
- package/dist/database.cjs.js +0 -9296
- package/dist/database.cjs.js.map +0 -7
- package/dist/database.esm.js +0 -9288
- package/dist/database.esm.js.map +0 -7
- package/dist/loader-helpers.browser.js +0 -6943
- package/dist/loader-helpers.browser.js.map +0 -7
- package/dist/loader-helpers.cjs.js +0 -4419
- package/dist/loader-helpers.cjs.js.map +0 -7
- package/dist/loader-helpers.esm.js +0 -4408
- package/dist/loader-helpers.esm.js.map +0 -7
- package/dist/loader.browser.js +0 -15968
- package/dist/loader.browser.js.map +0 -7
- package/dist/loader.cjs.js +0 -6667
- package/dist/loader.cjs.js.map +0 -7
- package/dist/loader.esm.js +0 -6657
- package/dist/loader.esm.js.map +0 -7
- package/dist/store-browser.browser.js +0 -1414
- package/dist/store-browser.browser.js.map +0 -7
- package/dist/store-browser.cjs.js +0 -1387
- package/dist/store-browser.cjs.js.map +0 -7
- package/dist/store-browser.esm.js +0 -1358
- package/dist/store-browser.esm.js.map +0 -7
- package/dist/store-fs.browser.js +0 -16142
- package/dist/store-fs.browser.js.map +0 -7
- package/dist/store-fs.cjs.js +0 -1171
- package/dist/store-fs.cjs.js.map +0 -7
- package/dist/store-fs.esm.js +0 -1143
- package/dist/store-fs.esm.js.map +0 -7
- package/dist/store.browser.js +0 -1113
- package/dist/store.browser.js.map +0 -7
- package/dist/store.cjs.js +0 -1126
- package/dist/store.cjs.js.map +0 -7
- package/dist/store.esm.js +0 -1097
- package/dist/store.esm.js.map +0 -7
- package/dist/transaction.browser.js +0 -17241
- package/dist/transaction.browser.js.map +0 -7
- package/dist/transaction.cjs.js +0 -7842
- package/dist/transaction.cjs.js.map +0 -7
- package/dist/transaction.esm.js +0 -7831
- package/dist/transaction.esm.js.map +0 -7
- package/dist/types.d.browser.js +0 -4
- package/dist/types.d.browser.js.map +0 -7
- package/dist/types.d.cjs.js +0 -19
- package/dist/types.d.cjs.js.map +0 -7
- package/dist/types.d.esm.js +0 -1
- package/dist/types.d.esm.js.map +0 -7
- package/scripts/analyze.js +0 -31
- package/scripts/build.js +0 -20
- package/scripts/serve.js +0 -20
- package/scripts/settings.js +0 -65
- package/scripts/test.js +0 -14
- package/src/crdt-helpers.ts +0 -89
- package/src/crdt.ts +0 -45
- package/src/database.ts +0 -61
- package/src/fireproof.ts +0 -6
- package/src/loader-helpers.ts +0 -53
- package/src/loader.ts +0 -66
- package/src/store-browser.ts +0 -76
- package/src/store-fs.ts +0 -51
- package/src/store.ts +0 -32
- package/src/transaction.ts +0 -68
- package/src/types.d.ts +0 -38
- package/test/crdt.test.js +0 -142
- package/test/database.test.js +0 -144
- package/test/fireproof.test.js +0 -50
- package/test/globals.d.ts +0 -4
- package/test/hello.test.js +0 -9
- package/test/helpers.js +0 -34
- package/test/loader.test.js +0 -112
- package/test/store-fs.test.js +0 -105
- package/test/transaction.test.js +0 -90
- package/tsconfig.json +0 -18
- package/webpack.config.cjs +0 -17
package/test/store-fs.test.js
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
4
|
-
/* eslint-disable mocha/max-top-level-suites */
|
5
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
6
|
-
import { join } from 'node:path'
|
7
|
-
import { readFile } from 'node:fs/promises'
|
8
|
-
|
9
|
-
import { CID } from 'multiformats'
|
10
|
-
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
12
|
-
import { assert, matches, equals } from './helpers.js'
|
13
|
-
|
14
|
-
import { CarStoreFS, defaultConfig, HeaderStoreFS } from '../dist/store-fs.esm.js'
|
15
|
-
|
16
|
-
const decoder = new TextDecoder('utf-8')
|
17
|
-
|
18
|
-
describe('CarStoreFS', function () {
|
19
|
-
/** @type {CarStoreFS} */
|
20
|
-
let loader
|
21
|
-
beforeEach(function () {
|
22
|
-
loader = new CarStoreFS('test')
|
23
|
-
})
|
24
|
-
it('should have a name', function () {
|
25
|
-
equals(loader.name, 'test')
|
26
|
-
})
|
27
|
-
it('should save a car', async function () {
|
28
|
-
const car = {
|
29
|
-
cid: 'cid',
|
30
|
-
bytes: new Uint8Array([55, 56, 57])
|
31
|
-
}
|
32
|
-
await loader.save(car)
|
33
|
-
const path = join(defaultConfig.dataDir, loader.name, car.cid + '.car')
|
34
|
-
const data = await readFile(path)
|
35
|
-
equals(data.toString(), decoder.decode(car.bytes))
|
36
|
-
})
|
37
|
-
})
|
38
|
-
|
39
|
-
describe('CarStoreFS with a saved car', function () {
|
40
|
-
/** @type {CarStoreFS} */
|
41
|
-
let loader, car
|
42
|
-
beforeEach(async function () {
|
43
|
-
loader = new CarStoreFS('test2')
|
44
|
-
car = {
|
45
|
-
cid: 'cid',
|
46
|
-
bytes: new Uint8Array([55, 56, 57, 80])
|
47
|
-
}
|
48
|
-
await loader.save(car)
|
49
|
-
})
|
50
|
-
it('should have a car', async function () {
|
51
|
-
const path = join(defaultConfig.dataDir, loader.name, car.cid + '.car')
|
52
|
-
const data = await readFile(path)
|
53
|
-
equals(data.toString(), decoder.decode(car.bytes))
|
54
|
-
})
|
55
|
-
it('should load a car', async function () {
|
56
|
-
const loaded = await loader.load(car.cid)
|
57
|
-
equals(loaded.cid, car.cid)
|
58
|
-
equals(loaded.bytes.constructor.name, 'Uint8Array')
|
59
|
-
equals(loaded.bytes.toString(), car.bytes.toString())
|
60
|
-
})
|
61
|
-
})
|
62
|
-
|
63
|
-
describe('HeaderStoreFS', function () {
|
64
|
-
/** @type {HeaderStoreFS} */
|
65
|
-
let loader
|
66
|
-
beforeEach(function () {
|
67
|
-
loader = new HeaderStoreFS('test')
|
68
|
-
})
|
69
|
-
it('should have a name', function () {
|
70
|
-
equals(loader.name, 'test')
|
71
|
-
})
|
72
|
-
it('should save a header', async function () {
|
73
|
-
const cid = CID.parse('bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4')
|
74
|
-
await loader.save(cid)
|
75
|
-
const path = join(defaultConfig.dataDir, loader.name, 'main.json')
|
76
|
-
const file = await readFile(path)
|
77
|
-
const header = JSON.parse(file.toString())
|
78
|
-
assert(header)
|
79
|
-
assert(header.car)
|
80
|
-
equals(header.car, cid.toString())
|
81
|
-
})
|
82
|
-
})
|
83
|
-
|
84
|
-
describe('HeaderStoreFS with a saved header', function () {
|
85
|
-
/** @type {HeaderStoreFS} */
|
86
|
-
let loader
|
87
|
-
beforeEach(async function () {
|
88
|
-
loader = new HeaderStoreFS('test-saved-header')
|
89
|
-
const cid = CID.parse('bafybeia4luuns6dgymy5kau5rm7r4qzrrzg6cglpzpogussprpy42cmcn4')
|
90
|
-
await loader.save(cid)
|
91
|
-
})
|
92
|
-
it('should have a header', async function () {
|
93
|
-
const path = join(defaultConfig.dataDir, loader.name, 'main.json')
|
94
|
-
const data = await readFile(path)
|
95
|
-
matches(data, /car/)
|
96
|
-
const header = JSON.parse(data.toString())
|
97
|
-
assert(header)
|
98
|
-
assert(header.car)
|
99
|
-
})
|
100
|
-
it('should load a header', async function () {
|
101
|
-
const loaded = await loader.load()
|
102
|
-
assert(loaded)
|
103
|
-
assert(loaded.car)
|
104
|
-
})
|
105
|
-
})
|
package/test/transaction.test.js
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
4
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
5
|
-
/* eslint-disable @typescript-eslint/require-await */
|
6
|
-
/* eslint-disable mocha/max-top-level-suites */
|
7
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
8
|
-
import { assert, equals, notEquals, matches, equalsJSON } from './helpers.js'
|
9
|
-
import { TransactionBlockstore as Blockstore, Transaction } from '../dist/transaction.esm.js'
|
10
|
-
|
11
|
-
describe('Fresh TransactionBlockstore', function () {
|
12
|
-
/** @type {Blockstore} */
|
13
|
-
let blocks
|
14
|
-
beforeEach(function () {
|
15
|
-
blocks = new Blockstore()
|
16
|
-
})
|
17
|
-
it('should not have a name', function () {
|
18
|
-
assert(!blocks.name)
|
19
|
-
})
|
20
|
-
it('should not have a loader', function () {
|
21
|
-
assert(!blocks._loader)
|
22
|
-
})
|
23
|
-
it('should not put', async function () {
|
24
|
-
const e = await blocks.put('key', 'value').catch(e => e)
|
25
|
-
matches(e.message, /transaction/)
|
26
|
-
})
|
27
|
-
it('should yield a transaction', async function () {
|
28
|
-
const txR = await blocks.transaction((tblocks) => {
|
29
|
-
assert(tblocks)
|
30
|
-
assert(tblocks instanceof Transaction)
|
31
|
-
return { head: [] }
|
32
|
-
})
|
33
|
-
assert(txR)
|
34
|
-
equalsJSON(txR, { head: [] })
|
35
|
-
})
|
36
|
-
})
|
37
|
-
|
38
|
-
describe('TransactionBlockstore with name', function () {
|
39
|
-
/** @type {Blockstore} */
|
40
|
-
let blocks
|
41
|
-
beforeEach(function () {
|
42
|
-
blocks = new Blockstore('test')
|
43
|
-
})
|
44
|
-
it('should have a name', function () {
|
45
|
-
equals(blocks.name, 'test')
|
46
|
-
})
|
47
|
-
it('should have a loader', function () {
|
48
|
-
assert(blocks.loader)
|
49
|
-
})
|
50
|
-
it('should get from loader', async function () {
|
51
|
-
blocks.loader.getBlock = async (cid) => {
|
52
|
-
return { cid, bytes: 'bytes' }
|
53
|
-
}
|
54
|
-
const value = await blocks.get('key')
|
55
|
-
equalsJSON(value, { cid: 'key', bytes: 'bytes' })
|
56
|
-
})
|
57
|
-
})
|
58
|
-
|
59
|
-
describe('A transaction', function () {
|
60
|
-
/** @type {Transaction} */
|
61
|
-
let tblocks, blocks
|
62
|
-
beforeEach(async function () {
|
63
|
-
blocks = new Blockstore()
|
64
|
-
tblocks = new Transaction(blocks)
|
65
|
-
blocks.transactions.add(tblocks)
|
66
|
-
})
|
67
|
-
it('should put and get', async function () {
|
68
|
-
await tblocks.put('key', 'bytes')
|
69
|
-
assert(blocks.transactions.has(tblocks))
|
70
|
-
const got = await tblocks.get('key')
|
71
|
-
assert(got)
|
72
|
-
equals(got.cid, 'key')
|
73
|
-
equals(got.bytes, 'bytes')
|
74
|
-
})
|
75
|
-
})
|
76
|
-
|
77
|
-
describe('TransactionBlockstore with a completed transaction', function () {
|
78
|
-
let blocks
|
79
|
-
beforeEach(async function () {
|
80
|
-
blocks = new Blockstore()
|
81
|
-
await blocks.transaction(async (tblocks) => {
|
82
|
-
return await tblocks.put('key', 'value')
|
83
|
-
})
|
84
|
-
})
|
85
|
-
it('should get', async function () {
|
86
|
-
const value = await blocks.get('key')
|
87
|
-
equals(value.cid, 'key')
|
88
|
-
equals(value.bytes, 'value')
|
89
|
-
})
|
90
|
-
})
|
package/tsconfig.json
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"include": ["src", "test", ".eslintrc.cjs", "scripts"],
|
3
|
-
"compilerOptions": {
|
4
|
-
"module": "esnext",
|
5
|
-
"target": "esnext",
|
6
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
7
|
-
"declaration": true,
|
8
|
-
"strict": true,
|
9
|
-
"moduleResolution": "node",
|
10
|
-
"jsx": "react",
|
11
|
-
"skipLibCheck": true,
|
12
|
-
"esModuleInterop": true,
|
13
|
-
"emitDeclarationOnly": true,
|
14
|
-
"outDir": "dist",
|
15
|
-
"rootDir": "src",
|
16
|
-
"forceConsistentCasingInFileNames": true
|
17
|
-
}
|
18
|
-
}
|
package/webpack.config.cjs
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
module: {
|
3
|
-
rules: [
|
4
|
-
{
|
5
|
-
test: /\.tsx?$/,
|
6
|
-
use: 'ts-loader',
|
7
|
-
exclude: /node_modules/
|
8
|
-
}
|
9
|
-
]
|
10
|
-
},
|
11
|
-
resolve: {
|
12
|
-
extensions: ['.tsx', '.ts', '.js'],
|
13
|
-
fallback: {
|
14
|
-
assert: require.resolve('browser-assert')
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|