Remove tsc-multi, re-install gts, apply autoformatting and linting

This commit is contained in:
Jon Staab
2024-12-17 10:59:27 -08:00
parent 0b86613161
commit f33e03740e
122 changed files with 2243 additions and 2178 deletions
+30 -29
View File
@@ -1,23 +1,20 @@
import {ctx, nthEq, now} from '@welshman/lib'
import {createEvent, getPubkeyTagValues} from '@welshman/util'
import {Scope, FeedController} from '@welshman/feeds'
import type {RequestOpts, FeedOptions, DVMOpts, Feed} from '@welshman/feeds'
import {makeDvmRequest, DVMEvent} from '@welshman/dvm'
import {makeSecret, Nip01Signer} from '@welshman/signer'
import {pubkey, signer} from './session'
import {getFilterSelections} from './router'
import {loadRelaySelections} from './relaySelections'
import {wotGraph, maxWot, getFollows, getNetwork, getFollowers} from './wot'
import {load} from './subscribe'
import {ctx, nthEq, now} from "@welshman/lib"
import {createEvent, getPubkeyTagValues} from "@welshman/util"
import {Scope, FeedController} from "@welshman/feeds"
import type {RequestOpts, FeedOptions, DVMOpts, Feed} from "@welshman/feeds"
import {makeDvmRequest, DVMEvent} from "@welshman/dvm"
import {makeSecret, Nip01Signer} from "@welshman/signer"
import {pubkey, signer} from "./session.js"
import {getFilterSelections} from "./router.js"
import {loadRelaySelections} from "./relaySelections.js"
import {wotGraph, maxWot, getFollows, getNetwork, getFollowers} from "./wot.js"
import {load} from "./subscribe.js"
export const request = async ({filters = [{}], relays = [], onEvent}: RequestOpts) => {
if (relays.length > 0) {
await load({onEvent, filters, relays})
} else {
await Promise.all(
getFilterSelections(filters)
.map(opts => load({onEvent, ...opts}))
)
await Promise.all(getFilterSelections(filters).map(opts => load({onEvent, ...opts})))
}
}
@@ -32,24 +29,23 @@ export const requestDVM = async ({kind, onEvent, ...request}: DVMOpts) => {
const tags = request.tags || []
const $signer = signer.get() || new Nip01Signer(makeSecret())
const pubkey = await $signer.getPubkey()
const relays =
request.relays
? ctx.app.router.FromRelays(request.relays).getUrls()
: ctx.app.router.FromPubkeys(getPubkeyTagValues(tags)).getUrls()
const relays = request.relays
? ctx.app.router.FromRelays(request.relays).getUrls()
: ctx.app.router.FromPubkeys(getPubkeyTagValues(tags)).getUrls()
if (!tags.some(nthEq(0, 'expiration'))) {
if (!tags.some(nthEq(0, "expiration"))) {
tags.push(["expiration", String(now() + 60)])
}
if (!tags.some(nthEq(0, 'relays'))) {
if (!tags.some(nthEq(0, "relays"))) {
tags.push(["relays", ...relays])
}
if (!tags.some(nthEq(1, 'user'))) {
if (!tags.some(nthEq(1, "user"))) {
tags.push(["param", "user", pubkey])
}
if (!tags.some(nthEq(1, 'max_results'))) {
if (!tags.some(nthEq(1, "max_results"))) {
tags.push(["param", "max_results", "200"])
}
@@ -72,11 +68,16 @@ export const getPubkeysForScope = (scope: string) => {
}
switch (scope) {
case Scope.Self: return [$pubkey]
case Scope.Follows: return getFollows($pubkey)
case Scope.Network: return getNetwork($pubkey)
case Scope.Followers: return getFollowers($pubkey)
default: return []
case Scope.Self:
return [$pubkey]
case Scope.Follows:
return getFollows($pubkey)
case Scope.Network:
return getNetwork($pubkey)
case Scope.Followers:
return getFollowers($pubkey)
default:
return []
}
}
@@ -94,7 +95,7 @@ export const getPubkeysForWOTRange = (min: number, max: number) => {
return pubkeys
}
type _FeedOptions = Partial<Omit<FeedOptions, 'feed'>> & {feed: Feed}
type _FeedOptions = Partial<Omit<FeedOptions, "feed">> & {feed: Feed}
export const createFeedController = (options: _FeedOptions) =>
new FeedController({