@fireproof/core 0.10.0-dev → 0.10.2-dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. package/dist/fireproof.browser.js +2 -3
  2. package/dist/fireproof.browser.js.map +2 -2
  3. package/dist/fireproof.cjs.js +2 -3
  4. package/dist/fireproof.cjs.js.map +2 -2
  5. package/dist/fireproof.esm.js +2 -3
  6. package/dist/fireproof.esm.js.map +2 -2
  7. package/package.json +5 -1
  8. package/.eslintrc.cjs +0 -37
  9. package/.vscode/launch.json +0 -12
  10. package/dist/crdt-helpers.browser.js +0 -4961
  11. package/dist/crdt-helpers.browser.js.map +0 -7
  12. package/dist/crdt-helpers.cjs.js +0 -4823
  13. package/dist/crdt-helpers.cjs.js.map +0 -7
  14. package/dist/crdt-helpers.esm.js +0 -4788
  15. package/dist/crdt-helpers.esm.js.map +0 -7
  16. package/dist/crdt.browser.js +0 -18214
  17. package/dist/crdt.browser.js.map +0 -7
  18. package/dist/crdt.cjs.js +0 -8692
  19. package/dist/crdt.cjs.js.map +0 -7
  20. package/dist/crdt.esm.js +0 -8682
  21. package/dist/crdt.esm.js.map +0 -7
  22. package/dist/database.browser.js +0 -18867
  23. package/dist/database.browser.js.map +0 -7
  24. package/dist/database.cjs.js +0 -9296
  25. package/dist/database.cjs.js.map +0 -7
  26. package/dist/database.esm.js +0 -9288
  27. package/dist/database.esm.js.map +0 -7
  28. package/dist/loader-helpers.browser.js +0 -6943
  29. package/dist/loader-helpers.browser.js.map +0 -7
  30. package/dist/loader-helpers.cjs.js +0 -4419
  31. package/dist/loader-helpers.cjs.js.map +0 -7
  32. package/dist/loader-helpers.esm.js +0 -4408
  33. package/dist/loader-helpers.esm.js.map +0 -7
  34. package/dist/loader.browser.js +0 -15968
  35. package/dist/loader.browser.js.map +0 -7
  36. package/dist/loader.cjs.js +0 -6667
  37. package/dist/loader.cjs.js.map +0 -7
  38. package/dist/loader.esm.js +0 -6657
  39. package/dist/loader.esm.js.map +0 -7
  40. package/dist/store-browser.browser.js +0 -1414
  41. package/dist/store-browser.browser.js.map +0 -7
  42. package/dist/store-browser.cjs.js +0 -1387
  43. package/dist/store-browser.cjs.js.map +0 -7
  44. package/dist/store-browser.esm.js +0 -1358
  45. package/dist/store-browser.esm.js.map +0 -7
  46. package/dist/store-fs.browser.js +0 -16142
  47. package/dist/store-fs.browser.js.map +0 -7
  48. package/dist/store-fs.cjs.js +0 -1171
  49. package/dist/store-fs.cjs.js.map +0 -7
  50. package/dist/store-fs.esm.js +0 -1143
  51. package/dist/store-fs.esm.js.map +0 -7
  52. package/dist/store.browser.js +0 -1113
  53. package/dist/store.browser.js.map +0 -7
  54. package/dist/store.cjs.js +0 -1126
  55. package/dist/store.cjs.js.map +0 -7
  56. package/dist/store.esm.js +0 -1097
  57. package/dist/store.esm.js.map +0 -7
  58. package/dist/transaction.browser.js +0 -17241
  59. package/dist/transaction.browser.js.map +0 -7
  60. package/dist/transaction.cjs.js +0 -7842
  61. package/dist/transaction.cjs.js.map +0 -7
  62. package/dist/transaction.esm.js +0 -7831
  63. package/dist/transaction.esm.js.map +0 -7
  64. package/dist/types.d.browser.js +0 -4
  65. package/dist/types.d.browser.js.map +0 -7
  66. package/dist/types.d.cjs.js +0 -19
  67. package/dist/types.d.cjs.js.map +0 -7
  68. package/dist/types.d.esm.js +0 -1
  69. package/dist/types.d.esm.js.map +0 -7
  70. package/scripts/analyze.js +0 -31
  71. package/scripts/build.js +0 -20
  72. package/scripts/serve.js +0 -20
  73. package/scripts/settings.js +0 -65
  74. package/scripts/test.js +0 -14
  75. package/src/crdt-helpers.ts +0 -89
  76. package/src/crdt.ts +0 -45
  77. package/src/database.ts +0 -61
  78. package/src/fireproof.ts +0 -6
  79. package/src/loader-helpers.ts +0 -53
  80. package/src/loader.ts +0 -66
  81. package/src/store-browser.ts +0 -76
  82. package/src/store-fs.ts +0 -51
  83. package/src/store.ts +0 -32
  84. package/src/transaction.ts +0 -68
  85. package/src/types.d.ts +0 -38
  86. package/test/crdt.test.js +0 -142
  87. package/test/database.test.js +0 -144
  88. package/test/fireproof.test.js +0 -50
  89. package/test/globals.d.ts +0 -4
  90. package/test/hello.test.js +0 -9
  91. package/test/helpers.js +0 -34
  92. package/test/loader.test.js +0 -112
  93. package/test/store-fs.test.js +0 -105
  94. package/test/transaction.test.js +0 -90
  95. package/tsconfig.json +0 -18
  96. package/webpack.config.cjs +0 -17
@@ -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
- })
@@ -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
- }
@@ -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
- }