@fireproof/core 0.5.18 → 0.5.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fireproof/core",
3
- "version": "0.5.18",
4
- "description": "Cloudless database for apps, the browser, and IPFS",
3
+ "version": "0.5.19",
4
+ "description": "Live data for your React app, powered by IPFS",
5
5
  "main": "dist/src/fireproof.js",
6
6
  "module": "dist/src/fireproof.mjs",
7
7
  "typings": "dist/src/fireproof.d.ts",
package/src/clock.js CHANGED
@@ -88,7 +88,7 @@ export class EventBlock extends Block {
88
88
  * @param {Uint8Array} config.bytes
89
89
  */
90
90
  constructor ({ cid, value, bytes }) {
91
- // @ts-expect-error
91
+ // @ts-ignore
92
92
  super({ cid, value, bytes })
93
93
  }
94
94
 
@@ -142,7 +142,7 @@ export class EventFetcher {
142
142
  export async function encodeEventBlock (value) {
143
143
  // TODO: sort parents
144
144
  const { cid, bytes } = await encode({ value, codec: cbor, hasher: sha256 })
145
- // @ts-expect-error
145
+ // @ts-ignore
146
146
  return new Block({ cid, value, bytes })
147
147
  }
148
148
 
@@ -153,7 +153,7 @@ export async function encodeEventBlock (value) {
153
153
  */
154
154
  export async function decodeEventBlock (bytes) {
155
155
  const { cid, value } = await decode({ bytes, codec: cbor, hasher: sha256 })
156
- // @ts-expect-error
156
+ // @ts-ignore
157
157
  return new Block({ cid, value, bytes })
158
158
  }
159
159
 
package/src/database.js CHANGED
@@ -83,6 +83,18 @@ export class Database {
83
83
  }
84
84
  }
85
85
 
86
+ index (name) {
87
+ // iterate over the indexes and gather any with the same name
88
+ // if there are more than one, throw an error
89
+ // if there is one, return it
90
+ // if there are none, return null
91
+ const indexes = [...this.indexes.values()].filter(index => index.name === name)
92
+ if (indexes.length > 1) {
93
+ throw new Error(`Multiple indexes found with name ${name}`)
94
+ }
95
+ return indexes[0] || null
96
+ }
97
+
86
98
  /**
87
99
  * Triggers a notification to all listeners
88
100
  * of the Fireproof instance so they can repaint UI, etc.
@@ -230,12 +242,11 @@ export class Database {
230
242
  return doc
231
243
  }
232
244
  /**
233
- * @typedef {Object} Document
245
+ * @typedef {any} Document
234
246
  * @property {string} _id - The ID of the document (required)
235
247
  * @property {string} [_proof] - The proof of the document (optional)
236
248
  * @property {string} [_clock] - The clock of the document (optional)
237
- * @property {any} [key: string] - Index signature notation to allow any other unknown fields
238
- * * @property {Object.<string, any>} [otherProperties] - Any other unknown properties (optional)
249
+ * @property {Object.<string, any>} [unknown: string] - Any other unknown properties (optional)
239
250
  */
240
251
 
241
252
  /**