@fireproof/core 0.4.1 → 0.5.1

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/README.md CHANGED
@@ -8,9 +8,28 @@ to offer a new kind of database that:
8
8
 
9
9
  Learn more about the [concepts and architecture behind Fireproof](https://fireproof.storage/documentation/how-the-database-engine-works/), or jump to the [quick start](#quick-start) for React and server-side examples.
10
10
 
11
+ ## Quick Start
12
+
13
+ Look in the `examples/` directory for projects using the database, or see [examples on CodePen](https://codepen.io/jchrisa/pen/GRYJJEM). If you are adding Fireproof to an existing page, just install it and try some operations.
14
+
15
+ ```sh
16
+ npm install @fireproof/core
17
+ ```
18
+
19
+ In your `app.js` or `app.tsx` file:
20
+
21
+ ```js
22
+ import { Fireproof } from '@fireproof/core'
23
+ const fireproof = Fireproof.storage("my-db")
24
+ const ok = await fireproof.put({ hello: 'world' })
25
+ const doc = await fireproof.get(ok.id)
26
+ ```
27
+
28
+ 🤫 I like to drop a `window.fireproof = fireproof` in there as a development aid.
29
+
11
30
  ### Status
12
31
 
13
- Fireproof is alpha software, you should only use it if you are planning to contribute. For now, [check out our React TodoMVC implementation running in browser-local mode.](https://main--lucky-naiad-5aa507.netlify.app/) It demonstrates document persistence, index queries, and event subscriptions, and uses the [`useFireproof()` React hook.](https://github.com/fireproof-storage/fireproof/blob/main/packages/fireproof/hooks/use-fireproof.tsx)
32
+ Fireproof is alpha software, ready for you to evaluate for your future applications. For now, [check out our React TodoMVC implementation running in browser-local mode.](https://main--lucky-naiad-5aa507.netlify.app/) It demonstrates document persistence, index queries, and event subscriptions, and uses the [`useFireproof()` React hook.](https://github.com/fireproof-storage/fireproof/blob/main/packages/fireproof/hooks/use-fireproof.tsx)
14
33
 
15
34
  [![Test](https://github.com/jchris/fireproof/actions/workflows/test.yml/badge.svg)](https://github.com/jchris/fireproof/actions/workflows/test.yml)
16
35
  [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
@@ -118,28 +137,18 @@ Fireproof is a synthesis of work done by people in the web community over the ye
118
137
 
119
138
  Thanks to Alan Shaw and Mikeal Rogers without whom this project would have never got started. The core Merkle hash-tree clock is based on [Alan's Pail](https://github.com/alanshaw/pail), and you can see the repository history goes all the way back to work begun as a branch of that repo. Mikeal wrote [the prolly trees implementation](https://github.com/mikeal/prolly-trees).
120
139
 
121
- ## Quick Start
122
-
123
- Look in the `examples/` directory for projects using the database. It's not picky how you use it, but we want to provide convenient jumping off places. Think of the examples as great to fork when starting your next project.
124
-
125
- If are adding Fireproof to an existing page, just install it and try some operations.
126
-
127
- ```sh
128
- npm install @fireproof/core
129
- ```
130
-
131
- In your `app.js` or `app.tsx` file:
132
-
133
- ```js
134
- import { Fireproof } from '@fireproof/core'
135
- const fireproof = Fireproof.storage()
136
- const ok = await fireproof.put({ hello: 'world' })
137
- const doc = await fireproof.get(ok.id)
138
- ```
140
+ # Contributing
139
141
 
140
- 🤫 I like to drop a `window.fireproof = fireproof` in there as a development aid.
142
+ To contribute please follow these steps for local setup and installation of the project
141
143
 
142
- # Contributing
144
+ 1. Click on the "Fork" button in the top-right corner of the repository's page. This will create a copy of the repository in your account.
145
+ 2. Clone the forked repository to your local machine using Git.
146
+ 3. Now cd to the target directory, or load the directory in your IDE, and open up a terminal.
147
+ 4. Write the command `pnpm install`. This will install all the dependencies that are listed in the `package.json` file.
148
+ 5. Now change the directory to packages/fireproof using the command `cd packages/fireproof`.
149
+ 6. See the `package.json` file to work with all the listed commands and try them out. You can also test your application locally using `npm test`.
150
+ 7. Also change directory to `examples/todomvc` and run the command `npm run dev` to load up a simple application to understand the use of Fireproof as a real-time database.
151
+ 8. Keep contributing :) See [projects](https://github.com/fireproof-storage/fireproof/projects?query=is%3Aopen) and [issues](https://github.com/fireproof-storage/fireproof/issues) for ideas where to get started.
143
152
 
144
153
  Feel free to join in. All welcome. [Open an issue](https://github.com/jchris/fireproof/issues)!
145
154
 
@@ -1,3 +1,5 @@
1
+ import * as multiformats from 'multiformats';
2
+
1
3
  /**
2
4
  * Represents an DbIndex for a Fireproof database.
3
5
  *
@@ -15,7 +17,7 @@ declare class DbIndex {
15
17
  clock: any;
16
18
  name: any;
17
19
  }): DbIndex;
18
- constructor(database: any, mapFn: any, clock: any, opts?: {});
20
+ constructor(database: any, name: any, mapFn: any, clock?: any, opts?: {});
19
21
  database: any;
20
22
  mapFnString: any;
21
23
  mapFn: any;
@@ -30,7 +32,7 @@ declare class DbIndex {
30
32
  };
31
33
  dbHead: any;
32
34
  instanceId: string;
33
- updateIndexPromise: Promise<void>;
35
+ updateIndexPromise: Promise<any>;
34
36
  makeName(): any;
35
37
  toJSON(): {
36
38
  name: any;
@@ -54,7 +56,7 @@ declare class DbIndex {
54
56
  * @memberof DbIndex
55
57
  * @instance
56
58
  */
57
- query(query: {
59
+ query(query?: {
58
60
  /**
59
61
  * - The range to query.
60
62
  */
@@ -73,7 +75,7 @@ declare class DbIndex {
73
75
  * @returns {Promise<void>}
74
76
  */
75
77
  private updateIndex;
76
- innerUpdateIndex(inBlocks: any): Promise<void>;
78
+ innerUpdateIndex(inBlocks: any): Promise<any>;
77
79
  }
78
80
  /**
79
81
  * JDoc for the result row type.
@@ -105,7 +107,7 @@ type ChangeEvent = {
105
107
  * @param {object} [authCtx] - Optional authorization context object to use for any authentication checks.
106
108
  *
107
109
  */
108
- declare class Database$1 {
110
+ declare class Database {
109
111
  constructor(blocks: any, clock: any, config?: {});
110
112
  listeners: Set<any>;
111
113
  name: any;
@@ -165,6 +167,7 @@ declare class Database$1 {
165
167
  clock: string[];
166
168
  proof: any[];
167
169
  }>;
170
+ allCIDs(): Promise<any[]>;
168
171
  /**
169
172
  * Runs validation on the specified document using the Fireproof instance's configuration. Throws an error if the document is invalid.
170
173
  *
@@ -188,13 +191,13 @@ declare class Database$1 {
188
191
  _id: string;
189
192
  }>;
190
193
  /**
191
- * @typedef {Object} Document
192
- * @property {string} _id - The ID of the document (required)
193
- * @property {string} [_proof] - The proof of the document (optional)
194
- * @property {string} [_clock] - The clock of the document (optional)
195
- * @property {any} [key: string] - Index signature notation to allow any other unknown fields
196
- * * @property {Object.<string, any>} [otherProperties] - Any other unknown properties (optional)
197
- */
194
+ * @typedef {Object} Document
195
+ * @property {string} _id - The ID of the document (required)
196
+ * @property {string} [_proof] - The proof of the document (optional)
197
+ * @property {string} [_clock] - The clock of the document (optional)
198
+ * @property {any} [key: string] - Index signature notation to allow any other unknown fields
199
+ * * @property {Object.<string, any>} [otherProperties] - Any other unknown properties (optional)
200
+ */
198
201
  /**
199
202
  * Adds a new document to the database, or updates an existing document. Returns the ID of the document and the new clock head.
200
203
  *
@@ -249,6 +252,7 @@ declare class Database$1 {
249
252
  * @returns {Promise<{ proof:{}, id: string, clock: CID[] }>} - The result of adding the event to storage
250
253
  */
251
254
  private putToProllyTree;
255
+ applyClock(prevClock: any, newClock: any): void;
252
256
  vis(): AsyncGenerator<any, {
253
257
  cids: any;
254
258
  result: any;
@@ -297,10 +301,10 @@ declare class Listener {
297
301
  * @param {import('./database.js').Database} database
298
302
  * @param {(_: any, emit: any) => void} routingFn
299
303
  */
300
- constructor(database: Database$1, routingFn?: (_: any, emit: any) => void);
304
+ constructor(database: Database, routingFn?: (_: any, emit: any) => void);
301
305
  subcribers: Map<any, any>;
302
306
  doStopListening: any;
303
- database: Database$1;
307
+ database: Database;
304
308
  /**
305
309
  * The map function to apply to each entry in the database.
306
310
  * @type {Function}
@@ -339,6 +343,7 @@ declare class Fireproof {
339
343
  static fromJSON(json: any, database: any): any;
340
344
  static snapshot(database: any, clock: any): any;
341
345
  static zoom(database: any, clock: any): Promise<any>;
346
+ static makeCar(database: any, key: any): Promise<multiformats.BlockView<Uint8Array, 85, 18, 1>>;
342
347
  }
343
348
 
344
- export { Fireproof, DbIndex as Index, Listener };
349
+ export { Database, Fireproof, DbIndex as Index, Listener };