Format
tests / tests (push) Failing after 5m17s

This commit is contained in:
Jon Staab
2026-06-20 10:36:40 -07:00
parent d2b57c559d
commit 22a666d497
53 changed files with 388 additions and 145 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ export class App implements IApp {
repository: Repository
wrapManager: WrapManager
private singletons = new Map<Function, unknown>()
private singletons = new Map<new (app: IApp) => unknown, unknown>()
private unsubscribers: Unsubscriber[] = []
constructor(options: AppOptions = {}) {
@@ -25,8 +25,7 @@ export class BlockedRelayLists extends DerivedPlugin<BlockedRelayList> {
return this.app.use(Network).loadUsingOutbox(pubkey, {kinds: [BLOCKED_RELAYS]}, relayHints)
}
urls = (pubkey: string): Projection<string[]> =>
this.project(pubkey, list => list?.urls() ?? [])
urls = (pubkey: string): Projection<string[]> => this.project(pubkey, list => list?.urls() ?? [])
update = async (fn: (builder: BlockedRelayListBuilder) => void) => {
const user = User.require(this.app)
+5 -1
View File
@@ -22,7 +22,11 @@ export class Logger {
log(
source: string,
{id = randomId(), at = Date.now(), ...message}: {id?: string; at?: number; [key: string]: unknown},
{
id = randomId(),
at = Date.now(),
...message
}: {id?: string; at?: number; [key: string]: unknown},
) {
this.store.update($messages => $messages.concat({source, id, at, ...message}).slice(-1000))
}
@@ -25,8 +25,7 @@ export class MessagingRelayLists extends DerivedPlugin<MessagingRelayList> {
return this.app.use(Network).loadUsingOutbox(pubkey, {kinds: [MESSAGING_RELAYS]}, relayHints)
}
urls = (pubkey: string): Projection<string[]> =>
this.project(pubkey, list => list?.urls() ?? [])
urls = (pubkey: string): Projection<string[]> => this.project(pubkey, list => list?.urls() ?? [])
update = async (fn: (builder: MessagingRelayListBuilder) => void) => {
const user = User.require(this.app)
+2 -3
View File
@@ -43,9 +43,8 @@ export class Profiles extends DerivedPlugin<Profile> {
const read = ($profile: Maybe<Profile>) =>
pubkey ? ($profile?.display() ?? displayPubkey(pubkey)) : ""
return projection(
pubkey ? derived(this.one(pubkey, ...args), read) : readable(""),
() => read(pubkey ? this.get(pubkey) : undefined),
return projection(pubkey ? derived(this.one(pubkey, ...args), read) : readable(""), () =>
read(pubkey ? this.get(pubkey) : undefined),
)
}
}
+1 -2
View File
@@ -34,8 +34,7 @@ export class RelayLists extends DerivedPlugin<RelayList> {
])
}
urls = (pubkey: string): Projection<string[]> =>
this.project(pubkey, list => list?.urls() ?? [])
urls = (pubkey: string): Projection<string[]> => this.project(pubkey, list => list?.urls() ?? [])
readUrls = (pubkey: string): Projection<string[]> =>
this.project(pubkey, list => list?.readUrls() ?? [])
+4 -1
View File
@@ -65,7 +65,10 @@ export class Rooms {
this.publish(url, await new RoomLeaveBuilder().setGroup(room.h).toTemplate())
addMember = async (url: string, room: RoomMeta, pubkey: string) =>
this.publish(url, await new RoomAddMemberBuilder().setGroup(room.h).addPubkey(pubkey).toTemplate())
this.publish(
url,
await new RoomAddMemberBuilder().setGroup(room.h).addPubkey(pubkey).toTemplate(),
)
removeMember = async (url: string, room: RoomMeta, pubkey: string) =>
this.publish(
+2 -8
View File
@@ -81,11 +81,7 @@ export class Searches {
return dec(score) * inc(wotScore / (this.app.use(Wot).max.get() || 1))
},
fuseOptions: {
keys: [
"nip05",
{name: "name", weight: 0.8},
{name: "about", weight: 0.3},
],
keys: ["nip05", {name: "name", weight: 0.8}, {name: "about", weight: 0.3}],
threshold: 0.3,
shouldSort: false,
// Read fields off the domain reader's parsed `values`; only expose a
@@ -96,9 +92,7 @@ export class Searches {
if (key === "nip05") {
const nip05 = profile.nip05()
return nip05 && $handlesByNip05.get(nip05)?.pubkey === profile.author()
? nip05
: ""
return nip05 && $handlesByNip05.get(nip05)?.pubkey === profile.author() ? nip05 : ""
}
return profile.values[key] ?? ""
+1 -2
View File
@@ -25,8 +25,7 @@ export class SearchRelayLists extends DerivedPlugin<SearchRelayList> {
return this.app.use(Network).loadUsingOutbox(pubkey, {kinds: [SEARCH_RELAYS]}, relayHints)
}
urls = (pubkey: string): Projection<string[]> =>
this.project(pubkey, list => list?.urls() ?? [])
urls = (pubkey: string): Projection<string[]> => this.project(pubkey, list => list?.urls() ?? [])
update = async (fn: (builder: SearchRelayListBuilder) => void) => {
const user = User.require(this.app)
+3 -1
View File
@@ -45,7 +45,9 @@ export class Sync {
if (await this.app.use(Relays).hasNegentropy(relay)) {
await net.push({filters, events, relays: [relay]})
} else {
await Promise.all(events.map((event: SignedEvent) => net.publish({event, relays: [relay]})))
await Promise.all(
events.map((event: SignedEvent) => net.publish({event, relays: [relay]})),
)
}
}),
)
+1 -1
View File
@@ -1,7 +1,7 @@
import type {Subscriber} from "svelte/store"
import {writable} from "svelte/store"
import type {Override} from "@welshman/lib"
import {append, TaskQueue, ensurePlural, remove, defer, sleep, nth, uniq, without} from "@welshman/lib"
import {append, TaskQueue, ensurePlural, remove, defer, sleep, nth, without} from "@welshman/lib"
import {
HashedEvent,
EventTemplate,
+3 -1
View File
@@ -160,7 +160,9 @@ export class Wot {
if (pubkey) {
const theirFollows = $follows.get(pubkey)?.pubkeys() ?? []
follows = theirFollows.filter(other => ($follows.get(other)?.pubkeys() ?? []).includes(target))
follows = theirFollows.filter(other =>
($follows.get(other)?.pubkeys() ?? []).includes(target),
)
mutes = theirFollows.filter(other => ($mutes.get(other)?.pubkeys() ?? []).includes(target))
} else {
follows = Array.from($followers.get(target) || [])
-1
View File
@@ -1,4 +1,3 @@
import {get, writable} from "svelte/store"
import {TaskQueue, uniq, now} from "@welshman/lib"
import {getPubkeyTagValues, prep} from "@welshman/util"
import type {TrustedEvent, SignedEvent, EventTemplate} from "@welshman/util"
+6 -5
View File
@@ -15,7 +15,6 @@ import type {Profile} from "@welshman/domain"
import {deriveDeduplicated, deriveDeduplicatedByValue} from "@welshman/store"
import {LoadableMapPlugin, projection} from "./base.js"
import type {Projection} from "./base.js"
import type {IApp} from "../app.js"
import {Profiles} from "./profiles.js"
/**
@@ -147,11 +146,13 @@ export class Zappers extends LoadableMapPlugin<Zapper> {
)
}
const stores: Readable<any>[] = [this.index.$, ...splits.map(split => profiles.one(split.pubkey))]
const stores: Readable<any>[] = [
this.index.$,
...splits.map(split => profiles.one(split.pubkey)),
]
return projection(
deriveDeduplicatedByValue(stores, read),
() => read([this.index.get(), ...splits.map(split => profiles.get(split.pubkey))]),
return projection(deriveDeduplicatedByValue(stores, read), () =>
read([this.index.get(), ...splits.map(split => profiles.get(split.pubkey))]),
)
}
}
+15 -19
View File
@@ -1,5 +1,5 @@
import type {Unsubscriber} from "svelte/store"
import {on, noop, always, call} from "@welshman/lib"
import {on, noop, always} from "@welshman/lib"
import {WRAP, isDVMKind, isEphemeralKind, verifyEvent} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
import {SocketEvent, isRelayEvent, makeSocketPolicyAuth} from "@welshman/net"
@@ -62,11 +62,7 @@ export const appPolicyAuthUnlessBlocked = makeAppPolicyAuth((socket, app) => {
return false
}
return !app
.use(BlockedRelayLists)
.urls(app.user.pubkey)
.get()
.includes(socket.url)
return !app.use(BlockedRelayLists).urls(app.user.pubkey).get().includes(socket.url)
})
/**
@@ -144,25 +140,25 @@ export const appPolicyCacheDecrypt: AppPolicy = app => {
* Wraps user.signer in a WrappedSigner which logs sign requests to the app logger.
*/
export const appPolicyLogSignerMethods: AppPolicy = app => {
if (!app.user) return noop
if (!app.user) return noop
const logger = app.use(Logger)
const logger = app.use(Logger)
return app.user.wrapSigner(async (method, thunk) => {
logger.log("signer", {method, status: "pending"})
return app.user.wrapSigner(async (method, thunk) => {
logger.log("signer", {method, status: "pending"})
try {
const result = await thunk()
try {
const result = await thunk()
logger.log("signer", {method, status: "success"})
logger.log("signer", {method, status: "success"})
return result
} catch (error) {
logger.log("signer", {method, status: "failure", error})
return result
} catch (error) {
logger.log("signer", {method, status: "failure", error})
throw error
}
})
throw error
}
})
}
export const defaultAppPolicies: AppPolicy[] = [