Skip to content

Commit

Permalink
Merge branch 'main' into allow-any-json-object-to-be-saved-in-blobstore
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanHahn authored Oct 22, 2024
2 parents 67d685b + c4ae725 commit 8a6390f
Show file tree
Hide file tree
Showing 21 changed files with 189 additions and 171 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- uses: nearform-actions/optic-release-automation-action@v4
with:
commit-message: 'Release {version}'
sync-semver-tags: true
sync-semver-tags: false
access: 'public'
# This prefix is added before the prerelease number, e.g. `v3.0.0-alpha.0`
# prerelease-prefix: 'alpha'
Expand Down
4 changes: 2 additions & 2 deletions docs/api/md/-internal-/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@
- [default](classes/default.md)
- [default](classes/default.md)
- [DenseIndex](classes/DenseIndex.md)
- [DriveLiveDownload](classes/DriveLiveDownload.md)
- [Hyperblobs](classes/Hyperblobs.md)
- [Hyperdrive](classes/Hyperdrive.md)
- [IconApi](classes/IconApi.md)
- [Index](classes/Index.md)
- [IndexWriter](classes/IndexWriter.md)
- [InviteApi](classes/InviteApi.md)
- [LiveDownload](classes/LiveDownload.md)
- [LocalDiscovery](classes/LocalDiscovery.md)
- [LocalPeers](classes/LocalPeers.md)
- [Logger](classes/Logger.md)
Expand All @@ -65,6 +63,7 @@
### Interfaces

- [BitmapOpts](interfaces/BitmapOpts.md)
- [BlobDownloadEvents](interfaces/BlobDownloadEvents.md)
- [BlobDownloadState](interfaces/BlobDownloadState.md)
- [Channel](interfaces/Channel.md)
- [CorestoreEvents](interfaces/CorestoreEvents.md)
Expand Down Expand Up @@ -137,6 +136,7 @@
- [PublicPeerInfo](type-aliases/PublicPeerInfo.md)
- [Range](type-aliases/Range.md)
- [RawStream](type-aliases/RawStream.md)
- [Readable](type-aliases/Readable.md)
- [ReplicationStream](type-aliases/ReplicationStream.md)
- [RoleId](type-aliases/RoleId.md)
- [SchemaName](type-aliases/SchemaName.md)
Expand Down
18 changes: 8 additions & 10 deletions docs/api/md/-internal-/classes/BlobStore.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Enable to return an object with a `block` property with number of bytes removed

### createEntryReadStream()

> **createEntryReadStream**(`driveId`, `entry`, `options`?): `Promise`\<[`BlobReadStream`](BlobReadStream.md)\>
> **createEntryReadStream**(`driveId`, `entry`, `options`?): `Promise`\<[`Readable`](../type-aliases/Readable.md)\>
Optimization for creating the blobs read stream when you have
previously read the entry from Hyperdrive using `drive.entry`
Expand All @@ -79,13 +79,13 @@ Set to `true` to wait for a blob to download, otherwise will throw if blob is no

#### Returns

`Promise`\<[`BlobReadStream`](BlobReadStream.md)\>
`Promise`\<[`Readable`](../type-aliases/Readable.md)\>

***

### createReadStream()

> **createReadStream**(`blobId`, `options`?): `Readable`\<`any`, `any`, `any`, `true`, `false`, `ReadableEvents`\<`any`\>\>
> **createReadStream**(`blobId`, `options`?): [`Readable`](../type-aliases/Readable.md)
#### Parameters

Expand All @@ -103,7 +103,7 @@ Set to `true` to wait for a blob to download, otherwise will throw if blob is no

#### Returns

`Readable`\<`any`, `any`, `any`, `true`, `false`, `ReadableEvents`\<`any`\>\>
[`Readable`](../type-aliases/Readable.md)

***

Expand All @@ -129,7 +129,7 @@ Metadata to store with the blob

### download()

> **download**(`filter`?, `options`?): [`LiveDownload`](LiveDownload.md)
> **download**(`filter`?, `options`?): `TypedEmitter`\<[`BlobDownloadEvents`](../interfaces/BlobDownloadEvents.md)\>
Download blobs from all drives, optionally filtering particular blob types
or blob variants. Download will be 'live' and will continue downloading new
Expand All @@ -152,9 +152,7 @@ Optional AbortSignal to cancel in-progress download

#### Returns

[`LiveDownload`](LiveDownload.md)

EventEmitter with `.state` propery, emits `state` with new state when it updates
`TypedEmitter`\<[`BlobDownloadEvents`](../interfaces/BlobDownloadEvents.md)\>

***

Expand Down Expand Up @@ -188,7 +186,7 @@ Set to `true` to wait for a blob to download, otherwise will throw if blob is no

### get()

> **get**(`blobId`, `opts`): `Promise`\<`Buffer`\>
> **get**(`blobId`, `opts`): `Promise`\<`Uint8Array`\>
#### Parameters

Expand All @@ -206,7 +204,7 @@ Set to `true` to wait for a blob to download, otherwise will throw if blob is no

#### Returns

`Promise`\<`Buffer`\>
`Promise`\<`Uint8Array`\>

***

Expand Down
51 changes: 0 additions & 51 deletions docs/api/md/-internal-/classes/DriveLiveDownload.md

This file was deleted.

53 changes: 0 additions & 53 deletions docs/api/md/-internal-/classes/LiveDownload.md

This file was deleted.

23 changes: 23 additions & 0 deletions docs/api/md/-internal-/interfaces/BlobDownloadEvents.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[**API**](../../README.md)**Docs**

***

[API](../../README.md) / [\<internal\>](../README.md) / BlobDownloadEvents

# Interface: BlobDownloadEvents

## Properties

### state()

> **state**: (`state`) => `void`
Emitted with the current download state whenever it changes (not emitted during initial 'checking' status)

#### Parameters

**state**: [`BlobDownloadState`](BlobDownloadState.md) \| [`BlobDownloadStateError`](../type-aliases/BlobDownloadStateError.md)

#### Returns

`void`
11 changes: 11 additions & 0 deletions docs/api/md/-internal-/type-aliases/Readable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[**API**](../../README.md)**Docs**

***

[API](../../README.md) / [\<internal\>](../README.md) / Readable

# Type Alias: Readable

> **Readable**\<\>: `NodeReadable` \| `StreamxReadable`
## Type Parameters
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@comapeo/core",
"version": "2.0.0",
"version": "2.0.1",
"description": "Offline p2p mapping library",
"main": "src/index.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -191,7 +191,7 @@
"sodium-universal": "^4.0.0",
"start-stop-state-machine": "^1.2.0",
"streamx": "^2.19.0",
"styled-map-package": "^1.1.0",
"styled-map-package": "^2.0.0",
"sub-encoder": "^2.1.1",
"throttle-debounce": "^5.0.0",
"tiny-typed-emitter": "^2.1.0",
Expand Down
1 change: 0 additions & 1 deletion src/config-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,6 @@ function parseIcon(filename, buf) {
if (!matches) {
throw new Error(`Unexpected icon filename ${filename}`)
}
/* eslint-disable no-unused-vars */
const [_, name, size, pixelDensityStr] = matches
const pixelDensity = Number(pixelDensityStr)
if (!(pixelDensity === 1 || pixelDensity === 2 || pixelDensity === 3)) {
Expand Down
7 changes: 5 additions & 2 deletions src/core-ownership.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { discoveryKey } from 'hypercore-crypto'
import pDefer from 'p-defer'
import { NAMESPACES } from './constants.js'
import { TypedEmitter } from 'tiny-typed-emitter'
import { omit } from './lib/omit.js'
/**
* @import {
* CoreOwnershipWithSignatures,
Expand Down Expand Up @@ -167,8 +168,10 @@ export function mapAndValidateCoreOwnership(doc, { coreDiscoveryKey }) {
if (!verifyCoreOwnership(doc)) {
throw new Error('Invalid coreOwnership record: signatures are invalid')
}
// eslint-disable-next-line no-unused-vars
const { identitySignature, coreSignatures, ...docWithoutSignatures } = doc
const docWithoutSignatures = omit(doc, [
'identitySignature',
'coreSignatures',
])
docWithoutSignatures.links = []
return docWithoutSignatures
}
Expand Down
14 changes: 11 additions & 3 deletions src/fastify-plugins/maps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'node:fs/promises'
import path from 'node:path'
import { fetch } from 'undici'
import { Server as SMPServerPlugin } from 'styled-map-package'
import { ReaderWatch, Server as SMPServerPlugin } from 'styled-map-package'

import { noop } from '../utils.js'
import { NotFoundError, ENOENTError } from './utils.js'
Expand All @@ -25,6 +25,10 @@ export async function plugin(fastify, opts) {
if (opts.customMapPath) {
const { customMapPath } = opts

const customMapReader = new ReaderWatch(customMapPath)

fastify.addHook('onClose', () => customMapReader.close().catch(noop))

fastify.get(`/${CUSTOM_MAP_PREFIX}/info`, async () => {
const baseUrl = new URL(fastify.prefix, fastify.listeningOrigin)

Expand Down Expand Up @@ -78,13 +82,17 @@ export async function plugin(fastify, opts) {

fastify.register(SMPServerPlugin, {
prefix: CUSTOM_MAP_PREFIX,
filepath: customMapPath,
reader: customMapReader,
})
}

const fallbackMapReader = new ReaderWatch(opts.fallbackMapPath)

fastify.addHook('onClose', () => fallbackMapReader.close().catch(noop))

fastify.register(SMPServerPlugin, {
prefix: FALLBACK_MAP_PREFIX,
filepath: opts.fallbackMapPath,
reader: fallbackMapReader,
})

fastify.get('/style.json', async (_request, reply) => {
Expand Down
Loading

0 comments on commit 8a6390f

Please sign in to comment.